diff options
author | Jiri Pirko <jiri@resnulli.us> | 2013-10-18 11:43:37 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-10-19 18:58:45 -0400 |
commit | 752d48b52ec929c6fd6ccd7ea9728571830fdd49 (patch) | |
tree | 9cfca24ba271e1c6ba64fae7417437f729c166ea /drivers | |
parent | 080a06e1a9a5d2c55884d5fba8755d0af838cd5c (diff) |
bonding: move active_slave getting into separate function
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/bonding/bond_options.c | 18 | ||||
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 8 | ||||
-rw-r--r-- | drivers/net/bonding/bonding.h | 2 |
3 files changed, 24 insertions, 4 deletions
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index 09af5d10d43a..9a5223c7b4d1 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c | |||
@@ -57,6 +57,24 @@ int bond_option_mode_set(struct bonding *bond, int mode) | |||
57 | return 0; | 57 | return 0; |
58 | } | 58 | } |
59 | 59 | ||
60 | static struct net_device *__bond_option_active_slave_get(struct bonding *bond, | ||
61 | struct slave *slave) | ||
62 | { | ||
63 | return USES_PRIMARY(bond->params.mode) && slave ? slave->dev : NULL; | ||
64 | } | ||
65 | |||
66 | struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond) | ||
67 | { | ||
68 | struct slave *slave = rcu_dereference(bond->curr_active_slave); | ||
69 | |||
70 | return __bond_option_active_slave_get(bond, slave); | ||
71 | } | ||
72 | |||
73 | struct net_device *bond_option_active_slave_get(struct bonding *bond) | ||
74 | { | ||
75 | return __bond_option_active_slave_get(bond, bond->curr_active_slave); | ||
76 | } | ||
77 | |||
60 | int bond_option_active_slave_set(struct bonding *bond, | 78 | int bond_option_active_slave_set(struct bonding *bond, |
61 | struct net_device *slave_dev) | 79 | struct net_device *slave_dev) |
62 | { | 80 | { |
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index abd260047103..47749c970a01 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -1219,13 +1219,13 @@ static ssize_t bonding_show_active_slave(struct device *d, | |||
1219 | char *buf) | 1219 | char *buf) |
1220 | { | 1220 | { |
1221 | struct bonding *bond = to_bond(d); | 1221 | struct bonding *bond = to_bond(d); |
1222 | struct slave *curr; | 1222 | struct net_device *slave_dev; |
1223 | int count = 0; | 1223 | int count = 0; |
1224 | 1224 | ||
1225 | rcu_read_lock(); | 1225 | rcu_read_lock(); |
1226 | curr = rcu_dereference(bond->curr_active_slave); | 1226 | slave_dev = bond_option_active_slave_get_rcu(bond); |
1227 | if (USES_PRIMARY(bond->params.mode) && curr) | 1227 | if (slave_dev) |
1228 | count = sprintf(buf, "%s\n", curr->dev->name); | 1228 | count = sprintf(buf, "%s\n", slave_dev->name); |
1229 | rcu_read_unlock(); | 1229 | rcu_read_unlock(); |
1230 | 1230 | ||
1231 | return count; | 1231 | return count; |
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index 686759dce4c6..046a60535e04 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h | |||
@@ -428,6 +428,8 @@ int bond_netlink_init(void); | |||
428 | void bond_netlink_fini(void); | 428 | void bond_netlink_fini(void); |
429 | int bond_option_mode_set(struct bonding *bond, int mode); | 429 | int bond_option_mode_set(struct bonding *bond, int mode); |
430 | int bond_option_active_slave_set(struct bonding *bond, struct net_device *slave_dev); | 430 | int bond_option_active_slave_set(struct bonding *bond, struct net_device *slave_dev); |
431 | struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond); | ||
432 | struct net_device *bond_option_active_slave_get(struct bonding *bond); | ||
431 | 433 | ||
432 | struct bond_net { | 434 | struct bond_net { |
433 | struct net * net; /* Associated network namespace */ | 435 | struct net * net; /* Associated network namespace */ |