diff options
author | Nikolay Aleksandrov <nikolay@redhat.com> | 2014-01-22 08:53:30 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-01-22 18:38:43 -0500 |
commit | ef56becbb37251f0371ad94210f50dc90e18830a (patch) | |
tree | d657b18b30389725142a2df35c8ba2ddefaae636 /drivers/net/bonding | |
parent | 9e5f5eebe765b340af0318dba261e5de0f2aaf32 (diff) |
bonding: convert num_peer_notif to use the new option API
This patch adds the necessary changes so num_peer_notif would use
the new bonding option API.
When the auto-sysfs generation is done an alias should be added for
this option as there're currently 2 entries in sysfs for it.
Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding')
-rw-r--r-- | drivers/net/bonding/bond_netlink.c | 3 | ||||
-rw-r--r-- | drivers/net/bonding/bond_options.c | 20 | ||||
-rw-r--r-- | drivers/net/bonding/bond_options.h | 3 | ||||
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 14 | ||||
-rw-r--r-- | drivers/net/bonding/bonding.h | 1 |
5 files changed, 24 insertions, 17 deletions
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c index 830203dae20c..6855f28ac780 100644 --- a/drivers/net/bonding/bond_netlink.c +++ b/drivers/net/bonding/bond_netlink.c | |||
@@ -268,7 +268,8 @@ static int bond_changelink(struct net_device *bond_dev, | |||
268 | int num_peer_notif = | 268 | int num_peer_notif = |
269 | nla_get_u8(data[IFLA_BOND_NUM_PEER_NOTIF]); | 269 | nla_get_u8(data[IFLA_BOND_NUM_PEER_NOTIF]); |
270 | 270 | ||
271 | err = bond_option_num_peer_notif_set(bond, num_peer_notif); | 271 | bond_opt_initval(&newval, num_peer_notif); |
272 | err = __bond_opt_set(bond, BOND_OPT_NUM_PEER_NOTIF, &newval); | ||
272 | if (err) | 273 | if (err) |
273 | return err; | 274 | return err; |
274 | } | 275 | } |
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index 081ab9b5d48a..1bd19f1f1af2 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c | |||
@@ -85,6 +85,13 @@ static struct bond_opt_value bond_ad_select_tbl[] = { | |||
85 | { NULL, -1, 0}, | 85 | { NULL, -1, 0}, |
86 | }; | 86 | }; |
87 | 87 | ||
88 | static struct bond_opt_value bond_num_peer_notif_tbl[] = { | ||
89 | { "off", 0, 0}, | ||
90 | { "maxval", 255, BOND_VALFLAG_MAX}, | ||
91 | { "default", 1, BOND_VALFLAG_DEFAULT}, | ||
92 | { NULL, -1, 0} | ||
93 | }; | ||
94 | |||
88 | static struct bond_option bond_opts[] = { | 95 | static struct bond_option bond_opts[] = { |
89 | [BOND_OPT_MODE] = { | 96 | [BOND_OPT_MODE] = { |
90 | .id = BOND_OPT_MODE, | 97 | .id = BOND_OPT_MODE, |
@@ -186,6 +193,13 @@ static struct bond_option bond_opts[] = { | |||
186 | .values = bond_ad_select_tbl, | 193 | .values = bond_ad_select_tbl, |
187 | .set = bond_option_ad_select_set | 194 | .set = bond_option_ad_select_set |
188 | }, | 195 | }, |
196 | [BOND_OPT_NUM_PEER_NOTIF] = { | ||
197 | .id = BOND_OPT_NUM_PEER_NOTIF, | ||
198 | .name = "num_unsol_na", | ||
199 | .desc = "Number of peer notifications to send on failover event", | ||
200 | .values = bond_num_peer_notif_tbl, | ||
201 | .set = bond_option_num_peer_notif_set | ||
202 | }, | ||
189 | { } | 203 | { } |
190 | }; | 204 | }; |
191 | 205 | ||
@@ -977,9 +991,11 @@ int bond_option_resend_igmp_set(struct bonding *bond, int resend_igmp) | |||
977 | return 0; | 991 | return 0; |
978 | } | 992 | } |
979 | 993 | ||
980 | int bond_option_num_peer_notif_set(struct bonding *bond, int num_peer_notif) | 994 | int bond_option_num_peer_notif_set(struct bonding *bond, |
995 | struct bond_opt_value *newval) | ||
981 | { | 996 | { |
982 | bond->params.num_peer_notif = num_peer_notif; | 997 | bond->params.num_peer_notif = newval->value; |
998 | |||
983 | return 0; | 999 | return 0; |
984 | } | 1000 | } |
985 | 1001 | ||
diff --git a/drivers/net/bonding/bond_options.h b/drivers/net/bonding/bond_options.h index 53df1762d80f..014a359460e5 100644 --- a/drivers/net/bonding/bond_options.h +++ b/drivers/net/bonding/bond_options.h | |||
@@ -51,6 +51,7 @@ enum { | |||
51 | BOND_OPT_LACP_RATE, | 51 | BOND_OPT_LACP_RATE, |
52 | BOND_OPT_MINLINKS, | 52 | BOND_OPT_MINLINKS, |
53 | BOND_OPT_AD_SELECT, | 53 | BOND_OPT_AD_SELECT, |
54 | BOND_OPT_NUM_PEER_NOTIF, | ||
54 | BOND_OPT_LAST | 55 | BOND_OPT_LAST |
55 | }; | 56 | }; |
56 | 57 | ||
@@ -136,4 +137,6 @@ int bond_option_min_links_set(struct bonding *bond, | |||
136 | struct bond_opt_value *newval); | 137 | struct bond_opt_value *newval); |
137 | int bond_option_ad_select_set(struct bonding *bond, | 138 | int bond_option_ad_select_set(struct bonding *bond, |
138 | struct bond_opt_value *newval); | 139 | struct bond_opt_value *newval); |
140 | int bond_option_num_peer_notif_set(struct bonding *bond, | ||
141 | struct bond_opt_value *newval); | ||
139 | #endif /* _BOND_OPTIONS_H */ | 142 | #endif /* _BOND_OPTIONS_H */ |
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 02e493ae5173..e1c99db134a9 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -641,24 +641,12 @@ static ssize_t bonding_store_num_peer_notif(struct device *d, | |||
641 | const char *buf, size_t count) | 641 | const char *buf, size_t count) |
642 | { | 642 | { |
643 | struct bonding *bond = to_bond(d); | 643 | struct bonding *bond = to_bond(d); |
644 | u8 new_value; | ||
645 | int ret; | 644 | int ret; |
646 | 645 | ||
647 | ret = kstrtou8(buf, 10, &new_value); | 646 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_NUM_PEER_NOTIF, (char *)buf); |
648 | if (ret) { | ||
649 | pr_err("%s: invalid value %s specified.\n", | ||
650 | bond->dev->name, buf); | ||
651 | return ret; | ||
652 | } | ||
653 | |||
654 | if (!rtnl_trylock()) | ||
655 | return restart_syscall(); | ||
656 | |||
657 | ret = bond_option_num_peer_notif_set(bond, new_value); | ||
658 | if (!ret) | 647 | if (!ret) |
659 | ret = count; | 648 | ret = count; |
660 | 649 | ||
661 | rtnl_unlock(); | ||
662 | return ret; | 650 | return ret; |
663 | } | 651 | } |
664 | static DEVICE_ATTR(num_grat_arp, S_IRUGO | S_IWUSR, | 652 | static DEVICE_ATTR(num_grat_arp, S_IRUGO | S_IWUSR, |
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index 235fb18b65bf..4554a16a0f3e 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h | |||
@@ -461,7 +461,6 @@ int bond_option_primary_set(struct bonding *bond, const char *primary); | |||
461 | int bond_option_primary_reselect_set(struct bonding *bond, | 461 | int bond_option_primary_reselect_set(struct bonding *bond, |
462 | int primary_reselect); | 462 | int primary_reselect); |
463 | int bond_option_resend_igmp_set(struct bonding *bond, int resend_igmp); | 463 | int bond_option_resend_igmp_set(struct bonding *bond, int resend_igmp); |
464 | int bond_option_num_peer_notif_set(struct bonding *bond, int num_peer_notif); | ||
465 | int bond_option_all_slaves_active_set(struct bonding *bond, | 464 | int bond_option_all_slaves_active_set(struct bonding *bond, |
466 | int all_slaves_active); | 465 | int all_slaves_active); |
467 | int bond_option_lp_interval_set(struct bonding *bond, int min_links); | 466 | int bond_option_lp_interval_set(struct bonding *bond, int min_links); |