Commit 01844098 authored by Veaceslav Falico's avatar Veaceslav Falico Committed by David S. Miller

bonding: create a macro for bond mode and use it

CC: Jay Vosburgh <j.vosburgh@gmail.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: default avatarVeaceslav Falico <vfalico@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ec0865a9
...@@ -1057,7 +1057,7 @@ static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[]) ...@@ -1057,7 +1057,7 @@ static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[])
struct net_device *dev = slave->dev; struct net_device *dev = slave->dev;
struct sockaddr s_addr; 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); memcpy(dev->dev_addr, addr, dev->addr_len);
return 0; return 0;
} }
...@@ -1745,7 +1745,7 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave ...@@ -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, /* 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 * 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; struct sockaddr sa;
u8 tmp_addr[ETH_ALEN]; u8 tmp_addr[ETH_ALEN];
......
...@@ -23,7 +23,7 @@ static int bond_debug_rlb_hash_show(struct seq_file *m, void *v) ...@@ -23,7 +23,7 @@ static int bond_debug_rlb_hash_show(struct seq_file *m, void *v)
struct rlb_client_info *client_info; struct rlb_client_info *client_info;
u32 hash_index; u32 hash_index;
if (bond->params.mode != BOND_MODE_ALB) if (BOND_MODE(bond) != BOND_MODE_ALB)
return 0; return 0;
seq_printf(m, "SourceIP DestinationIP " seq_printf(m, "SourceIP DestinationIP "
......
This diff is collapsed.
...@@ -56,7 +56,7 @@ static int bond_fill_slave_info(struct sk_buff *skb, ...@@ -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)) if (nla_put_u16(skb, IFLA_BOND_SLAVE_QUEUE_ID, slave->queue_id))
goto nla_put_failure; goto nla_put_failure;
if (slave->bond->params.mode == BOND_MODE_8023AD) { if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) {
const struct aggregator *agg; const struct aggregator *agg;
agg = SLAVE_AD_INFO(slave)->port.aggregator; agg = SLAVE_AD_INFO(slave)->port.aggregator;
...@@ -407,7 +407,7 @@ static int bond_fill_info(struct sk_buff *skb, ...@@ -407,7 +407,7 @@ static int bond_fill_info(struct sk_buff *skb,
unsigned int packets_per_slave; unsigned int packets_per_slave;
int i, targets_added; 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; goto nla_put_failure;
if (slave_dev && if (slave_dev &&
...@@ -505,7 +505,7 @@ static int bond_fill_info(struct sk_buff *skb, ...@@ -505,7 +505,7 @@ static int bond_fill_info(struct sk_buff *skb,
bond->params.ad_select)) bond->params.ad_select))
goto nla_put_failure; goto nla_put_failure;
if (bond->params.mode == BOND_MODE_8023AD) { if (BOND_MODE(bond) == BOND_MODE_8023AD) {
struct ad_info info; struct ad_info info;
if (!bond_3ad_get_active_agg_info(bond, &info)) { if (!bond_3ad_get_active_agg_info(bond, &info)) {
......
...@@ -72,9 +72,9 @@ static void bond_info_show_master(struct seq_file *seq) ...@@ -72,9 +72,9 @@ static void bond_info_show_master(struct seq_file *seq)
curr = rcu_dereference(bond->curr_active_slave); curr = rcu_dereference(bond->curr_active_slave);
seq_printf(seq, "Bonding Mode: %s", 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) { bond->params.fail_over_mac) {
optval = bond_opt_get_val(BOND_OPT_FAIL_OVER_MAC, optval = bond_opt_get_val(BOND_OPT_FAIL_OVER_MAC,
bond->params.fail_over_mac); bond->params.fail_over_mac);
...@@ -83,8 +83,8 @@ static void bond_info_show_master(struct seq_file *seq) ...@@ -83,8 +83,8 @@ static void bond_info_show_master(struct seq_file *seq)
seq_printf(seq, "\n"); seq_printf(seq, "\n");
if (bond->params.mode == BOND_MODE_XOR || if (BOND_MODE(bond) == BOND_MODE_XOR ||
bond->params.mode == BOND_MODE_8023AD) { BOND_MODE(bond) == BOND_MODE_8023AD) {
optval = bond_opt_get_val(BOND_OPT_XMIT_HASH, optval = bond_opt_get_val(BOND_OPT_XMIT_HASH,
bond->params.xmit_policy); bond->params.xmit_policy);
seq_printf(seq, "Transmit Hash Policy: %s (%d)\n", seq_printf(seq, "Transmit Hash Policy: %s (%d)\n",
...@@ -134,7 +134,7 @@ static void bond_info_show_master(struct seq_file *seq) ...@@ -134,7 +134,7 @@ static void bond_info_show_master(struct seq_file *seq)
seq_printf(seq, "\n"); seq_printf(seq, "\n");
} }
if (bond->params.mode == BOND_MODE_8023AD) { if (BOND_MODE(bond) == BOND_MODE_8023AD) {
struct ad_info ad_info; struct ad_info ad_info;
seq_puts(seq, "\n802.3ad info\n"); seq_puts(seq, "\n802.3ad info\n");
...@@ -188,7 +188,7 @@ static void bond_info_show_slave(struct seq_file *seq, ...@@ -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); 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 const struct aggregator *agg
= SLAVE_AD_INFO(slave)->port.aggregator; = SLAVE_AD_INFO(slave)->port.aggregator;
......
...@@ -214,9 +214,9 @@ static ssize_t bonding_show_mode(struct device *d, ...@@ -214,9 +214,9 @@ static ssize_t bonding_show_mode(struct device *d,
struct bonding *bond = to_bond(d); struct bonding *bond = to_bond(d);
const struct bond_opt_value *val; 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, static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR,
bonding_show_mode, bonding_sysfs_store_option); bonding_show_mode, bonding_sysfs_store_option);
...@@ -505,7 +505,7 @@ static ssize_t bonding_show_ad_aggregator(struct device *d, ...@@ -505,7 +505,7 @@ static ssize_t bonding_show_ad_aggregator(struct device *d,
int count = 0; int count = 0;
struct bonding *bond = to_bond(d); 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; struct ad_info ad_info;
count = sprintf(buf, "%d\n", count = sprintf(buf, "%d\n",
bond_3ad_get_active_agg_info(bond, &ad_info) bond_3ad_get_active_agg_info(bond, &ad_info)
...@@ -525,7 +525,7 @@ static ssize_t bonding_show_ad_num_ports(struct device *d, ...@@ -525,7 +525,7 @@ static ssize_t bonding_show_ad_num_ports(struct device *d,
int count = 0; int count = 0;
struct bonding *bond = to_bond(d); 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; struct ad_info ad_info;
count = sprintf(buf, "%d\n", count = sprintf(buf, "%d\n",
bond_3ad_get_active_agg_info(bond, &ad_info) bond_3ad_get_active_agg_info(bond, &ad_info)
...@@ -545,7 +545,7 @@ static ssize_t bonding_show_ad_actor_key(struct device *d, ...@@ -545,7 +545,7 @@ static ssize_t bonding_show_ad_actor_key(struct device *d,
int count = 0; int count = 0;
struct bonding *bond = to_bond(d); 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; struct ad_info ad_info;
count = sprintf(buf, "%d\n", count = sprintf(buf, "%d\n",
bond_3ad_get_active_agg_info(bond, &ad_info) bond_3ad_get_active_agg_info(bond, &ad_info)
...@@ -565,7 +565,7 @@ static ssize_t bonding_show_ad_partner_key(struct device *d, ...@@ -565,7 +565,7 @@ static ssize_t bonding_show_ad_partner_key(struct device *d,
int count = 0; int count = 0;
struct bonding *bond = to_bond(d); 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; struct ad_info ad_info;
count = sprintf(buf, "%d\n", count = sprintf(buf, "%d\n",
bond_3ad_get_active_agg_info(bond, &ad_info) bond_3ad_get_active_agg_info(bond, &ad_info)
...@@ -585,7 +585,7 @@ static ssize_t bonding_show_ad_partner_mac(struct device *d, ...@@ -585,7 +585,7 @@ static ssize_t bonding_show_ad_partner_mac(struct device *d,
int count = 0; int count = 0;
struct bonding *bond = to_bond(d); 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; struct ad_info ad_info;
if (!bond_3ad_get_active_agg_info(bond, &ad_info)) if (!bond_3ad_get_active_agg_info(bond, &ad_info))
count = sprintf(buf, "%pM\n", ad_info.partner_system); count = sprintf(buf, "%pM\n", ad_info.partner_system);
......
...@@ -69,7 +69,7 @@ static ssize_t ad_aggregator_id_show(struct slave *slave, char *buf) ...@@ -69,7 +69,7 @@ static ssize_t ad_aggregator_id_show(struct slave *slave, char *buf)
{ {
const struct aggregator *agg; 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; agg = SLAVE_AD_INFO(slave)->port.aggregator;
if (agg) if (agg)
return sprintf(buf, "%d\n", return sprintf(buf, "%d\n",
......
...@@ -70,6 +70,8 @@ ...@@ -70,6 +70,8 @@
set_fs(fs); \ set_fs(fs); \
res; }) res; })
#define BOND_MODE(bond) ((bond)->params.mode)
/* slave list primitives */ /* slave list primitives */
#define bond_slave_list(bond) (&(bond)->dev->adj_list.lower) #define bond_slave_list(bond) (&(bond)->dev->adj_list.lower)
...@@ -271,14 +273,14 @@ static inline struct bonding *bond_get_bond_by_slave(struct slave *slave) ...@@ -271,14 +273,14 @@ static inline struct bonding *bond_get_bond_by_slave(struct slave *slave)
static inline bool bond_should_override_tx_queue(struct bonding *bond) static inline bool bond_should_override_tx_queue(struct bonding *bond)
{ {
return bond->params.mode == BOND_MODE_ACTIVEBACKUP || return BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP ||
bond->params.mode == BOND_MODE_ROUNDROBIN; BOND_MODE(bond) == BOND_MODE_ROUNDROBIN;
} }
static inline bool bond_is_lb(const struct bonding *bond) static inline bool bond_is_lb(const struct bonding *bond)
{ {
return bond->params.mode == BOND_MODE_TLB || return BOND_MODE(bond) == BOND_MODE_TLB ||
bond->params.mode == BOND_MODE_ALB; BOND_MODE(bond) == BOND_MODE_ALB;
} }
static inline bool bond_mode_uses_arp(int mode) static inline bool bond_mode_uses_arp(int mode)
...@@ -295,7 +297,7 @@ static inline bool bond_mode_uses_primary(int mode) ...@@ -295,7 +297,7 @@ static inline bool bond_mode_uses_primary(int mode)
static inline bool bond_uses_primary(struct bonding *bond) static inline bool bond_uses_primary(struct bonding *bond)
{ {
return bond_mode_uses_primary(bond->params.mode); return bond_mode_uses_primary(BOND_MODE(bond));
} }
static inline void bond_set_active_slave(struct slave *slave) static inline void bond_set_active_slave(struct slave *slave)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment