* [PATCH v2 net-next 0/9] bonding: simple macro cleanup
@ 2014-05-15 12:29 Veaceslav Falico
2014-05-15 12:29 ` [PATCH v2 net-next 1/9] bonding: remove BOND_MODE_IS_LB macro Veaceslav Falico
` (8 more replies)
0 siblings, 9 replies; 16+ messages in thread
From: Veaceslav Falico @ 2014-05-15 12:29 UTC (permalink / raw)
To: netdev; +Cc: Jay Vosburgh, Andy Gospodarek, Veaceslav Falico
Hi,
Trivial patchset that converts most of the bonding's macros into inline
functions. It introduces only one macro, BOND_MODE(), which is just
bond->params.mode, better to write/understand/remember.
The only real change is the removal of IFF_UP verification, which always
came in pair with && netif_running(), and is though useless, as it's always
IFF_UP when LINK_STATE_RUNNING.
v1->v2: use inlined functions instead of macros.
CC: Jay Vosburgh <j.vosburgh@gmail.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: netdev@vger.kernel.org
Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
---
drivers/net/bonding/bond_3ad.c | 6 +-
drivers/net/bonding/bond_alb.c | 18 ++---
drivers/net/bonding/bond_debugfs.c | 2 +-
drivers/net/bonding/bond_main.c | 143 ++++++++++++++++-----------------
drivers/net/bonding/bond_netlink.c | 6 +-
drivers/net/bonding/bond_options.c | 10 +--
drivers/net/bonding/bond_procfs.c | 14 ++--
drivers/net/bonding/bond_sysfs.c | 14 ++--
drivers/net/bonding/bond_sysfs_slave.c | 2 +-
drivers/net/bonding/bonding.h | 84 +++++++++----------
10 files changed, 145 insertions(+), 154 deletions(-)
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 net-next 1/9] bonding: remove BOND_MODE_IS_LB macro
2014-05-15 12:29 [PATCH v2 net-next 0/9] bonding: simple macro cleanup Veaceslav Falico
@ 2014-05-15 12:29 ` Veaceslav Falico
2014-05-15 12:29 ` [PATCH v2 net-next 2/9] bonding: make TX_QUEUE_OVERRIDE() macro an inline function Veaceslav Falico
` (7 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Veaceslav Falico @ 2014-05-15 12:29 UTC (permalink / raw)
To: netdev; +Cc: Veaceslav Falico, Jay Vosburgh, Andy Gospodarek
It's used only in an inline function and is useless.
CC: Jay Vosburgh <j.vosburgh@gmail.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
---
drivers/net/bonding/bonding.h | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index c51c433..16e57a1 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -69,10 +69,6 @@
(((mode) == BOND_MODE_ACTIVEBACKUP) || \
((mode) == BOND_MODE_ROUNDROBIN))
-#define BOND_MODE_IS_LB(mode) \
- (((mode) == BOND_MODE_TLB) || \
- ((mode) == BOND_MODE_ALB))
-
#define IS_IP_TARGET_UNUSABLE_ADDRESS(a) \
((htonl(INADDR_BROADCAST) == a) || \
ipv4_is_zeronet(a))
@@ -290,7 +286,8 @@ static inline struct bonding *bond_get_bond_by_slave(struct slave *slave)
static inline bool bond_is_lb(const struct bonding *bond)
{
- return BOND_MODE_IS_LB(bond->params.mode);
+ return bond->params.mode == BOND_MODE_TLB ||
+ bond->params.mode == BOND_MODE_ALB;
}
static inline void bond_set_active_slave(struct slave *slave)
--
1.8.4
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 net-next 2/9] bonding: make TX_QUEUE_OVERRIDE() macro an inline function
2014-05-15 12:29 [PATCH v2 net-next 0/9] bonding: simple macro cleanup Veaceslav Falico
2014-05-15 12:29 ` [PATCH v2 net-next 1/9] bonding: remove BOND_MODE_IS_LB macro Veaceslav Falico
@ 2014-05-15 12:29 ` Veaceslav Falico
2014-05-15 12:29 ` [PATCH v2 net-next 3/9] bonding: make BOND_NO_USES_ARP " Veaceslav Falico
` (6 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Veaceslav Falico @ 2014-05-15 12:29 UTC (permalink / raw)
To: netdev; +Cc: Veaceslav Falico, Jay Vosburgh, Andy Gospodarek
Also, make it accept bonding as a parameter and change the name a bit to
better reflect its scope.
CC: Jay Vosburgh <j.vosburgh@gmail.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
---
drivers/net/bonding/bond_main.c | 7 +++----
drivers/net/bonding/bonding.h | 10 ++++++----
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 90ebed6..5c88c11 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3788,10 +3788,9 @@ static netdev_tx_t __bond_start_xmit(struct sk_buff *skb, struct net_device *dev
{
struct bonding *bond = netdev_priv(dev);
- if (TX_QUEUE_OVERRIDE(bond->params.mode)) {
- if (!bond_slave_override(bond, skb))
- return NETDEV_TX_OK;
- }
+ if (bond_should_override_tx_queue(bond) &&
+ !bond_slave_override(bond, skb))
+ return NETDEV_TX_OK;
switch (bond->params.mode) {
case BOND_MODE_ROUNDROBIN:
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 16e57a1..dca3dfd 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -65,10 +65,6 @@
((mode) == BOND_MODE_TLB) || \
((mode) == BOND_MODE_ALB))
-#define TX_QUEUE_OVERRIDE(mode) \
- (((mode) == BOND_MODE_ACTIVEBACKUP) || \
- ((mode) == BOND_MODE_ROUNDROBIN))
-
#define IS_IP_TARGET_UNUSABLE_ADDRESS(a) \
((htonl(INADDR_BROADCAST) == a) || \
ipv4_is_zeronet(a))
@@ -284,6 +280,12 @@ static inline struct bonding *bond_get_bond_by_slave(struct slave *slave)
return slave->bond;
}
+static inline bool bond_should_override_tx_queue(struct bonding *bond)
+{
+ return bond->params.mode == BOND_MODE_ACTIVEBACKUP ||
+ bond->params.mode == BOND_MODE_ROUNDROBIN;
+}
+
static inline bool bond_is_lb(const struct bonding *bond)
{
return bond->params.mode == BOND_MODE_TLB ||
--
1.8.4
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 net-next 3/9] bonding: make BOND_NO_USES_ARP an inline function
2014-05-15 12:29 [PATCH v2 net-next 0/9] bonding: simple macro cleanup Veaceslav Falico
2014-05-15 12:29 ` [PATCH v2 net-next 1/9] bonding: remove BOND_MODE_IS_LB macro Veaceslav Falico
2014-05-15 12:29 ` [PATCH v2 net-next 2/9] bonding: make TX_QUEUE_OVERRIDE() macro an inline function Veaceslav Falico
@ 2014-05-15 12:29 ` Veaceslav Falico
2014-05-15 15:35 ` Alexei Starovoitov
2014-05-15 12:29 ` [PATCH v2 net-next 4/9] bonding: make USES_PRIMARY " Veaceslav Falico
` (5 subsequent siblings)
8 siblings, 1 reply; 16+ messages in thread
From: Veaceslav Falico @ 2014-05-15 12:29 UTC (permalink / raw)
To: netdev; +Cc: Veaceslav Falico, Jay Vosburgh, Andy Gospodarek
Also, change its name to better reflect its scope, and skip the "no"
part.
CC: Jay Vosburgh <j.vosburgh@gmail.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
---
drivers/net/bonding/bond_main.c | 2 +-
drivers/net/bonding/bond_options.c | 2 +-
drivers/net/bonding/bonding.h | 11 ++++++-----
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 5c88c11..2448e28 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4113,7 +4113,7 @@ static int bond_check_params(struct bond_params *params)
}
/* reset values for 802.3ad/TLB/ALB */
- if (BOND_NO_USES_ARP(bond_mode)) {
+ if (!bond_mode_uses_arp(bond_mode)) {
if (!miimon) {
pr_warn("Warning: miimon must be specified, otherwise bonding will not detect link failure, speed and duplex which are essential for 802.3ad operation\n");
pr_warn("Forcing miimon to 100msec\n");
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index 6dc49da..98c8801 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -672,7 +672,7 @@ const struct bond_option *bond_opt_get(unsigned int option)
int bond_option_mode_set(struct bonding *bond, const struct bond_opt_value *newval)
{
- if (BOND_NO_USES_ARP(newval->value) && bond->params.arp_interval) {
+ if (!bond_mode_uses_arp(newval->value) && bond->params.arp_interval) {
pr_info("%s: %s mode is incompatible with arp monitoring, start mii monitoring\n",
bond->dev->name, newval->string);
/* disable arp monitoring */
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index dca3dfd..8f9f0df 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -60,11 +60,6 @@
((mode) == BOND_MODE_TLB) || \
((mode) == BOND_MODE_ALB))
-#define BOND_NO_USES_ARP(mode) \
- (((mode) == BOND_MODE_8023AD) || \
- ((mode) == BOND_MODE_TLB) || \
- ((mode) == BOND_MODE_ALB))
-
#define IS_IP_TARGET_UNUSABLE_ADDRESS(a) \
((htonl(INADDR_BROADCAST) == a) || \
ipv4_is_zeronet(a))
@@ -292,6 +287,12 @@ static inline bool bond_is_lb(const struct bonding *bond)
bond->params.mode == BOND_MODE_ALB;
}
+static inline bool bond_mode_uses_arp(int mode)
+{
+ return mode == BOND_MODE_8023AD || mode == BOND_MODE_TLB ||
+ mode == BOND_MODE_ALB;
+}
+
static inline void bond_set_active_slave(struct slave *slave)
{
if (slave->backup) {
--
1.8.4
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 net-next 4/9] bonding: make USES_PRIMARY inline function
2014-05-15 12:29 [PATCH v2 net-next 0/9] bonding: simple macro cleanup Veaceslav Falico
` (2 preceding siblings ...)
2014-05-15 12:29 ` [PATCH v2 net-next 3/9] bonding: make BOND_NO_USES_ARP " Veaceslav Falico
@ 2014-05-15 12:29 ` Veaceslav Falico
2014-05-15 12:29 ` [PATCH v2 net-next 5/9] bonding: create a macro for bond mode and use it Veaceslav Falico
` (4 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Veaceslav Falico @ 2014-05-15 12:29 UTC (permalink / raw)
To: netdev; +Cc: Veaceslav Falico, Jay Vosburgh, Andy Gospodarek
Change the name a bit to better reflect its scope, and update some
comments.
CC: Jay Vosburgh <j.vosburgh@gmail.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
---
drivers/net/bonding/bond_main.c | 38 +++++++++++++++++++-------------------
drivers/net/bonding/bond_options.c | 2 +-
drivers/net/bonding/bond_procfs.c | 2 +-
drivers/net/bonding/bonding.h | 12 ++++++------
4 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 2448e28..17b68b5 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -497,7 +497,7 @@ static int bond_set_promiscuity(struct bonding *bond, int inc)
struct list_head *iter;
int err = 0;
- if (USES_PRIMARY(bond->params.mode)) {
+ if (bond_mode_uses_primary(bond->params.mode)) {
/* write lock already acquired */
if (bond->curr_active_slave) {
err = dev_set_promiscuity(bond->curr_active_slave->dev,
@@ -523,7 +523,7 @@ static int bond_set_allmulti(struct bonding *bond, int inc)
struct list_head *iter;
int err = 0;
- if (USES_PRIMARY(bond->params.mode)) {
+ if (bond_mode_uses_primary(bond->params.mode)) {
/* write lock already acquired */
if (bond->curr_active_slave) {
err = dev_set_allmulti(bond->curr_active_slave->dev,
@@ -585,8 +585,8 @@ static void bond_hw_addr_flush(struct net_device *bond_dev,
/*--------------------------- Active slave change ---------------------------*/
/* Update the hardware address list and promisc/allmulti for the new and
- * old active slaves (if any). Modes that are !USES_PRIMARY keep all
- * slaves up date at all times; only the USES_PRIMARY modes need to call
+ * old active slaves (if any). Modes that are not using primary keep all
+ * slaves up date at all times; only the modes that use primary need to call
* this function to swap these settings during a failover.
*/
static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active,
@@ -801,7 +801,7 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
new_active->last_link_up = jiffies;
if (new_active->link == BOND_LINK_BACK) {
- if (USES_PRIMARY(bond->params.mode)) {
+ if (bond_mode_uses_primary(bond->params.mode)) {
pr_info("%s: making interface %s the new active one %d ms earlier\n",
bond->dev->name, new_active->dev->name,
(bond->params.updelay - new_active->delay) * bond->params.miimon);
@@ -816,14 +816,14 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
if (bond_is_lb(bond))
bond_alb_handle_link_change(bond, new_active, BOND_LINK_UP);
} else {
- if (USES_PRIMARY(bond->params.mode)) {
+ if (bond_mode_uses_primary(bond->params.mode)) {
pr_info("%s: making interface %s the new active one\n",
bond->dev->name, new_active->dev->name);
}
}
}
- if (USES_PRIMARY(bond->params.mode))
+ if (bond_mode_uses_primary(bond->params.mode))
bond_hw_addr_swap(bond, new_active, old_active);
if (bond_is_lb(bond)) {
@@ -876,7 +876,7 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
* resend only if bond is brought up with the affected
* bonding modes and the retransmission is enabled */
if (netif_running(bond->dev) && (bond->params.resend_igmp > 0) &&
- ((USES_PRIMARY(bond->params.mode) && new_active) ||
+ ((bond_mode_uses_primary(bond->params.mode) && new_active) ||
bond->params.mode == BOND_MODE_ROUNDROBIN)) {
bond->igmp_retrans = bond->params.resend_igmp;
queue_delayed_work(bond->wq, &bond->mcast_work, 1);
@@ -1381,10 +1381,10 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
goto err_close;
}
- /* If the mode USES_PRIMARY, then the following is handled by
+ /* If the mode uses primary, then the following is handled by
* bond_change_active_slave().
*/
- if (!USES_PRIMARY(bond->params.mode)) {
+ if (!bond_mode_uses_primary(bond->params.mode)) {
/* set promiscuity level to new slave */
if (bond_dev->flags & IFF_PROMISC) {
res = dev_set_promiscuity(slave_dev, 1);
@@ -1480,7 +1480,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
new_slave->link == BOND_LINK_DOWN ? "DOWN" :
(new_slave->link == BOND_LINK_UP ? "UP" : "BACK"));
- if (USES_PRIMARY(bond->params.mode) && bond->params.primary[0]) {
+ if (bond_mode_uses_primary(bond->params.mode) && bond->params.primary[0]) {
/* if there is a primary slave, remember it */
if (strcmp(bond->params.primary, new_slave->dev->name) == 0) {
bond->primary_slave = new_slave;
@@ -1569,7 +1569,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
bond_compute_features(bond);
bond_set_carrier(bond);
- if (USES_PRIMARY(bond->params.mode)) {
+ if (bond_mode_uses_primary(bond->params.mode)) {
block_netpoll_tx();
write_lock_bh(&bond->curr_slave_lock);
bond_select_active_slave(bond);
@@ -1593,7 +1593,7 @@ err_unregister:
netdev_rx_handler_unregister(slave_dev);
err_detach:
- if (!USES_PRIMARY(bond->params.mode))
+ if (!bond_mode_uses_primary(bond->params.mode))
bond_hw_addr_flush(bond_dev, slave_dev);
vlan_vids_del_by_dev(slave_dev, bond_dev);
@@ -1778,10 +1778,10 @@ static int __bond_release_one(struct net_device *bond_dev,
/* must do this from outside any spinlocks */
vlan_vids_del_by_dev(slave_dev, bond_dev);
- /* If the mode USES_PRIMARY, then this cases was handled above by
+ /* If the mode uses primary, then this cases was handled above by
* bond_change_active_slave(..., NULL)
*/
- if (!USES_PRIMARY(bond->params.mode)) {
+ if (!bond_mode_uses_primary(bond->params.mode)) {
/* unset promiscuity level from slave
* NOTE: The NETDEV_CHANGEADDR call above may change the value
* of the IFF_PROMISC flag in the bond_dev, but we need the
@@ -2915,7 +2915,7 @@ static int bond_slave_netdev_event(unsigned long event,
break;
case NETDEV_CHANGENAME:
/* we don't care if we don't have primary set */
- if (!USES_PRIMARY(bond->params.mode) ||
+ if (!bond_mode_uses_primary(bond->params.mode) ||
!bond->params.primary[0])
break;
@@ -3105,7 +3105,7 @@ static int bond_open(struct net_device *bond_dev)
if (bond_has_slaves(bond)) {
read_lock(&bond->curr_slave_lock);
bond_for_each_slave(bond, slave, iter) {
- if (USES_PRIMARY(bond->params.mode)
+ if (bond_mode_uses_primary(bond->params.mode)
&& (slave != bond->curr_active_slave)) {
bond_set_slave_inactive_flags(slave,
BOND_SLAVE_NOTIFY_NOW);
@@ -3343,7 +3343,7 @@ static void bond_set_rx_mode(struct net_device *bond_dev)
rcu_read_lock();
- if (USES_PRIMARY(bond->params.mode)) {
+ if (bond_mode_uses_primary(bond->params.mode)) {
slave = rcu_dereference(bond->curr_active_slave);
if (slave) {
dev_uc_sync(slave->dev, bond_dev);
@@ -4268,7 +4268,7 @@ static int bond_check_params(struct bond_params *params)
pr_debug("Warning: either miimon or arp_interval and arp_ip_target module parameters must be specified, otherwise bonding will not detect link failures! see bonding.txt for details\n");
}
- if (primary && !USES_PRIMARY(bond_mode)) {
+ if (primary && !bond_mode_uses_primary(bond_mode)) {
/* currently, using a primary only makes sense
* in active backup, TLB or ALB modes
*/
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index 98c8801..afae661 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -693,7 +693,7 @@ int bond_option_mode_set(struct bonding *bond, const struct bond_opt_value *newv
static struct net_device *__bond_option_active_slave_get(struct bonding *bond,
struct slave *slave)
{
- return USES_PRIMARY(bond->params.mode) && slave ? slave->dev : NULL;
+ return bond_mode_uses_primary(bond->params.mode) && slave ? slave->dev : NULL;
}
struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond)
diff --git a/drivers/net/bonding/bond_procfs.c b/drivers/net/bonding/bond_procfs.c
index 6a261c8..7cf55a5 100644
--- a/drivers/net/bonding/bond_procfs.c
+++ b/drivers/net/bonding/bond_procfs.c
@@ -91,7 +91,7 @@ static void bond_info_show_master(struct seq_file *seq)
optval->string, bond->params.xmit_policy);
}
- if (USES_PRIMARY(bond->params.mode)) {
+ if (bond_mode_uses_primary(bond->params.mode)) {
seq_printf(seq, "Primary Slave: %s",
(bond->primary_slave) ?
bond->primary_slave->dev->name : "None");
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 8f9f0df..34a8ed5 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -54,12 +54,6 @@
((slave)->link == BOND_LINK_UP) && \
bond_is_active_slave(slave))
-
-#define USES_PRIMARY(mode) \
- (((mode) == BOND_MODE_ACTIVEBACKUP) || \
- ((mode) == BOND_MODE_TLB) || \
- ((mode) == BOND_MODE_ALB))
-
#define IS_IP_TARGET_UNUSABLE_ADDRESS(a) \
((htonl(INADDR_BROADCAST) == a) || \
ipv4_is_zeronet(a))
@@ -293,6 +287,12 @@ static inline bool bond_mode_uses_arp(int mode)
mode == BOND_MODE_ALB;
}
+static inline bool bond_mode_uses_primary(int mode)
+{
+ return mode == BOND_MODE_ACTIVEBACKUP || mode == BOND_MODE_TLB ||
+ mode == BOND_MODE_ALB;
+}
+
static inline void bond_set_active_slave(struct slave *slave)
{
if (slave->backup) {
--
1.8.4
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 net-next 5/9] bonding: create a macro for bond mode and use it
2014-05-15 12:29 [PATCH v2 net-next 0/9] bonding: simple macro cleanup Veaceslav Falico
` (3 preceding siblings ...)
2014-05-15 12:29 ` [PATCH v2 net-next 4/9] bonding: make USES_PRIMARY " Veaceslav Falico
@ 2014-05-15 12:29 ` Veaceslav Falico
2014-05-15 17:51 ` Jay Vosburgh
2014-05-15 12:29 ` [PATCH v2 net-next 6/9] bonding: make IS_IP_TARGET_UNUSABLE_ADDRESS an inline function Veaceslav Falico
` (3 subsequent siblings)
8 siblings, 1 reply; 16+ messages in thread
From: Veaceslav Falico @ 2014-05-15 12:29 UTC (permalink / raw)
To: netdev; +Cc: Veaceslav Falico, Jay Vosburgh, Andy Gospodarek
CC: Jay Vosburgh <j.vosburgh@gmail.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
---
drivers/net/bonding/bond_alb.c | 4 +-
drivers/net/bonding/bond_debugfs.c | 2 +-
drivers/net/bonding/bond_main.c | 94 +++++++++++++++++-----------------
drivers/net/bonding/bond_netlink.c | 6 +--
drivers/net/bonding/bond_options.c | 2 +-
drivers/net/bonding/bond_procfs.c | 14 ++---
drivers/net/bonding/bond_sysfs.c | 14 ++---
drivers/net/bonding/bond_sysfs_slave.c | 2 +-
drivers/net/bonding/bonding.h | 6 ++-
9 files changed, 73 insertions(+), 71 deletions(-)
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 70de039..efacb0e 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -1057,7 +1057,7 @@ static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[])
struct net_device *dev = slave->dev;
struct sockaddr s_addr;
- if (slave->bond->params.mode == BOND_MODE_TLB) {
+ if (BOND_MODE(slave->bond) == BOND_MODE_TLB) {
memcpy(dev->dev_addr, addr, dev->addr_len);
return 0;
}
@@ -1745,7 +1745,7 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave
/* in TLB mode, the slave might flip down/up with the old dev_addr,
* and thus filter bond->dev_addr's packets, so force bond's mac
*/
- if (bond->params.mode == BOND_MODE_TLB) {
+ if (BOND_MODE(bond) == BOND_MODE_TLB) {
struct sockaddr sa;
u8 tmp_addr[ETH_ALEN];
diff --git a/drivers/net/bonding/bond_debugfs.c b/drivers/net/bonding/bond_debugfs.c
index 2d3f7fa..658e761 100644
--- a/drivers/net/bonding/bond_debugfs.c
+++ b/drivers/net/bonding/bond_debugfs.c
@@ -23,7 +23,7 @@ static int bond_debug_rlb_hash_show(struct seq_file *m, void *v)
struct rlb_client_info *client_info;
u32 hash_index;
- if (bond->params.mode != BOND_MODE_ALB)
+ if (BOND_MODE(bond) != BOND_MODE_ALB)
return 0;
seq_printf(m, "SourceIP DestinationIP "
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 17b68b5..7b8e121 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -343,7 +343,7 @@ static int bond_set_carrier(struct bonding *bond)
if (!bond_has_slaves(bond))
goto down;
- if (bond->params.mode == BOND_MODE_8023AD)
+ if (BOND_MODE(bond) == BOND_MODE_8023AD)
return bond_3ad_set_carrier(bond);
bond_for_each_slave(bond, slave, iter) {
@@ -497,7 +497,7 @@ static int bond_set_promiscuity(struct bonding *bond, int inc)
struct list_head *iter;
int err = 0;
- if (bond_mode_uses_primary(bond->params.mode)) {
+ if (bond_mode_uses_primary(BOND_MODE(bond))) {
/* write lock already acquired */
if (bond->curr_active_slave) {
err = dev_set_promiscuity(bond->curr_active_slave->dev,
@@ -523,7 +523,7 @@ static int bond_set_allmulti(struct bonding *bond, int inc)
struct list_head *iter;
int err = 0;
- if (bond_mode_uses_primary(bond->params.mode)) {
+ if (bond_mode_uses_primary(BOND_MODE(bond))) {
/* write lock already acquired */
if (bond->curr_active_slave) {
err = dev_set_allmulti(bond->curr_active_slave->dev,
@@ -574,7 +574,7 @@ static void bond_hw_addr_flush(struct net_device *bond_dev,
dev_uc_unsync(slave_dev, bond_dev);
dev_mc_unsync(slave_dev, bond_dev);
- if (bond->params.mode == BOND_MODE_8023AD) {
+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
/* del lacpdu mc addr from mc list */
u8 lacpdu_multicast[ETH_ALEN] = MULTICAST_LACPDU_ADDR;
@@ -801,7 +801,7 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
new_active->last_link_up = jiffies;
if (new_active->link == BOND_LINK_BACK) {
- if (bond_mode_uses_primary(bond->params.mode)) {
+ if (bond_mode_uses_primary(BOND_MODE(bond))) {
pr_info("%s: making interface %s the new active one %d ms earlier\n",
bond->dev->name, new_active->dev->name,
(bond->params.updelay - new_active->delay) * bond->params.miimon);
@@ -810,20 +810,20 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
new_active->delay = 0;
new_active->link = BOND_LINK_UP;
- if (bond->params.mode == BOND_MODE_8023AD)
+ if (BOND_MODE(bond) == BOND_MODE_8023AD)
bond_3ad_handle_link_change(new_active, BOND_LINK_UP);
if (bond_is_lb(bond))
bond_alb_handle_link_change(bond, new_active, BOND_LINK_UP);
} else {
- if (bond_mode_uses_primary(bond->params.mode)) {
+ if (bond_mode_uses_primary(BOND_MODE(bond))) {
pr_info("%s: making interface %s the new active one\n",
bond->dev->name, new_active->dev->name);
}
}
}
- if (bond_mode_uses_primary(bond->params.mode))
+ if (bond_mode_uses_primary(BOND_MODE(bond)))
bond_hw_addr_swap(bond, new_active, old_active);
if (bond_is_lb(bond)) {
@@ -838,7 +838,7 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
rcu_assign_pointer(bond->curr_active_slave, new_active);
}
- if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) {
+ if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) {
if (old_active)
bond_set_slave_inactive_flags(old_active,
BOND_SLAVE_NOTIFY_NOW);
@@ -876,8 +876,8 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
* resend only if bond is brought up with the affected
* bonding modes and the retransmission is enabled */
if (netif_running(bond->dev) && (bond->params.resend_igmp > 0) &&
- ((bond_mode_uses_primary(bond->params.mode) && new_active) ||
- bond->params.mode == BOND_MODE_ROUNDROBIN)) {
+ ((bond_mode_uses_primary(BOND_MODE(bond)) && new_active) ||
+ BOND_MODE(bond) == BOND_MODE_ROUNDROBIN)) {
bond->igmp_retrans = bond->params.resend_igmp;
queue_delayed_work(bond->wq, &bond->mcast_work, 1);
}
@@ -1084,7 +1084,7 @@ static bool bond_should_deliver_exact_match(struct sk_buff *skb,
struct bonding *bond)
{
if (bond_is_slave_inactive(slave)) {
- if (bond->params.mode == BOND_MODE_ALB &&
+ if (BOND_MODE(bond) == BOND_MODE_ALB &&
skb->pkt_type != PACKET_BROADCAST &&
skb->pkt_type != PACKET_MULTICAST)
return false;
@@ -1126,7 +1126,7 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb)
skb->dev = bond->dev;
- if (bond->params.mode == BOND_MODE_ALB &&
+ if (BOND_MODE(bond) == BOND_MODE_ALB &&
bond->dev->priv_flags & IFF_BRIDGE_PORT &&
skb->pkt_type == PACKET_HOST) {
@@ -1171,7 +1171,7 @@ static struct slave *bond_alloc_slave(struct bonding *bond)
if (!slave)
return NULL;
- if (bond->params.mode == BOND_MODE_8023AD) {
+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
SLAVE_AD_INFO(slave) = kzalloc(sizeof(struct ad_slave_info),
GFP_KERNEL);
if (!SLAVE_AD_INFO(slave)) {
@@ -1186,7 +1186,7 @@ static void bond_free_slave(struct slave *slave)
{
struct bonding *bond = bond_get_bond_by_slave(slave);
- if (bond->params.mode == BOND_MODE_8023AD)
+ if (BOND_MODE(bond) == BOND_MODE_8023AD)
kfree(SLAVE_AD_INFO(slave));
kfree(slave);
@@ -1298,7 +1298,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
if (!bond_has_slaves(bond)) {
pr_warn("%s: Warning: The first slave device specified does not support setting the MAC address\n",
bond_dev->name);
- if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) {
+ if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) {
bond->params.fail_over_mac = BOND_FOM_ACTIVE;
pr_warn("%s: Setting fail_over_mac to active for active-backup mode\n",
bond_dev->name);
@@ -1347,7 +1347,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
ether_addr_copy(new_slave->perm_hwaddr, slave_dev->dev_addr);
if (!bond->params.fail_over_mac ||
- bond->params.mode != BOND_MODE_ACTIVEBACKUP) {
+ BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) {
/*
* Set slave to master's mac address. The application already
* set the master's mac address to that of the first slave
@@ -1384,7 +1384,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
/* If the mode uses primary, then the following is handled by
* bond_change_active_slave().
*/
- if (!bond_mode_uses_primary(bond->params.mode)) {
+ if (!bond_mode_uses_primary(BOND_MODE(bond))) {
/* set promiscuity level to new slave */
if (bond_dev->flags & IFF_PROMISC) {
res = dev_set_promiscuity(slave_dev, 1);
@@ -1407,7 +1407,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
netif_addr_unlock_bh(bond_dev);
}
- if (bond->params.mode == BOND_MODE_8023AD) {
+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
/* add lacpdu mc addr to mc list */
u8 lacpdu_multicast[ETH_ALEN] = MULTICAST_LACPDU_ADDR;
@@ -1480,7 +1480,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
new_slave->link == BOND_LINK_DOWN ? "DOWN" :
(new_slave->link == BOND_LINK_UP ? "UP" : "BACK"));
- if (bond_mode_uses_primary(bond->params.mode) && bond->params.primary[0]) {
+ if (bond_mode_uses_primary(BOND_MODE(bond)) && bond->params.primary[0]) {
/* if there is a primary slave, remember it */
if (strcmp(bond->params.primary, new_slave->dev->name) == 0) {
bond->primary_slave = new_slave;
@@ -1488,7 +1488,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
}
}
- switch (bond->params.mode) {
+ switch (BOND_MODE(bond)) {
case BOND_MODE_ACTIVEBACKUP:
bond_set_slave_inactive_flags(new_slave,
BOND_SLAVE_NOTIFY_NOW);
@@ -1569,7 +1569,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
bond_compute_features(bond);
bond_set_carrier(bond);
- if (bond_mode_uses_primary(bond->params.mode)) {
+ if (bond_mode_uses_primary(BOND_MODE(bond))) {
block_netpoll_tx();
write_lock_bh(&bond->curr_slave_lock);
bond_select_active_slave(bond);
@@ -1593,7 +1593,7 @@ err_unregister:
netdev_rx_handler_unregister(slave_dev);
err_detach:
- if (!bond_mode_uses_primary(bond->params.mode))
+ if (!bond_mode_uses_primary(BOND_MODE(bond)))
bond_hw_addr_flush(bond_dev, slave_dev);
vlan_vids_del_by_dev(slave_dev, bond_dev);
@@ -1615,7 +1615,7 @@ err_close:
err_restore_mac:
if (!bond->params.fail_over_mac ||
- bond->params.mode != BOND_MODE_ACTIVEBACKUP) {
+ BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) {
/* XXX TODO - fom follow mode needs to change master's
* MAC if this slave's MAC is in use by the bond, or at
* least print a warning.
@@ -1691,7 +1691,7 @@ static int __bond_release_one(struct net_device *bond_dev,
write_lock_bh(&bond->lock);
/* Inform AD package of unbinding of slave. */
- if (bond->params.mode == BOND_MODE_8023AD)
+ if (BOND_MODE(bond) == BOND_MODE_8023AD)
bond_3ad_unbind_slave(slave);
write_unlock_bh(&bond->lock);
@@ -1706,7 +1706,7 @@ static int __bond_release_one(struct net_device *bond_dev,
bond->current_arp_slave = NULL;
if (!all && (!bond->params.fail_over_mac ||
- bond->params.mode != BOND_MODE_ACTIVEBACKUP)) {
+ BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP)) {
if (ether_addr_equal_64bits(bond_dev->dev_addr, slave->perm_hwaddr) &&
bond_has_slaves(bond))
pr_warn("%s: Warning: the permanent HWaddr of %s - %pM - is still in use by %s - set the HWaddr of %s to a different address to avoid conflicts\n",
@@ -1781,7 +1781,7 @@ static int __bond_release_one(struct net_device *bond_dev,
/* If the mode uses primary, then this cases was handled above by
* bond_change_active_slave(..., NULL)
*/
- if (!bond_mode_uses_primary(bond->params.mode)) {
+ if (!bond_mode_uses_primary(BOND_MODE(bond))) {
/* unset promiscuity level from slave
* NOTE: The NETDEV_CHANGEADDR call above may change the value
* of the IFF_PROMISC flag in the bond_dev, but we need the
@@ -1805,7 +1805,7 @@ static int __bond_release_one(struct net_device *bond_dev,
dev_close(slave_dev);
if (bond->params.fail_over_mac != BOND_FOM_ACTIVE ||
- bond->params.mode != BOND_MODE_ACTIVEBACKUP) {
+ BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) {
/* restore original ("permanent") mac address */
ether_addr_copy(addr.sa_data, slave->perm_hwaddr);
addr.sa_family = slave_dev->type;
@@ -1851,7 +1851,7 @@ static int bond_info_query(struct net_device *bond_dev, struct ifbond *info)
{
struct bonding *bond = netdev_priv(bond_dev);
- info->bond_mode = bond->params.mode;
+ info->bond_mode = BOND_MODE(bond);
info->miimon = bond->params.miimon;
info->num_slaves = bond->slave_cnt;
@@ -1907,7 +1907,7 @@ static int bond_miimon_inspect(struct bonding *bond)
if (slave->delay) {
pr_info("%s: link status down for %sinterface %s, disabling it in %d ms\n",
bond->dev->name,
- (bond->params.mode ==
+ (BOND_MODE(bond) ==
BOND_MODE_ACTIVEBACKUP) ?
(bond_is_active_slave(slave) ?
"active " : "backup ") : "",
@@ -1998,10 +1998,10 @@ static void bond_miimon_commit(struct bonding *bond)
slave->link = BOND_LINK_UP;
slave->last_link_up = jiffies;
- if (bond->params.mode == BOND_MODE_8023AD) {
+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
/* prevent it from being the active one */
bond_set_backup_slave(slave);
- } else if (bond->params.mode != BOND_MODE_ACTIVEBACKUP) {
+ } else if (BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) {
/* make it immediately active */
bond_set_active_slave(slave);
} else if (slave != bond->primary_slave) {
@@ -2015,7 +2015,7 @@ static void bond_miimon_commit(struct bonding *bond)
slave->duplex ? "full" : "half");
/* notify ad that the link status has changed */
- if (bond->params.mode == BOND_MODE_8023AD)
+ if (BOND_MODE(bond) == BOND_MODE_8023AD)
bond_3ad_handle_link_change(slave, BOND_LINK_UP);
if (bond_is_lb(bond))
@@ -2034,15 +2034,15 @@ static void bond_miimon_commit(struct bonding *bond)
slave->link = BOND_LINK_DOWN;
- if (bond->params.mode == BOND_MODE_ACTIVEBACKUP ||
- bond->params.mode == BOND_MODE_8023AD)
+ if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP ||
+ BOND_MODE(bond) == BOND_MODE_8023AD)
bond_set_slave_inactive_flags(slave,
BOND_SLAVE_NOTIFY_NOW);
pr_info("%s: link status definitely down for interface %s, disabling it\n",
bond->dev->name, slave->dev->name);
- if (bond->params.mode == BOND_MODE_8023AD)
+ if (BOND_MODE(bond) == BOND_MODE_8023AD)
bond_3ad_handle_link_change(slave,
BOND_LINK_DOWN);
@@ -2887,7 +2887,7 @@ static int bond_slave_netdev_event(unsigned long event,
bond_update_speed_duplex(slave);
- if (bond->params.mode == BOND_MODE_8023AD) {
+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
if (old_speed != slave->speed)
bond_3ad_adapter_speed_changed(slave);
if (old_duplex != slave->duplex)
@@ -2915,7 +2915,7 @@ static int bond_slave_netdev_event(unsigned long event,
break;
case NETDEV_CHANGENAME:
/* we don't care if we don't have primary set */
- if (!bond_mode_uses_primary(bond->params.mode) ||
+ if (!bond_mode_uses_primary(BOND_MODE(bond)) ||
!bond->params.primary[0])
break;
@@ -3078,7 +3078,7 @@ static void bond_work_init_all(struct bonding *bond)
bond_resend_igmp_join_requests_delayed);
INIT_DELAYED_WORK(&bond->alb_work, bond_alb_monitor);
INIT_DELAYED_WORK(&bond->mii_work, bond_mii_monitor);
- if (bond->params.mode == BOND_MODE_ACTIVEBACKUP)
+ if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP)
INIT_DELAYED_WORK(&bond->arp_work, bond_activebackup_arp_mon);
else
INIT_DELAYED_WORK(&bond->arp_work, bond_loadbalance_arp_mon);
@@ -3105,7 +3105,7 @@ static int bond_open(struct net_device *bond_dev)
if (bond_has_slaves(bond)) {
read_lock(&bond->curr_slave_lock);
bond_for_each_slave(bond, slave, iter) {
- if (bond_mode_uses_primary(bond->params.mode)
+ if (bond_mode_uses_primary(BOND_MODE(bond))
&& (slave != bond->curr_active_slave)) {
bond_set_slave_inactive_flags(slave,
BOND_SLAVE_NOTIFY_NOW);
@@ -3124,7 +3124,7 @@ static int bond_open(struct net_device *bond_dev)
/* bond_alb_initialize must be called before the timer
* is started.
*/
- if (bond_alb_initialize(bond, (bond->params.mode == BOND_MODE_ALB)))
+ if (bond_alb_initialize(bond, (BOND_MODE(bond) == BOND_MODE_ALB)))
return -ENOMEM;
if (bond->params.tlb_dynamic_lb)
queue_delayed_work(bond->wq, &bond->alb_work, 0);
@@ -3138,7 +3138,7 @@ static int bond_open(struct net_device *bond_dev)
bond->recv_probe = bond_arp_rcv;
}
- if (bond->params.mode == BOND_MODE_8023AD) {
+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
queue_delayed_work(bond->wq, &bond->ad_work, 0);
/* register to receive LACPDUs */
bond->recv_probe = bond_3ad_lacpdu_recv;
@@ -3343,7 +3343,7 @@ static void bond_set_rx_mode(struct net_device *bond_dev)
rcu_read_lock();
- if (bond_mode_uses_primary(bond->params.mode)) {
+ if (bond_mode_uses_primary(BOND_MODE(bond))) {
slave = rcu_dereference(bond->curr_active_slave);
if (slave) {
dev_uc_sync(slave->dev, bond_dev);
@@ -3497,7 +3497,7 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr)
struct list_head *iter;
int res = 0;
- if (bond->params.mode == BOND_MODE_ALB)
+ if (BOND_MODE(bond) == BOND_MODE_ALB)
return bond_alb_set_mac_address(bond_dev, addr);
@@ -3508,7 +3508,7 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr)
* Returning an error causes ifenslave to fail.
*/
if (bond->params.fail_over_mac &&
- bond->params.mode == BOND_MODE_ACTIVEBACKUP)
+ BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP)
return 0;
if (!is_valid_ether_addr(sa->sa_data))
@@ -3792,7 +3792,7 @@ static netdev_tx_t __bond_start_xmit(struct sk_buff *skb, struct net_device *dev
!bond_slave_override(bond, skb))
return NETDEV_TX_OK;
- switch (bond->params.mode) {
+ switch (BOND_MODE(bond)) {
case BOND_MODE_ROUNDROBIN:
return bond_xmit_roundrobin(skb, dev);
case BOND_MODE_ACTIVEBACKUP:
@@ -3810,7 +3810,7 @@ static netdev_tx_t __bond_start_xmit(struct sk_buff *skb, struct net_device *dev
default:
/* Should never happen, mode already checked */
pr_err("%s: Error: Unknown bonding mode %d\n",
- dev->name, bond->params.mode);
+ dev->name, BOND_MODE(bond));
WARN_ON_ONCE(1);
dev_kfree_skb_any(skb);
return NETDEV_TX_OK;
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
index 0d06e75..5ab3c18 100644
--- a/drivers/net/bonding/bond_netlink.c
+++ b/drivers/net/bonding/bond_netlink.c
@@ -56,7 +56,7 @@ static int bond_fill_slave_info(struct sk_buff *skb,
if (nla_put_u16(skb, IFLA_BOND_SLAVE_QUEUE_ID, slave->queue_id))
goto nla_put_failure;
- if (slave->bond->params.mode == BOND_MODE_8023AD) {
+ if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) {
const struct aggregator *agg;
agg = SLAVE_AD_INFO(slave)->port.aggregator;
@@ -407,7 +407,7 @@ static int bond_fill_info(struct sk_buff *skb,
unsigned int packets_per_slave;
int i, targets_added;
- if (nla_put_u8(skb, IFLA_BOND_MODE, bond->params.mode))
+ if (nla_put_u8(skb, IFLA_BOND_MODE, BOND_MODE(bond)))
goto nla_put_failure;
if (slave_dev &&
@@ -505,7 +505,7 @@ static int bond_fill_info(struct sk_buff *skb,
bond->params.ad_select))
goto nla_put_failure;
- if (bond->params.mode == BOND_MODE_8023AD) {
+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
struct ad_info info;
if (!bond_3ad_get_active_agg_info(bond, &info)) {
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index afae661..ed11c6f 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -693,7 +693,7 @@ int bond_option_mode_set(struct bonding *bond, const struct bond_opt_value *newv
static struct net_device *__bond_option_active_slave_get(struct bonding *bond,
struct slave *slave)
{
- return bond_mode_uses_primary(bond->params.mode) && slave ? slave->dev : NULL;
+ return bond_mode_uses_primary(BOND_MODE(bond)) && slave ? slave->dev : NULL;
}
struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond)
diff --git a/drivers/net/bonding/bond_procfs.c b/drivers/net/bonding/bond_procfs.c
index 7cf55a5..dc1291f 100644
--- a/drivers/net/bonding/bond_procfs.c
+++ b/drivers/net/bonding/bond_procfs.c
@@ -72,9 +72,9 @@ static void bond_info_show_master(struct seq_file *seq)
curr = rcu_dereference(bond->curr_active_slave);
seq_printf(seq, "Bonding Mode: %s",
- bond_mode_name(bond->params.mode));
+ bond_mode_name(BOND_MODE(bond)));
- if (bond->params.mode == BOND_MODE_ACTIVEBACKUP &&
+ if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP &&
bond->params.fail_over_mac) {
optval = bond_opt_get_val(BOND_OPT_FAIL_OVER_MAC,
bond->params.fail_over_mac);
@@ -83,15 +83,15 @@ static void bond_info_show_master(struct seq_file *seq)
seq_printf(seq, "\n");
- if (bond->params.mode == BOND_MODE_XOR ||
- bond->params.mode == BOND_MODE_8023AD) {
+ if (BOND_MODE(bond) == BOND_MODE_XOR ||
+ BOND_MODE(bond) == BOND_MODE_8023AD) {
optval = bond_opt_get_val(BOND_OPT_XMIT_HASH,
bond->params.xmit_policy);
seq_printf(seq, "Transmit Hash Policy: %s (%d)\n",
optval->string, bond->params.xmit_policy);
}
- if (bond_mode_uses_primary(bond->params.mode)) {
+ if (bond_mode_uses_primary(BOND_MODE(bond))) {
seq_printf(seq, "Primary Slave: %s",
(bond->primary_slave) ?
bond->primary_slave->dev->name : "None");
@@ -134,7 +134,7 @@ static void bond_info_show_master(struct seq_file *seq)
seq_printf(seq, "\n");
}
- if (bond->params.mode == BOND_MODE_8023AD) {
+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
struct ad_info ad_info;
seq_puts(seq, "\n802.3ad info\n");
@@ -188,7 +188,7 @@ static void bond_info_show_slave(struct seq_file *seq,
seq_printf(seq, "Permanent HW addr: %pM\n", slave->perm_hwaddr);
- if (bond->params.mode == BOND_MODE_8023AD) {
+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
const struct aggregator *agg
= SLAVE_AD_INFO(slave)->port.aggregator;
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 39c4d8d..daed52f 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -214,9 +214,9 @@ static ssize_t bonding_show_mode(struct device *d,
struct bonding *bond = to_bond(d);
const struct bond_opt_value *val;
- val = bond_opt_get_val(BOND_OPT_MODE, bond->params.mode);
+ val = bond_opt_get_val(BOND_OPT_MODE, BOND_MODE(bond));
- return sprintf(buf, "%s %d\n", val->string, bond->params.mode);
+ return sprintf(buf, "%s %d\n", val->string, BOND_MODE(bond));
}
static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR,
bonding_show_mode, bonding_sysfs_store_option);
@@ -505,7 +505,7 @@ static ssize_t bonding_show_ad_aggregator(struct device *d,
int count = 0;
struct bonding *bond = to_bond(d);
- if (bond->params.mode == BOND_MODE_8023AD) {
+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
struct ad_info ad_info;
count = sprintf(buf, "%d\n",
bond_3ad_get_active_agg_info(bond, &ad_info)
@@ -525,7 +525,7 @@ static ssize_t bonding_show_ad_num_ports(struct device *d,
int count = 0;
struct bonding *bond = to_bond(d);
- if (bond->params.mode == BOND_MODE_8023AD) {
+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
struct ad_info ad_info;
count = sprintf(buf, "%d\n",
bond_3ad_get_active_agg_info(bond, &ad_info)
@@ -545,7 +545,7 @@ static ssize_t bonding_show_ad_actor_key(struct device *d,
int count = 0;
struct bonding *bond = to_bond(d);
- if (bond->params.mode == BOND_MODE_8023AD) {
+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
struct ad_info ad_info;
count = sprintf(buf, "%d\n",
bond_3ad_get_active_agg_info(bond, &ad_info)
@@ -565,7 +565,7 @@ static ssize_t bonding_show_ad_partner_key(struct device *d,
int count = 0;
struct bonding *bond = to_bond(d);
- if (bond->params.mode == BOND_MODE_8023AD) {
+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
struct ad_info ad_info;
count = sprintf(buf, "%d\n",
bond_3ad_get_active_agg_info(bond, &ad_info)
@@ -585,7 +585,7 @@ static ssize_t bonding_show_ad_partner_mac(struct device *d,
int count = 0;
struct bonding *bond = to_bond(d);
- if (bond->params.mode == BOND_MODE_8023AD) {
+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
struct ad_info ad_info;
if (!bond_3ad_get_active_agg_info(bond, &ad_info))
count = sprintf(buf, "%pM\n", ad_info.partner_system);
diff --git a/drivers/net/bonding/bond_sysfs_slave.c b/drivers/net/bonding/bond_sysfs_slave.c
index 89bc3b3..198677f 100644
--- a/drivers/net/bonding/bond_sysfs_slave.c
+++ b/drivers/net/bonding/bond_sysfs_slave.c
@@ -69,7 +69,7 @@ static ssize_t ad_aggregator_id_show(struct slave *slave, char *buf)
{
const struct aggregator *agg;
- if (slave->bond->params.mode == BOND_MODE_8023AD) {
+ if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) {
agg = SLAVE_AD_INFO(slave)->port.aggregator;
if (agg)
return sprintf(buf, "%d\n",
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 34a8ed5..4494fb9 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -70,6 +70,8 @@
set_fs(fs); \
res; })
+#define BOND_MODE(bond) ((bond)->params.mode)
+
/* slave list primitives */
#define bond_slave_list(bond) (&(bond)->dev->adj_list.lower)
@@ -277,8 +279,8 @@ static inline bool bond_should_override_tx_queue(struct bonding *bond)
static inline bool bond_is_lb(const struct bonding *bond)
{
- return bond->params.mode == BOND_MODE_TLB ||
- bond->params.mode == BOND_MODE_ALB;
+ return BOND_MODE(bond) == BOND_MODE_TLB ||
+ BOND_MODE(bond) == BOND_MODE_ALB;
}
static inline bool bond_mode_uses_arp(int mode)
--
1.8.4
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 net-next 6/9] bonding: make IS_IP_TARGET_UNUSABLE_ADDRESS an inline function
2014-05-15 12:29 [PATCH v2 net-next 0/9] bonding: simple macro cleanup Veaceslav Falico
` (4 preceding siblings ...)
2014-05-15 12:29 ` [PATCH v2 net-next 5/9] bonding: create a macro for bond mode and use it Veaceslav Falico
@ 2014-05-15 12:29 ` Veaceslav Falico
2014-05-15 12:29 ` [PATCH v2 net-next 7/9] bonding: convert IS_UP(slave->dev) to " Veaceslav Falico
` (2 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Veaceslav Falico @ 2014-05-15 12:29 UTC (permalink / raw)
To: netdev; +Cc: Veaceslav Falico, Jay Vosburgh, Andy Gospodarek
Also, use standard IP primitives to check the address.
CC: Jay Vosburgh <j.vosburgh@gmail.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
---
drivers/net/bonding/bond_main.c | 2 +-
drivers/net/bonding/bond_options.c | 4 ++--
drivers/net/bonding/bonding.h | 8 +++++---
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 7b8e121..42d9c92 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4195,7 +4195,7 @@ static int bond_check_params(struct bond_params *params)
catch mistakes */
__be32 ip;
if (!in4_pton(arp_ip_target[i], -1, (u8 *)&ip, -1, NULL) ||
- IS_IP_TARGET_UNUSABLE_ADDRESS(ip)) {
+ !bond_is_ip_target_ok(ip)) {
pr_warn("Warning: bad arp_ip_target module parameter (%s), ARP monitoring will not be performed\n",
arp_ip_target[i]);
arp_interval = 0;
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index ed11c6f..eb2683f 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -942,7 +942,7 @@ static int _bond_option_arp_ip_target_add(struct bonding *bond, __be32 target)
__be32 *targets = bond->params.arp_targets;
int ind;
- if (IS_IP_TARGET_UNUSABLE_ADDRESS(target)) {
+ if (!bond_is_ip_target_ok(target)) {
pr_err("%s: invalid ARP target %pI4 specified for addition\n",
bond->dev->name, &target);
return -EINVAL;
@@ -987,7 +987,7 @@ static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target)
unsigned long *targets_rx;
int ind, i;
- if (IS_IP_TARGET_UNUSABLE_ADDRESS(target)) {
+ if (!bond_is_ip_target_ok(target)) {
pr_err("%s: invalid ARP target %pI4 specified for removal\n",
bond->dev->name, &target);
return -EINVAL;
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 4494fb9..425e83c 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -54,9 +54,6 @@
((slave)->link == BOND_LINK_UP) && \
bond_is_active_slave(slave))
-#define IS_IP_TARGET_UNUSABLE_ADDRESS(a) \
- ((htonl(INADDR_BROADCAST) == a) || \
- ipv4_is_zeronet(a))
/*
* Less bad way to call ioctl from within the kernel; this needs to be
* done some other way to get the call out of interrupt context.
@@ -401,6 +398,11 @@ static inline int slave_do_arp_validate_only(struct bonding *bond)
return bond->params.arp_validate & BOND_ARP_FILTER;
}
+static inline int bond_is_ip_target_ok(__be32 addr)
+{
+ return !ipv4_is_lbcast(addr) && !ipv4_is_zeronet(addr);
+}
+
/* Get the oldest arp which we've received on this slave for bond's
* arp_targets.
*/
--
1.8.4
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 net-next 7/9] bonding: convert IS_UP(slave->dev) to inline function
2014-05-15 12:29 [PATCH v2 net-next 0/9] bonding: simple macro cleanup Veaceslav Falico
` (5 preceding siblings ...)
2014-05-15 12:29 ` [PATCH v2 net-next 6/9] bonding: make IS_IP_TARGET_UNUSABLE_ADDRESS an inline function Veaceslav Falico
@ 2014-05-15 12:29 ` Veaceslav Falico
2014-05-15 12:29 ` [PATCH v2 net-next 8/9] bonding: rename {,bond_}slave_can_tx and clean it up Veaceslav Falico
2014-05-15 12:29 ` [PATCH v2 net-next 9/9] bonding: replace SLAVE_IS_OK() with bond_slave_can_tx() Veaceslav Falico
8 siblings, 0 replies; 16+ messages in thread
From: Veaceslav Falico @ 2014-05-15 12:29 UTC (permalink / raw)
To: netdev; +Cc: Veaceslav Falico, Jay Vosburgh, Andy Gospodarek
Also, remove the IFF_UP verification cause we can't be netif_running() with
being also IFF_UP.
CC: Jay Vosburgh <j.vosburgh@gmail.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
---
drivers/net/bonding/bond_3ad.c | 2 +-
drivers/net/bonding/bond_main.c | 16 ++++++++--------
drivers/net/bonding/bond_options.c | 2 +-
drivers/net/bonding/bonding.h | 12 ++++++------
4 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index 24faddd..7997a1e 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -192,7 +192,7 @@ static inline void __enable_port(struct port *port)
{
struct slave *slave = port->slave;
- if ((slave->link == BOND_LINK_UP) && IS_UP(slave->dev))
+ if ((slave->link == BOND_LINK_UP) && bond_slave_is_up(slave))
bond_set_slave_active_flags(slave, BOND_SLAVE_NOTIFY_LATER);
}
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 42d9c92..5502ea6 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -747,7 +747,7 @@ static struct slave *bond_find_best_slave(struct bonding *bond)
bond_for_each_slave(bond, slave, iter) {
if (slave->link == BOND_LINK_UP)
return slave;
- if (slave->link == BOND_LINK_BACK && IS_UP(slave->dev) &&
+ if (slave->link == BOND_LINK_BACK && bond_slave_is_up(slave) &&
slave->delay < mintime) {
mintime = slave->delay;
bestslave = slave;
@@ -958,7 +958,7 @@ static void bond_netpoll_cleanup(struct net_device *bond_dev)
struct slave *slave;
bond_for_each_slave(bond, slave, iter)
- if (IS_UP(slave->dev))
+ if (bond_slave_is_up(slave))
slave_disable_netpoll(slave);
}
@@ -2490,7 +2490,7 @@ static void bond_loadbalance_arp_mon(struct work_struct *work)
* do - all replies will be rx'ed on same link causing slaves
* to be unstable during low/no traffic periods
*/
- if (IS_UP(slave->dev))
+ if (bond_slave_is_up(slave))
bond_arp_send_all(bond, slave);
}
@@ -2712,10 +2712,10 @@ static bool bond_ab_arp_probe(struct bonding *bond)
bond_set_slave_inactive_flags(curr_arp_slave, BOND_SLAVE_NOTIFY_LATER);
bond_for_each_slave_rcu(bond, slave, iter) {
- if (!found && !before && IS_UP(slave->dev))
+ if (!found && !before && bond_slave_is_up(slave))
before = slave;
- if (found && !new_slave && IS_UP(slave->dev))
+ if (found && !new_slave && bond_slave_is_up(slave))
new_slave = slave;
/* if the link state is up at this point, we
* mark it down - this can happen if we have
@@ -2724,7 +2724,7 @@ static bool bond_ab_arp_probe(struct bonding *bond)
* one the current slave so it is still marked
* up when it is actually down
*/
- if (!IS_UP(slave->dev) && slave->link == BOND_LINK_UP) {
+ if (!bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) {
slave->link = BOND_LINK_DOWN;
if (slave->link_failure_count < UINT_MAX)
slave->link_failure_count++;
@@ -3710,7 +3710,7 @@ static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev)
bond_for_each_slave_rcu(bond, slave, iter) {
if (bond_is_last_slave(bond, slave))
break;
- if (IS_UP(slave->dev) && slave->link == BOND_LINK_UP) {
+ if (bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) {
struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
if (!skb2) {
@@ -3722,7 +3722,7 @@ static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev)
bond_dev_queue_xmit(bond, skb2, slave->dev);
}
}
- if (slave && IS_UP(slave->dev) && slave->link == BOND_LINK_UP)
+ if (slave && bond_slave_is_up(slave) && slave->link == BOND_LINK_UP)
bond_dev_queue_xmit(bond, skb, slave->dev);
else
dev_kfree_skb_any(skb);
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index eb2683f..b5c42e3 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -758,7 +758,7 @@ static int bond_option_active_slave_set(struct bonding *bond,
bond->dev->name, new_active->dev->name);
} else {
if (old_active && (new_active->link == BOND_LINK_UP) &&
- IS_UP(new_active->dev)) {
+ bond_slave_is_up(new_active)) {
pr_info("%s: Setting %s as active slave\n",
bond->dev->name, new_active->dev->name);
bond_change_active_slave(bond, new_active);
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 425e83c..d1f45cd 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -40,11 +40,6 @@
#define BOND_DEFAULT_MIIMON 100
-#define IS_UP(dev) \
- ((((dev)->flags & IFF_UP) == IFF_UP) && \
- netif_running(dev) && \
- netif_carrier_ok(dev))
-
/*
* Checks whether slave is ready for transmit.
*/
@@ -292,6 +287,11 @@ static inline bool bond_mode_uses_primary(int mode)
mode == BOND_MODE_ALB;
}
+static inline bool bond_slave_is_up(struct slave *slave)
+{
+ return netif_running(slave->dev) && netif_carrier_ok(slave->dev);
+}
+
static inline void bond_set_active_slave(struct slave *slave)
{
if (slave->backup) {
@@ -482,7 +482,7 @@ static inline __be32 bond_confirm_addr(struct net_device *dev, __be32 dst, __be3
static inline bool slave_can_tx(struct slave *slave)
{
- if (IS_UP(slave->dev) && slave->link == BOND_LINK_UP &&
+ if (bond_slave_is_up(slave) && slave->link == BOND_LINK_UP &&
bond_is_active_slave(slave))
return true;
else
--
1.8.4
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 net-next 8/9] bonding: rename {,bond_}slave_can_tx and clean it up
2014-05-15 12:29 [PATCH v2 net-next 0/9] bonding: simple macro cleanup Veaceslav Falico
` (6 preceding siblings ...)
2014-05-15 12:29 ` [PATCH v2 net-next 7/9] bonding: convert IS_UP(slave->dev) to " Veaceslav Falico
@ 2014-05-15 12:29 ` Veaceslav Falico
2014-05-15 12:29 ` [PATCH v2 net-next 9/9] bonding: replace SLAVE_IS_OK() with bond_slave_can_tx() Veaceslav Falico
8 siblings, 0 replies; 16+ messages in thread
From: Veaceslav Falico @ 2014-05-15 12:29 UTC (permalink / raw)
To: netdev; +Cc: Veaceslav Falico, Jay Vosburgh, Andy Gospodarek
CC: Jay Vosburgh <j.vosburgh@gmail.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
---
drivers/net/bonding/bond_main.c | 8 ++++----
drivers/net/bonding/bonding.h | 15 ++++++---------
2 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 5502ea6..34cd5cc 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3588,7 +3588,7 @@ static void bond_xmit_slave_id(struct bonding *bond, struct sk_buff *skb, int sl
/* Here we start from the slave with slave_id */
bond_for_each_slave_rcu(bond, slave, iter) {
if (--i < 0) {
- if (slave_can_tx(slave)) {
+ if (bond_slave_can_tx(slave)) {
bond_dev_queue_xmit(bond, skb, slave->dev);
return;
}
@@ -3600,7 +3600,7 @@ static void bond_xmit_slave_id(struct bonding *bond, struct sk_buff *skb, int sl
bond_for_each_slave_rcu(bond, slave, iter) {
if (--i < 0)
break;
- if (slave_can_tx(slave)) {
+ if (bond_slave_can_tx(slave)) {
bond_dev_queue_xmit(bond, skb, slave->dev);
return;
}
@@ -3657,7 +3657,7 @@ static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev
*/
if (iph->protocol == IPPROTO_IGMP && skb->protocol == htons(ETH_P_IP)) {
slave = rcu_dereference(bond->curr_active_slave);
- if (slave && slave_can_tx(slave))
+ if (slave && bond_slave_can_tx(slave))
bond_dev_queue_xmit(bond, skb, slave->dev);
else
bond_xmit_slave_id(bond, skb, 0);
@@ -3747,7 +3747,7 @@ static inline int bond_slave_override(struct bonding *bond,
/* Find out if any slaves have the same mapping as this skb. */
bond_for_each_slave_rcu(bond, slave, iter) {
if (slave->queue_id == skb->queue_mapping) {
- if (slave_can_tx(slave)) {
+ if (bond_slave_can_tx(slave)) {
bond_dev_queue_xmit(bond, skb, slave->dev);
return 0;
}
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index d1f45cd..364395c 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -362,6 +362,12 @@ static inline bool bond_is_active_slave(struct slave *slave)
return !bond_slave_state(slave);
}
+static inline bool bond_slave_can_tx(struct slave *slave)
+{
+ return bond_slave_is_up(slave) && slave->link == BOND_LINK_UP &&
+ bond_is_active_slave(slave);
+}
+
#define BOND_PRI_RESELECT_ALWAYS 0
#define BOND_PRI_RESELECT_BETTER 1
#define BOND_PRI_RESELECT_FAILURE 2
@@ -480,15 +486,6 @@ static inline __be32 bond_confirm_addr(struct net_device *dev, __be32 dst, __be3
return addr;
}
-static inline bool slave_can_tx(struct slave *slave)
-{
- if (bond_slave_is_up(slave) && slave->link == BOND_LINK_UP &&
- bond_is_active_slave(slave))
- return true;
- else
- return false;
-}
-
struct bond_net {
struct net *net; /* Associated network namespace */
struct list_head dev_list;
--
1.8.4
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 net-next 9/9] bonding: replace SLAVE_IS_OK() with bond_slave_can_tx()
2014-05-15 12:29 [PATCH v2 net-next 0/9] bonding: simple macro cleanup Veaceslav Falico
` (7 preceding siblings ...)
2014-05-15 12:29 ` [PATCH v2 net-next 8/9] bonding: rename {,bond_}slave_can_tx and clean it up Veaceslav Falico
@ 2014-05-15 12:29 ` Veaceslav Falico
8 siblings, 0 replies; 16+ messages in thread
From: Veaceslav Falico @ 2014-05-15 12:29 UTC (permalink / raw)
To: netdev; +Cc: Veaceslav Falico, Jay Vosburgh, Andy Gospodarek
They're verifying the same thing (except of IFF_UP, which is implied for
netif_running(), which is also a prerequisite).
CC: Jay Vosburgh <j.vosburgh@gmail.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
---
drivers/net/bonding/bond_3ad.c | 4 ++--
drivers/net/bonding/bond_alb.c | 14 +++++++-------
drivers/net/bonding/bond_main.c | 4 ++--
drivers/net/bonding/bonding.h | 9 ---------
4 files changed, 11 insertions(+), 20 deletions(-)
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index 7997a1e..0dfeaf5 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -2449,13 +2449,13 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
continue;
if (slave_agg_no >= 0) {
- if (!first_ok_slave && SLAVE_IS_OK(slave))
+ if (!first_ok_slave && bond_slave_can_tx(slave))
first_ok_slave = slave;
slave_agg_no--;
continue;
}
- if (SLAVE_IS_OK(slave)) {
+ if (bond_slave_can_tx(slave)) {
bond_dev_queue_xmit(bond, skb, slave->dev);
goto out;
}
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index efacb0e..03e0bca 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -228,7 +228,7 @@ static struct slave *tlb_get_least_loaded_slave(struct bonding *bond)
/* Find the slave with the largest gap */
bond_for_each_slave_rcu(bond, slave, iter) {
- if (SLAVE_IS_OK(slave)) {
+ if (bond_slave_can_tx(slave)) {
long long gap = compute_gap(slave);
if (max_gap < gap) {
@@ -383,7 +383,7 @@ static struct slave *rlb_next_rx_slave(struct bonding *bond)
bool found = false;
bond_for_each_slave(bond, slave, iter) {
- if (!SLAVE_IS_OK(slave))
+ if (!bond_slave_can_tx(slave))
continue;
if (!found) {
if (!before || before->speed < slave->speed)
@@ -416,7 +416,7 @@ static struct slave *__rlb_next_rx_slave(struct bonding *bond)
bool found = false;
bond_for_each_slave_rcu(bond, slave, iter) {
- if (!SLAVE_IS_OK(slave))
+ if (!bond_slave_can_tx(slave))
continue;
if (!found) {
if (!before || before->speed < slave->speed)
@@ -1100,13 +1100,13 @@ static void alb_swap_mac_addr(struct slave *slave1, struct slave *slave2)
static void alb_fasten_mac_swap(struct bonding *bond, struct slave *slave1,
struct slave *slave2)
{
- int slaves_state_differ = (SLAVE_IS_OK(slave1) != SLAVE_IS_OK(slave2));
+ int slaves_state_differ = (bond_slave_can_tx(slave1) != bond_slave_can_tx(slave2));
struct slave *disabled_slave = NULL;
ASSERT_RTNL();
/* fasten the change in the switch */
- if (SLAVE_IS_OK(slave1)) {
+ if (bond_slave_can_tx(slave1)) {
alb_send_learning_packets(slave1, slave1->dev->dev_addr);
if (bond->alb_info.rlb_enabled) {
/* inform the clients that the mac address
@@ -1118,7 +1118,7 @@ static void alb_fasten_mac_swap(struct bonding *bond, struct slave *slave1,
disabled_slave = slave1;
}
- if (SLAVE_IS_OK(slave2)) {
+ if (bond_slave_can_tx(slave2)) {
alb_send_learning_packets(slave2, slave2->dev->dev_addr);
if (bond->alb_info.rlb_enabled) {
/* inform the clients that the mac address
@@ -1360,7 +1360,7 @@ static int bond_do_alb_xmit(struct sk_buff *skb, struct bonding *bond,
bond_info->unbalanced_load += skb->len;
}
- if (tx_slave && SLAVE_IS_OK(tx_slave)) {
+ if (tx_slave && bond_slave_can_tx(tx_slave)) {
if (tx_slave != rcu_dereference(bond->curr_active_slave)) {
ether_addr_copy(eth_data->h_source,
tx_slave->dev->dev_addr);
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 34cd5cc..2660529 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3850,14 +3850,14 @@ static int bond_ethtool_get_settings(struct net_device *bond_dev,
ecmd->duplex = DUPLEX_UNKNOWN;
ecmd->port = PORT_OTHER;
- /* Since SLAVE_IS_OK returns false for all inactive or down slaves, we
+ /* Since bond_slave_can_tx returns false for all inactive or down slaves, we
* do not need to check mode. Though link speed might not represent
* the true receive or transmit bandwidth (not all modes are symmetric)
* this is an accurate maximum.
*/
read_lock(&bond->lock);
bond_for_each_slave(bond, slave, iter) {
- if (SLAVE_IS_OK(slave)) {
+ if (bond_slave_can_tx(slave)) {
if (slave->speed != SPEED_UNKNOWN)
speed += slave->speed;
if (ecmd->duplex == DUPLEX_UNKNOWN &&
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 364395c..4e5c65f 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -41,15 +41,6 @@
#define BOND_DEFAULT_MIIMON 100
/*
- * Checks whether slave is ready for transmit.
- */
-#define SLAVE_IS_OK(slave) \
- (((slave)->dev->flags & IFF_UP) && \
- netif_running((slave)->dev) && \
- ((slave)->link == BOND_LINK_UP) && \
- bond_is_active_slave(slave))
-
-/*
* Less bad way to call ioctl from within the kernel; this needs to be
* done some other way to get the call out of interrupt context.
* Needs "ioctl" variable to be supplied by calling context.
--
1.8.4
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v2 net-next 3/9] bonding: make BOND_NO_USES_ARP an inline function
2014-05-15 12:29 ` [PATCH v2 net-next 3/9] bonding: make BOND_NO_USES_ARP " Veaceslav Falico
@ 2014-05-15 15:35 ` Alexei Starovoitov
2014-05-15 15:45 ` Veaceslav Falico
0 siblings, 1 reply; 16+ messages in thread
From: Alexei Starovoitov @ 2014-05-15 15:35 UTC (permalink / raw)
To: Veaceslav Falico; +Cc: netdev, Jay Vosburgh, Andy Gospodarek
On Thu, May 15, 2014 at 5:29 AM, Veaceslav Falico <vfalico@gmail.com> wrote:
> Also, change its name to better reflect its scope, and skip the "no"
> part.
>
> CC: Jay Vosburgh <j.vosburgh@gmail.com>
> CC: Andy Gospodarek <andy@greyhouse.net>
> Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
> ---
> drivers/net/bonding/bond_main.c | 2 +-
> drivers/net/bonding/bond_options.c | 2 +-
> drivers/net/bonding/bonding.h | 11 ++++++-----
> 3 files changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 5c88c11..2448e28 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -4113,7 +4113,7 @@ static int bond_check_params(struct bond_params *params)
> }
>
> /* reset values for 802.3ad/TLB/ALB */
> - if (BOND_NO_USES_ARP(bond_mode)) {
> + if (!bond_mode_uses_arp(bond_mode)) {
looks like condition becomes inverted.
Did you mean to add '!' inside bond_mode_uses_arp() as well?
> if (!miimon) {
> pr_warn("Warning: miimon must be specified, otherwise bonding will not detect link failure, speed and duplex which are essential for 802.3ad operation\n");
> pr_warn("Forcing miimon to 100msec\n");
> diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
> index 6dc49da..98c8801 100644
> --- a/drivers/net/bonding/bond_options.c
> +++ b/drivers/net/bonding/bond_options.c
> @@ -672,7 +672,7 @@ const struct bond_option *bond_opt_get(unsigned int option)
>
> int bond_option_mode_set(struct bonding *bond, const struct bond_opt_value *newval)
> {
> - if (BOND_NO_USES_ARP(newval->value) && bond->params.arp_interval) {
> + if (!bond_mode_uses_arp(newval->value) && bond->params.arp_interval) {
> pr_info("%s: %s mode is incompatible with arp monitoring, start mii monitoring\n",
> bond->dev->name, newval->string);
> /* disable arp monitoring */
> diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
> index dca3dfd..8f9f0df 100644
> --- a/drivers/net/bonding/bonding.h
> +++ b/drivers/net/bonding/bonding.h
> @@ -60,11 +60,6 @@
> ((mode) == BOND_MODE_TLB) || \
> ((mode) == BOND_MODE_ALB))
>
> -#define BOND_NO_USES_ARP(mode) \
> - (((mode) == BOND_MODE_8023AD) || \
> - ((mode) == BOND_MODE_TLB) || \
> - ((mode) == BOND_MODE_ALB))
> -
> #define IS_IP_TARGET_UNUSABLE_ADDRESS(a) \
> ((htonl(INADDR_BROADCAST) == a) || \
> ipv4_is_zeronet(a))
> @@ -292,6 +287,12 @@ static inline bool bond_is_lb(const struct bonding *bond)
> bond->params.mode == BOND_MODE_ALB;
> }
>
> +static inline bool bond_mode_uses_arp(int mode)
> +{
> + return mode == BOND_MODE_8023AD || mode == BOND_MODE_TLB ||
> + mode == BOND_MODE_ALB;
> +}
> +
> static inline void bond_set_active_slave(struct slave *slave)
> {
> if (slave->backup) {
> --
> 1.8.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 net-next 3/9] bonding: make BOND_NO_USES_ARP an inline function
2014-05-15 15:35 ` Alexei Starovoitov
@ 2014-05-15 15:45 ` Veaceslav Falico
0 siblings, 0 replies; 16+ messages in thread
From: Veaceslav Falico @ 2014-05-15 15:45 UTC (permalink / raw)
To: Alexei Starovoitov; +Cc: netdev, Jay Vosburgh, Andy Gospodarek
On Thu, May 15, 2014 at 08:35:47AM -0700, Alexei Starovoitov wrote:
>On Thu, May 15, 2014 at 5:29 AM, Veaceslav Falico <vfalico@gmail.com> wrote:
...snip...
>> - if (BOND_NO_USES_ARP(bond_mode)) {
>> + if (!bond_mode_uses_arp(bond_mode)) {
>
>looks like condition becomes inverted.
>Did you mean to add '!' inside bond_mode_uses_arp() as well?
Right, good catch. Easy to miss with this amount of mechanical work :(.
I'll wait for more feedback and resubmit v3.
Thanks!
>
...snip...
>> -#define BOND_NO_USES_ARP(mode) \
>> - (((mode) == BOND_MODE_8023AD) || \
>> - ((mode) == BOND_MODE_TLB) || \
>> - ((mode) == BOND_MODE_ALB))
>> -
...snip...
>> +static inline bool bond_mode_uses_arp(int mode)
>> +{
>> + return mode == BOND_MODE_8023AD || mode == BOND_MODE_TLB ||
>> + mode == BOND_MODE_ALB;
>> +}
>> +
...snip...
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 net-next 5/9] bonding: create a macro for bond mode and use it
2014-05-15 12:29 ` [PATCH v2 net-next 5/9] bonding: create a macro for bond mode and use it Veaceslav Falico
@ 2014-05-15 17:51 ` Jay Vosburgh
2014-05-15 18:14 ` Veaceslav Falico
0 siblings, 1 reply; 16+ messages in thread
From: Jay Vosburgh @ 2014-05-15 17:51 UTC (permalink / raw)
To: Veaceslav Falico; +Cc: netdev, Andy Gospodarek
Veaceslav Falico <vfalico@gmail.com> wrote:
>CC: Jay Vosburgh <j.vosburgh@gmail.com>
>CC: Andy Gospodarek <andy@greyhouse.net>
>Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
>---
> drivers/net/bonding/bond_alb.c | 4 +-
> drivers/net/bonding/bond_debugfs.c | 2 +-
> drivers/net/bonding/bond_main.c | 94 +++++++++++++++++-----------------
> drivers/net/bonding/bond_netlink.c | 6 +--
> drivers/net/bonding/bond_options.c | 2 +-
> drivers/net/bonding/bond_procfs.c | 14 ++---
> drivers/net/bonding/bond_sysfs.c | 14 ++---
> drivers/net/bonding/bond_sysfs_slave.c | 2 +-
> drivers/net/bonding/bonding.h | 6 ++-
> 9 files changed, 73 insertions(+), 71 deletions(-)
>
>diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
>index 70de039..efacb0e 100644
>--- a/drivers/net/bonding/bond_alb.c
>+++ b/drivers/net/bonding/bond_alb.c
>@@ -1057,7 +1057,7 @@ static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[])
> struct net_device *dev = slave->dev;
> struct sockaddr s_addr;
>
>- if (slave->bond->params.mode == BOND_MODE_TLB) {
>+ if (BOND_MODE(slave->bond) == BOND_MODE_TLB) {
> memcpy(dev->dev_addr, addr, dev->addr_len);
> return 0;
> }
>@@ -1745,7 +1745,7 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave
> /* in TLB mode, the slave might flip down/up with the old dev_addr,
> * and thus filter bond->dev_addr's packets, so force bond's mac
> */
>- if (bond->params.mode == BOND_MODE_TLB) {
>+ if (BOND_MODE(bond) == BOND_MODE_TLB) {
> struct sockaddr sa;
> u8 tmp_addr[ETH_ALEN];
>
>diff --git a/drivers/net/bonding/bond_debugfs.c b/drivers/net/bonding/bond_debugfs.c
>index 2d3f7fa..658e761 100644
>--- a/drivers/net/bonding/bond_debugfs.c
>+++ b/drivers/net/bonding/bond_debugfs.c
>@@ -23,7 +23,7 @@ static int bond_debug_rlb_hash_show(struct seq_file *m, void *v)
> struct rlb_client_info *client_info;
> u32 hash_index;
>
>- if (bond->params.mode != BOND_MODE_ALB)
>+ if (BOND_MODE(bond) != BOND_MODE_ALB)
> return 0;
>
> seq_printf(m, "SourceIP DestinationIP "
>diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>index 17b68b5..7b8e121 100644
>--- a/drivers/net/bonding/bond_main.c
>+++ b/drivers/net/bonding/bond_main.c
>@@ -343,7 +343,7 @@ static int bond_set_carrier(struct bonding *bond)
> if (!bond_has_slaves(bond))
> goto down;
>
>- if (bond->params.mode == BOND_MODE_8023AD)
>+ if (BOND_MODE(bond) == BOND_MODE_8023AD)
> return bond_3ad_set_carrier(bond);
>
> bond_for_each_slave(bond, slave, iter) {
>@@ -497,7 +497,7 @@ static int bond_set_promiscuity(struct bonding *bond, int inc)
> struct list_head *iter;
> int err = 0;
>
>- if (bond_mode_uses_primary(bond->params.mode)) {
>+ if (bond_mode_uses_primary(BOND_MODE(bond))) {
Would it be better to use "bond_uses_primary(struct bonding *)"
instead of the above? That would simplify the above calling pattern,
and shorten the calls elsewhere. Maybe I missed one, but it looks like
all of the calls to _uses_primary have BOND_MODE(bond) as the argument.
-J
> /* write lock already acquired */
> if (bond->curr_active_slave) {
> err = dev_set_promiscuity(bond->curr_active_slave->dev,
>@@ -523,7 +523,7 @@ static int bond_set_allmulti(struct bonding *bond, int inc)
> struct list_head *iter;
> int err = 0;
>
>- if (bond_mode_uses_primary(bond->params.mode)) {
>+ if (bond_mode_uses_primary(BOND_MODE(bond))) {
> /* write lock already acquired */
> if (bond->curr_active_slave) {
> err = dev_set_allmulti(bond->curr_active_slave->dev,
>@@ -574,7 +574,7 @@ static void bond_hw_addr_flush(struct net_device *bond_dev,
> dev_uc_unsync(slave_dev, bond_dev);
> dev_mc_unsync(slave_dev, bond_dev);
>
>- if (bond->params.mode == BOND_MODE_8023AD) {
>+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
> /* del lacpdu mc addr from mc list */
> u8 lacpdu_multicast[ETH_ALEN] = MULTICAST_LACPDU_ADDR;
>
>@@ -801,7 +801,7 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
> new_active->last_link_up = jiffies;
>
> if (new_active->link == BOND_LINK_BACK) {
>- if (bond_mode_uses_primary(bond->params.mode)) {
>+ if (bond_mode_uses_primary(BOND_MODE(bond))) {
> pr_info("%s: making interface %s the new active one %d ms earlier\n",
> bond->dev->name, new_active->dev->name,
> (bond->params.updelay - new_active->delay) * bond->params.miimon);
>@@ -810,20 +810,20 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
> new_active->delay = 0;
> new_active->link = BOND_LINK_UP;
>
>- if (bond->params.mode == BOND_MODE_8023AD)
>+ if (BOND_MODE(bond) == BOND_MODE_8023AD)
> bond_3ad_handle_link_change(new_active, BOND_LINK_UP);
>
> if (bond_is_lb(bond))
> bond_alb_handle_link_change(bond, new_active, BOND_LINK_UP);
> } else {
>- if (bond_mode_uses_primary(bond->params.mode)) {
>+ if (bond_mode_uses_primary(BOND_MODE(bond))) {
> pr_info("%s: making interface %s the new active one\n",
> bond->dev->name, new_active->dev->name);
> }
> }
> }
>
>- if (bond_mode_uses_primary(bond->params.mode))
>+ if (bond_mode_uses_primary(BOND_MODE(bond)))
> bond_hw_addr_swap(bond, new_active, old_active);
>
> if (bond_is_lb(bond)) {
>@@ -838,7 +838,7 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
> rcu_assign_pointer(bond->curr_active_slave, new_active);
> }
>
>- if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) {
>+ if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) {
> if (old_active)
> bond_set_slave_inactive_flags(old_active,
> BOND_SLAVE_NOTIFY_NOW);
>@@ -876,8 +876,8 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
> * resend only if bond is brought up with the affected
> * bonding modes and the retransmission is enabled */
> if (netif_running(bond->dev) && (bond->params.resend_igmp > 0) &&
>- ((bond_mode_uses_primary(bond->params.mode) && new_active) ||
>- bond->params.mode == BOND_MODE_ROUNDROBIN)) {
>+ ((bond_mode_uses_primary(BOND_MODE(bond)) && new_active) ||
>+ BOND_MODE(bond) == BOND_MODE_ROUNDROBIN)) {
> bond->igmp_retrans = bond->params.resend_igmp;
> queue_delayed_work(bond->wq, &bond->mcast_work, 1);
> }
>@@ -1084,7 +1084,7 @@ static bool bond_should_deliver_exact_match(struct sk_buff *skb,
> struct bonding *bond)
> {
> if (bond_is_slave_inactive(slave)) {
>- if (bond->params.mode == BOND_MODE_ALB &&
>+ if (BOND_MODE(bond) == BOND_MODE_ALB &&
> skb->pkt_type != PACKET_BROADCAST &&
> skb->pkt_type != PACKET_MULTICAST)
> return false;
>@@ -1126,7 +1126,7 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb)
>
> skb->dev = bond->dev;
>
>- if (bond->params.mode == BOND_MODE_ALB &&
>+ if (BOND_MODE(bond) == BOND_MODE_ALB &&
> bond->dev->priv_flags & IFF_BRIDGE_PORT &&
> skb->pkt_type == PACKET_HOST) {
>
>@@ -1171,7 +1171,7 @@ static struct slave *bond_alloc_slave(struct bonding *bond)
> if (!slave)
> return NULL;
>
>- if (bond->params.mode == BOND_MODE_8023AD) {
>+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
> SLAVE_AD_INFO(slave) = kzalloc(sizeof(struct ad_slave_info),
> GFP_KERNEL);
> if (!SLAVE_AD_INFO(slave)) {
>@@ -1186,7 +1186,7 @@ static void bond_free_slave(struct slave *slave)
> {
> struct bonding *bond = bond_get_bond_by_slave(slave);
>
>- if (bond->params.mode == BOND_MODE_8023AD)
>+ if (BOND_MODE(bond) == BOND_MODE_8023AD)
> kfree(SLAVE_AD_INFO(slave));
>
> kfree(slave);
>@@ -1298,7 +1298,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
> if (!bond_has_slaves(bond)) {
> pr_warn("%s: Warning: The first slave device specified does not support setting the MAC address\n",
> bond_dev->name);
>- if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) {
>+ if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) {
> bond->params.fail_over_mac = BOND_FOM_ACTIVE;
> pr_warn("%s: Setting fail_over_mac to active for active-backup mode\n",
> bond_dev->name);
>@@ -1347,7 +1347,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
> ether_addr_copy(new_slave->perm_hwaddr, slave_dev->dev_addr);
>
> if (!bond->params.fail_over_mac ||
>- bond->params.mode != BOND_MODE_ACTIVEBACKUP) {
>+ BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) {
> /*
> * Set slave to master's mac address. The application already
> * set the master's mac address to that of the first slave
>@@ -1384,7 +1384,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
> /* If the mode uses primary, then the following is handled by
> * bond_change_active_slave().
> */
>- if (!bond_mode_uses_primary(bond->params.mode)) {
>+ if (!bond_mode_uses_primary(BOND_MODE(bond))) {
> /* set promiscuity level to new slave */
> if (bond_dev->flags & IFF_PROMISC) {
> res = dev_set_promiscuity(slave_dev, 1);
>@@ -1407,7 +1407,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
> netif_addr_unlock_bh(bond_dev);
> }
>
>- if (bond->params.mode == BOND_MODE_8023AD) {
>+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
> /* add lacpdu mc addr to mc list */
> u8 lacpdu_multicast[ETH_ALEN] = MULTICAST_LACPDU_ADDR;
>
>@@ -1480,7 +1480,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
> new_slave->link == BOND_LINK_DOWN ? "DOWN" :
> (new_slave->link == BOND_LINK_UP ? "UP" : "BACK"));
>
>- if (bond_mode_uses_primary(bond->params.mode) && bond->params.primary[0]) {
>+ if (bond_mode_uses_primary(BOND_MODE(bond)) && bond->params.primary[0]) {
> /* if there is a primary slave, remember it */
> if (strcmp(bond->params.primary, new_slave->dev->name) == 0) {
> bond->primary_slave = new_slave;
>@@ -1488,7 +1488,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
> }
> }
>
>- switch (bond->params.mode) {
>+ switch (BOND_MODE(bond)) {
> case BOND_MODE_ACTIVEBACKUP:
> bond_set_slave_inactive_flags(new_slave,
> BOND_SLAVE_NOTIFY_NOW);
>@@ -1569,7 +1569,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
> bond_compute_features(bond);
> bond_set_carrier(bond);
>
>- if (bond_mode_uses_primary(bond->params.mode)) {
>+ if (bond_mode_uses_primary(BOND_MODE(bond))) {
> block_netpoll_tx();
> write_lock_bh(&bond->curr_slave_lock);
> bond_select_active_slave(bond);
>@@ -1593,7 +1593,7 @@ err_unregister:
> netdev_rx_handler_unregister(slave_dev);
>
> err_detach:
>- if (!bond_mode_uses_primary(bond->params.mode))
>+ if (!bond_mode_uses_primary(BOND_MODE(bond)))
> bond_hw_addr_flush(bond_dev, slave_dev);
>
> vlan_vids_del_by_dev(slave_dev, bond_dev);
>@@ -1615,7 +1615,7 @@ err_close:
>
> err_restore_mac:
> if (!bond->params.fail_over_mac ||
>- bond->params.mode != BOND_MODE_ACTIVEBACKUP) {
>+ BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) {
> /* XXX TODO - fom follow mode needs to change master's
> * MAC if this slave's MAC is in use by the bond, or at
> * least print a warning.
>@@ -1691,7 +1691,7 @@ static int __bond_release_one(struct net_device *bond_dev,
> write_lock_bh(&bond->lock);
>
> /* Inform AD package of unbinding of slave. */
>- if (bond->params.mode == BOND_MODE_8023AD)
>+ if (BOND_MODE(bond) == BOND_MODE_8023AD)
> bond_3ad_unbind_slave(slave);
>
> write_unlock_bh(&bond->lock);
>@@ -1706,7 +1706,7 @@ static int __bond_release_one(struct net_device *bond_dev,
> bond->current_arp_slave = NULL;
>
> if (!all && (!bond->params.fail_over_mac ||
>- bond->params.mode != BOND_MODE_ACTIVEBACKUP)) {
>+ BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP)) {
> if (ether_addr_equal_64bits(bond_dev->dev_addr, slave->perm_hwaddr) &&
> bond_has_slaves(bond))
> pr_warn("%s: Warning: the permanent HWaddr of %s - %pM - is still in use by %s - set the HWaddr of %s to a different address to avoid conflicts\n",
>@@ -1781,7 +1781,7 @@ static int __bond_release_one(struct net_device *bond_dev,
> /* If the mode uses primary, then this cases was handled above by
> * bond_change_active_slave(..., NULL)
> */
>- if (!bond_mode_uses_primary(bond->params.mode)) {
>+ if (!bond_mode_uses_primary(BOND_MODE(bond))) {
> /* unset promiscuity level from slave
> * NOTE: The NETDEV_CHANGEADDR call above may change the value
> * of the IFF_PROMISC flag in the bond_dev, but we need the
>@@ -1805,7 +1805,7 @@ static int __bond_release_one(struct net_device *bond_dev,
> dev_close(slave_dev);
>
> if (bond->params.fail_over_mac != BOND_FOM_ACTIVE ||
>- bond->params.mode != BOND_MODE_ACTIVEBACKUP) {
>+ BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) {
> /* restore original ("permanent") mac address */
> ether_addr_copy(addr.sa_data, slave->perm_hwaddr);
> addr.sa_family = slave_dev->type;
>@@ -1851,7 +1851,7 @@ static int bond_info_query(struct net_device *bond_dev, struct ifbond *info)
> {
> struct bonding *bond = netdev_priv(bond_dev);
>
>- info->bond_mode = bond->params.mode;
>+ info->bond_mode = BOND_MODE(bond);
> info->miimon = bond->params.miimon;
>
> info->num_slaves = bond->slave_cnt;
>@@ -1907,7 +1907,7 @@ static int bond_miimon_inspect(struct bonding *bond)
> if (slave->delay) {
> pr_info("%s: link status down for %sinterface %s, disabling it in %d ms\n",
> bond->dev->name,
>- (bond->params.mode ==
>+ (BOND_MODE(bond) ==
> BOND_MODE_ACTIVEBACKUP) ?
> (bond_is_active_slave(slave) ?
> "active " : "backup ") : "",
>@@ -1998,10 +1998,10 @@ static void bond_miimon_commit(struct bonding *bond)
> slave->link = BOND_LINK_UP;
> slave->last_link_up = jiffies;
>
>- if (bond->params.mode == BOND_MODE_8023AD) {
>+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
> /* prevent it from being the active one */
> bond_set_backup_slave(slave);
>- } else if (bond->params.mode != BOND_MODE_ACTIVEBACKUP) {
>+ } else if (BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) {
> /* make it immediately active */
> bond_set_active_slave(slave);
> } else if (slave != bond->primary_slave) {
>@@ -2015,7 +2015,7 @@ static void bond_miimon_commit(struct bonding *bond)
> slave->duplex ? "full" : "half");
>
> /* notify ad that the link status has changed */
>- if (bond->params.mode == BOND_MODE_8023AD)
>+ if (BOND_MODE(bond) == BOND_MODE_8023AD)
> bond_3ad_handle_link_change(slave, BOND_LINK_UP);
>
> if (bond_is_lb(bond))
>@@ -2034,15 +2034,15 @@ static void bond_miimon_commit(struct bonding *bond)
>
> slave->link = BOND_LINK_DOWN;
>
>- if (bond->params.mode == BOND_MODE_ACTIVEBACKUP ||
>- bond->params.mode == BOND_MODE_8023AD)
>+ if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP ||
>+ BOND_MODE(bond) == BOND_MODE_8023AD)
> bond_set_slave_inactive_flags(slave,
> BOND_SLAVE_NOTIFY_NOW);
>
> pr_info("%s: link status definitely down for interface %s, disabling it\n",
> bond->dev->name, slave->dev->name);
>
>- if (bond->params.mode == BOND_MODE_8023AD)
>+ if (BOND_MODE(bond) == BOND_MODE_8023AD)
> bond_3ad_handle_link_change(slave,
> BOND_LINK_DOWN);
>
>@@ -2887,7 +2887,7 @@ static int bond_slave_netdev_event(unsigned long event,
>
> bond_update_speed_duplex(slave);
>
>- if (bond->params.mode == BOND_MODE_8023AD) {
>+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
> if (old_speed != slave->speed)
> bond_3ad_adapter_speed_changed(slave);
> if (old_duplex != slave->duplex)
>@@ -2915,7 +2915,7 @@ static int bond_slave_netdev_event(unsigned long event,
> break;
> case NETDEV_CHANGENAME:
> /* we don't care if we don't have primary set */
>- if (!bond_mode_uses_primary(bond->params.mode) ||
>+ if (!bond_mode_uses_primary(BOND_MODE(bond)) ||
> !bond->params.primary[0])
> break;
>
>@@ -3078,7 +3078,7 @@ static void bond_work_init_all(struct bonding *bond)
> bond_resend_igmp_join_requests_delayed);
> INIT_DELAYED_WORK(&bond->alb_work, bond_alb_monitor);
> INIT_DELAYED_WORK(&bond->mii_work, bond_mii_monitor);
>- if (bond->params.mode == BOND_MODE_ACTIVEBACKUP)
>+ if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP)
> INIT_DELAYED_WORK(&bond->arp_work, bond_activebackup_arp_mon);
> else
> INIT_DELAYED_WORK(&bond->arp_work, bond_loadbalance_arp_mon);
>@@ -3105,7 +3105,7 @@ static int bond_open(struct net_device *bond_dev)
> if (bond_has_slaves(bond)) {
> read_lock(&bond->curr_slave_lock);
> bond_for_each_slave(bond, slave, iter) {
>- if (bond_mode_uses_primary(bond->params.mode)
>+ if (bond_mode_uses_primary(BOND_MODE(bond))
> && (slave != bond->curr_active_slave)) {
> bond_set_slave_inactive_flags(slave,
> BOND_SLAVE_NOTIFY_NOW);
>@@ -3124,7 +3124,7 @@ static int bond_open(struct net_device *bond_dev)
> /* bond_alb_initialize must be called before the timer
> * is started.
> */
>- if (bond_alb_initialize(bond, (bond->params.mode == BOND_MODE_ALB)))
>+ if (bond_alb_initialize(bond, (BOND_MODE(bond) == BOND_MODE_ALB)))
> return -ENOMEM;
> if (bond->params.tlb_dynamic_lb)
> queue_delayed_work(bond->wq, &bond->alb_work, 0);
>@@ -3138,7 +3138,7 @@ static int bond_open(struct net_device *bond_dev)
> bond->recv_probe = bond_arp_rcv;
> }
>
>- if (bond->params.mode == BOND_MODE_8023AD) {
>+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
> queue_delayed_work(bond->wq, &bond->ad_work, 0);
> /* register to receive LACPDUs */
> bond->recv_probe = bond_3ad_lacpdu_recv;
>@@ -3343,7 +3343,7 @@ static void bond_set_rx_mode(struct net_device *bond_dev)
>
>
> rcu_read_lock();
>- if (bond_mode_uses_primary(bond->params.mode)) {
>+ if (bond_mode_uses_primary(BOND_MODE(bond))) {
> slave = rcu_dereference(bond->curr_active_slave);
> if (slave) {
> dev_uc_sync(slave->dev, bond_dev);
>@@ -3497,7 +3497,7 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr)
> struct list_head *iter;
> int res = 0;
>
>- if (bond->params.mode == BOND_MODE_ALB)
>+ if (BOND_MODE(bond) == BOND_MODE_ALB)
> return bond_alb_set_mac_address(bond_dev, addr);
>
>
>@@ -3508,7 +3508,7 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr)
> * Returning an error causes ifenslave to fail.
> */
> if (bond->params.fail_over_mac &&
>- bond->params.mode == BOND_MODE_ACTIVEBACKUP)
>+ BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP)
> return 0;
>
> if (!is_valid_ether_addr(sa->sa_data))
>@@ -3792,7 +3792,7 @@ static netdev_tx_t __bond_start_xmit(struct sk_buff *skb, struct net_device *dev
> !bond_slave_override(bond, skb))
> return NETDEV_TX_OK;
>
>- switch (bond->params.mode) {
>+ switch (BOND_MODE(bond)) {
> case BOND_MODE_ROUNDROBIN:
> return bond_xmit_roundrobin(skb, dev);
> case BOND_MODE_ACTIVEBACKUP:
>@@ -3810,7 +3810,7 @@ static netdev_tx_t __bond_start_xmit(struct sk_buff *skb, struct net_device *dev
> default:
> /* Should never happen, mode already checked */
> pr_err("%s: Error: Unknown bonding mode %d\n",
>- dev->name, bond->params.mode);
>+ dev->name, BOND_MODE(bond));
> WARN_ON_ONCE(1);
> dev_kfree_skb_any(skb);
> return NETDEV_TX_OK;
>diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
>index 0d06e75..5ab3c18 100644
>--- a/drivers/net/bonding/bond_netlink.c
>+++ b/drivers/net/bonding/bond_netlink.c
>@@ -56,7 +56,7 @@ static int bond_fill_slave_info(struct sk_buff *skb,
> if (nla_put_u16(skb, IFLA_BOND_SLAVE_QUEUE_ID, slave->queue_id))
> goto nla_put_failure;
>
>- if (slave->bond->params.mode == BOND_MODE_8023AD) {
>+ if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) {
> const struct aggregator *agg;
>
> agg = SLAVE_AD_INFO(slave)->port.aggregator;
>@@ -407,7 +407,7 @@ static int bond_fill_info(struct sk_buff *skb,
> unsigned int packets_per_slave;
> int i, targets_added;
>
>- if (nla_put_u8(skb, IFLA_BOND_MODE, bond->params.mode))
>+ if (nla_put_u8(skb, IFLA_BOND_MODE, BOND_MODE(bond)))
> goto nla_put_failure;
>
> if (slave_dev &&
>@@ -505,7 +505,7 @@ static int bond_fill_info(struct sk_buff *skb,
> bond->params.ad_select))
> goto nla_put_failure;
>
>- if (bond->params.mode == BOND_MODE_8023AD) {
>+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
> struct ad_info info;
>
> if (!bond_3ad_get_active_agg_info(bond, &info)) {
>diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
>index afae661..ed11c6f 100644
>--- a/drivers/net/bonding/bond_options.c
>+++ b/drivers/net/bonding/bond_options.c
>@@ -693,7 +693,7 @@ int bond_option_mode_set(struct bonding *bond, const struct bond_opt_value *newv
> static struct net_device *__bond_option_active_slave_get(struct bonding *bond,
> struct slave *slave)
> {
>- return bond_mode_uses_primary(bond->params.mode) && slave ? slave->dev : NULL;
>+ return bond_mode_uses_primary(BOND_MODE(bond)) && slave ? slave->dev : NULL;
> }
>
> struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond)
>diff --git a/drivers/net/bonding/bond_procfs.c b/drivers/net/bonding/bond_procfs.c
>index 7cf55a5..dc1291f 100644
>--- a/drivers/net/bonding/bond_procfs.c
>+++ b/drivers/net/bonding/bond_procfs.c
>@@ -72,9 +72,9 @@ static void bond_info_show_master(struct seq_file *seq)
> curr = rcu_dereference(bond->curr_active_slave);
>
> seq_printf(seq, "Bonding Mode: %s",
>- bond_mode_name(bond->params.mode));
>+ bond_mode_name(BOND_MODE(bond)));
>
>- if (bond->params.mode == BOND_MODE_ACTIVEBACKUP &&
>+ if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP &&
> bond->params.fail_over_mac) {
> optval = bond_opt_get_val(BOND_OPT_FAIL_OVER_MAC,
> bond->params.fail_over_mac);
>@@ -83,15 +83,15 @@ static void bond_info_show_master(struct seq_file *seq)
>
> seq_printf(seq, "\n");
>
>- if (bond->params.mode == BOND_MODE_XOR ||
>- bond->params.mode == BOND_MODE_8023AD) {
>+ if (BOND_MODE(bond) == BOND_MODE_XOR ||
>+ BOND_MODE(bond) == BOND_MODE_8023AD) {
> optval = bond_opt_get_val(BOND_OPT_XMIT_HASH,
> bond->params.xmit_policy);
> seq_printf(seq, "Transmit Hash Policy: %s (%d)\n",
> optval->string, bond->params.xmit_policy);
> }
>
>- if (bond_mode_uses_primary(bond->params.mode)) {
>+ if (bond_mode_uses_primary(BOND_MODE(bond))) {
> seq_printf(seq, "Primary Slave: %s",
> (bond->primary_slave) ?
> bond->primary_slave->dev->name : "None");
>@@ -134,7 +134,7 @@ static void bond_info_show_master(struct seq_file *seq)
> seq_printf(seq, "\n");
> }
>
>- if (bond->params.mode == BOND_MODE_8023AD) {
>+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
> struct ad_info ad_info;
>
> seq_puts(seq, "\n802.3ad info\n");
>@@ -188,7 +188,7 @@ static void bond_info_show_slave(struct seq_file *seq,
>
> seq_printf(seq, "Permanent HW addr: %pM\n", slave->perm_hwaddr);
>
>- if (bond->params.mode == BOND_MODE_8023AD) {
>+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
> const struct aggregator *agg
> = SLAVE_AD_INFO(slave)->port.aggregator;
>
>diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
>index 39c4d8d..daed52f 100644
>--- a/drivers/net/bonding/bond_sysfs.c
>+++ b/drivers/net/bonding/bond_sysfs.c
>@@ -214,9 +214,9 @@ static ssize_t bonding_show_mode(struct device *d,
> struct bonding *bond = to_bond(d);
> const struct bond_opt_value *val;
>
>- val = bond_opt_get_val(BOND_OPT_MODE, bond->params.mode);
>+ val = bond_opt_get_val(BOND_OPT_MODE, BOND_MODE(bond));
>
>- return sprintf(buf, "%s %d\n", val->string, bond->params.mode);
>+ return sprintf(buf, "%s %d\n", val->string, BOND_MODE(bond));
> }
> static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR,
> bonding_show_mode, bonding_sysfs_store_option);
>@@ -505,7 +505,7 @@ static ssize_t bonding_show_ad_aggregator(struct device *d,
> int count = 0;
> struct bonding *bond = to_bond(d);
>
>- if (bond->params.mode == BOND_MODE_8023AD) {
>+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
> struct ad_info ad_info;
> count = sprintf(buf, "%d\n",
> bond_3ad_get_active_agg_info(bond, &ad_info)
>@@ -525,7 +525,7 @@ static ssize_t bonding_show_ad_num_ports(struct device *d,
> int count = 0;
> struct bonding *bond = to_bond(d);
>
>- if (bond->params.mode == BOND_MODE_8023AD) {
>+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
> struct ad_info ad_info;
> count = sprintf(buf, "%d\n",
> bond_3ad_get_active_agg_info(bond, &ad_info)
>@@ -545,7 +545,7 @@ static ssize_t bonding_show_ad_actor_key(struct device *d,
> int count = 0;
> struct bonding *bond = to_bond(d);
>
>- if (bond->params.mode == BOND_MODE_8023AD) {
>+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
> struct ad_info ad_info;
> count = sprintf(buf, "%d\n",
> bond_3ad_get_active_agg_info(bond, &ad_info)
>@@ -565,7 +565,7 @@ static ssize_t bonding_show_ad_partner_key(struct device *d,
> int count = 0;
> struct bonding *bond = to_bond(d);
>
>- if (bond->params.mode == BOND_MODE_8023AD) {
>+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
> struct ad_info ad_info;
> count = sprintf(buf, "%d\n",
> bond_3ad_get_active_agg_info(bond, &ad_info)
>@@ -585,7 +585,7 @@ static ssize_t bonding_show_ad_partner_mac(struct device *d,
> int count = 0;
> struct bonding *bond = to_bond(d);
>
>- if (bond->params.mode == BOND_MODE_8023AD) {
>+ if (BOND_MODE(bond) == BOND_MODE_8023AD) {
> struct ad_info ad_info;
> if (!bond_3ad_get_active_agg_info(bond, &ad_info))
> count = sprintf(buf, "%pM\n", ad_info.partner_system);
>diff --git a/drivers/net/bonding/bond_sysfs_slave.c b/drivers/net/bonding/bond_sysfs_slave.c
>index 89bc3b3..198677f 100644
>--- a/drivers/net/bonding/bond_sysfs_slave.c
>+++ b/drivers/net/bonding/bond_sysfs_slave.c
>@@ -69,7 +69,7 @@ static ssize_t ad_aggregator_id_show(struct slave *slave, char *buf)
> {
> const struct aggregator *agg;
>
>- if (slave->bond->params.mode == BOND_MODE_8023AD) {
>+ if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) {
> agg = SLAVE_AD_INFO(slave)->port.aggregator;
> if (agg)
> return sprintf(buf, "%d\n",
>diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
>index 34a8ed5..4494fb9 100644
>--- a/drivers/net/bonding/bonding.h
>+++ b/drivers/net/bonding/bonding.h
>@@ -70,6 +70,8 @@
> set_fs(fs); \
> res; })
>
>+#define BOND_MODE(bond) ((bond)->params.mode)
>+
> /* slave list primitives */
> #define bond_slave_list(bond) (&(bond)->dev->adj_list.lower)
>
>@@ -277,8 +279,8 @@ static inline bool bond_should_override_tx_queue(struct bonding *bond)
>
> static inline bool bond_is_lb(const struct bonding *bond)
> {
>- return bond->params.mode == BOND_MODE_TLB ||
>- bond->params.mode == BOND_MODE_ALB;
>+ return BOND_MODE(bond) == BOND_MODE_TLB ||
>+ BOND_MODE(bond) == BOND_MODE_ALB;
> }
>
> static inline bool bond_mode_uses_arp(int mode)
>--
>1.8.4
---
-Jay Vosburgh, jay.vosburgh@canonical.com
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 net-next 5/9] bonding: create a macro for bond mode and use it
2014-05-15 17:51 ` Jay Vosburgh
@ 2014-05-15 18:14 ` Veaceslav Falico
2014-05-15 18:32 ` Jay Vosburgh
0 siblings, 1 reply; 16+ messages in thread
From: Veaceslav Falico @ 2014-05-15 18:14 UTC (permalink / raw)
To: Jay Vosburgh; +Cc: netdev, Andy Gospodarek
On Thu, May 15, 2014 at 10:51:51AM -0700, Jay Vosburgh wrote:
>Veaceslav Falico <vfalico@gmail.com> wrote:
>
>>CC: Jay Vosburgh <j.vosburgh@gmail.com>
>>CC: Andy Gospodarek <andy@greyhouse.net>
>>Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
>>---
...snip...
> Would it be better to use "bond_uses_primary(struct bonding *)"
>instead of the above? That would simplify the above calling pattern,
>and shorten the calls elsewhere. Maybe I missed one, but it looks like
>all of the calls to _uses_primary have BOND_MODE(bond) as the argument.
There's at least one call, when checking the params, where it checks the
int:
bond_main.c:
4271 if (primary && !bond_mode_uses_primary(bond_mode)) {
so, either we'll use something else here, or leave it with BOND_MODE()...
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 net-next 5/9] bonding: create a macro for bond mode and use it
2014-05-15 18:14 ` Veaceslav Falico
@ 2014-05-15 18:32 ` Jay Vosburgh
2014-05-15 19:18 ` Veaceslav Falico
0 siblings, 1 reply; 16+ messages in thread
From: Jay Vosburgh @ 2014-05-15 18:32 UTC (permalink / raw)
To: Veaceslav Falico; +Cc: netdev, Andy Gospodarek
Veaceslav Falico <vfalico@gmail.com> wrote:
>On Thu, May 15, 2014 at 10:51:51AM -0700, Jay Vosburgh wrote:
>>Veaceslav Falico <vfalico@gmail.com> wrote:
>>
>>>CC: Jay Vosburgh <j.vosburgh@gmail.com>
>>>CC: Andy Gospodarek <andy@greyhouse.net>
>>>Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
>>>---
>...snip...
>> Would it be better to use "bond_uses_primary(struct bonding *)"
>>instead of the above? That would simplify the above calling pattern,
>>and shorten the calls elsewhere. Maybe I missed one, but it looks like
>>all of the calls to _uses_primary have BOND_MODE(bond) as the argument.
>
>There's at least one call, when checking the params, where it checks the
>int:
>
>bond_main.c:
>4271 if (primary && !bond_mode_uses_primary(bond_mode)) {
>
>so, either we'll use something else here, or leave it with BOND_MODE()...
The something else isn't so bad, and would look better for most
callers:
static inline bool bond_uses_primary(struct bonding *bond)
{
return bond_mode_uses_primary(bond->params.mode);
}
This ends up replacing "USES_PRIMARY(bond->params.mode)" with
"bond_uses_primary(bond)" for most call sites, which actually looks like
an improvement (it's even shorter).
-J
---
-Jay Vosburgh, jay.vosburgh@canonical.com
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 net-next 5/9] bonding: create a macro for bond mode and use it
2014-05-15 18:32 ` Jay Vosburgh
@ 2014-05-15 19:18 ` Veaceslav Falico
0 siblings, 0 replies; 16+ messages in thread
From: Veaceslav Falico @ 2014-05-15 19:18 UTC (permalink / raw)
To: Jay Vosburgh; +Cc: netdev, Andy Gospodarek
On Thu, May 15, 2014 at 11:32:41AM -0700, Jay Vosburgh wrote:
>Veaceslav Falico <vfalico@gmail.com> wrote:
>
>>On Thu, May 15, 2014 at 10:51:51AM -0700, Jay Vosburgh wrote:
>>>Veaceslav Falico <vfalico@gmail.com> wrote:
>>>
>>>>CC: Jay Vosburgh <j.vosburgh@gmail.com>
>>>>CC: Andy Gospodarek <andy@greyhouse.net>
>>>>Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
>>>>---
>>...snip...
>>> Would it be better to use "bond_uses_primary(struct bonding *)"
>>>instead of the above? That would simplify the above calling pattern,
>>>and shorten the calls elsewhere. Maybe I missed one, but it looks like
>>>all of the calls to _uses_primary have BOND_MODE(bond) as the argument.
>>
>>There's at least one call, when checking the params, where it checks the
>>int:
>>
>>bond_main.c:
>>4271 if (primary && !bond_mode_uses_primary(bond_mode)) {
>>
>>so, either we'll use something else here, or leave it with BOND_MODE()...
>
> The something else isn't so bad, and would look better for most
>callers:
>
>static inline bool bond_uses_primary(struct bonding *bond)
>{
> return bond_mode_uses_primary(bond->params.mode);
>}
>
> This ends up replacing "USES_PRIMARY(bond->params.mode)" with
>"bond_uses_primary(bond)" for most call sites, which actually looks like
>an improvement (it's even shorter).
Yeah, good idea, will do and resubmit.
Thank you!
>
> -J
>
>---
> -Jay Vosburgh, jay.vosburgh@canonical.com
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2014-05-15 19:18 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-15 12:29 [PATCH v2 net-next 0/9] bonding: simple macro cleanup Veaceslav Falico
2014-05-15 12:29 ` [PATCH v2 net-next 1/9] bonding: remove BOND_MODE_IS_LB macro Veaceslav Falico
2014-05-15 12:29 ` [PATCH v2 net-next 2/9] bonding: make TX_QUEUE_OVERRIDE() macro an inline function Veaceslav Falico
2014-05-15 12:29 ` [PATCH v2 net-next 3/9] bonding: make BOND_NO_USES_ARP " Veaceslav Falico
2014-05-15 15:35 ` Alexei Starovoitov
2014-05-15 15:45 ` Veaceslav Falico
2014-05-15 12:29 ` [PATCH v2 net-next 4/9] bonding: make USES_PRIMARY " Veaceslav Falico
2014-05-15 12:29 ` [PATCH v2 net-next 5/9] bonding: create a macro for bond mode and use it Veaceslav Falico
2014-05-15 17:51 ` Jay Vosburgh
2014-05-15 18:14 ` Veaceslav Falico
2014-05-15 18:32 ` Jay Vosburgh
2014-05-15 19:18 ` Veaceslav Falico
2014-05-15 12:29 ` [PATCH v2 net-next 6/9] bonding: make IS_IP_TARGET_UNUSABLE_ADDRESS an inline function Veaceslav Falico
2014-05-15 12:29 ` [PATCH v2 net-next 7/9] bonding: convert IS_UP(slave->dev) to " Veaceslav Falico
2014-05-15 12:29 ` [PATCH v2 net-next 8/9] bonding: rename {,bond_}slave_can_tx and clean it up Veaceslav Falico
2014-05-15 12:29 ` [PATCH v2 net-next 9/9] bonding: replace SLAVE_IS_OK() with bond_slave_can_tx() Veaceslav Falico
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).