summaryrefslogtreecommitdiff
path: root/drivers/net/bonding
diff options
context:
space:
mode:
authorNikolay Aleksandrov <nikolay@redhat.com>2014-01-22 14:53:30 +0100
committerDavid S. Miller <davem@davemloft.net>2014-01-22 15:38:43 -0800
commitef56becbb37251f0371ad94210f50dc90e18830a (patch)
treed657b18b30389725142a2df35c8ba2ddefaae636 /drivers/net/bonding
parent9e5f5eebe765b340af0318dba261e5de0f2aaf32 (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.c3
-rw-r--r--drivers/net/bonding/bond_options.c20
-rw-r--r--drivers/net/bonding/bond_options.h3
-rw-r--r--drivers/net/bonding/bond_sysfs.c14
-rw-r--r--drivers/net/bonding/bonding.h1
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,
int num_peer_notif =
nla_get_u8(data[IFLA_BOND_NUM_PEER_NOTIF]);
- err = bond_option_num_peer_notif_set(bond, num_peer_notif);
+ bond_opt_initval(&newval, num_peer_notif);
+ err = __bond_opt_set(bond, BOND_OPT_NUM_PEER_NOTIF, &newval);
if (err)
return err;
}
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[] = {
{ NULL, -1, 0},
};
+static struct bond_opt_value bond_num_peer_notif_tbl[] = {
+ { "off", 0, 0},
+ { "maxval", 255, BOND_VALFLAG_MAX},
+ { "default", 1, BOND_VALFLAG_DEFAULT},
+ { NULL, -1, 0}
+};
+
static struct bond_option bond_opts[] = {
[BOND_OPT_MODE] = {
.id = BOND_OPT_MODE,
@@ -186,6 +193,13 @@ static struct bond_option bond_opts[] = {
.values = bond_ad_select_tbl,
.set = bond_option_ad_select_set
},
+ [BOND_OPT_NUM_PEER_NOTIF] = {
+ .id = BOND_OPT_NUM_PEER_NOTIF,
+ .name = "num_unsol_na",
+ .desc = "Number of peer notifications to send on failover event",
+ .values = bond_num_peer_notif_tbl,
+ .set = bond_option_num_peer_notif_set
+ },
{ }
};
@@ -977,9 +991,11 @@ int bond_option_resend_igmp_set(struct bonding *bond, int resend_igmp)
return 0;
}
-int bond_option_num_peer_notif_set(struct bonding *bond, int num_peer_notif)
+int bond_option_num_peer_notif_set(struct bonding *bond,
+ struct bond_opt_value *newval)
{
- bond->params.num_peer_notif = num_peer_notif;
+ bond->params.num_peer_notif = newval->value;
+
return 0;
}
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 {
BOND_OPT_LACP_RATE,
BOND_OPT_MINLINKS,
BOND_OPT_AD_SELECT,
+ BOND_OPT_NUM_PEER_NOTIF,
BOND_OPT_LAST
};
@@ -136,4 +137,6 @@ int bond_option_min_links_set(struct bonding *bond,
struct bond_opt_value *newval);
int bond_option_ad_select_set(struct bonding *bond,
struct bond_opt_value *newval);
+int bond_option_num_peer_notif_set(struct bonding *bond,
+ struct bond_opt_value *newval);
#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,
const char *buf, size_t count)
{
struct bonding *bond = to_bond(d);
- u8 new_value;
int ret;
- ret = kstrtou8(buf, 10, &new_value);
- if (ret) {
- pr_err("%s: invalid value %s specified.\n",
- bond->dev->name, buf);
- return ret;
- }
-
- if (!rtnl_trylock())
- return restart_syscall();
-
- ret = bond_option_num_peer_notif_set(bond, new_value);
+ ret = bond_opt_tryset_rtnl(bond, BOND_OPT_NUM_PEER_NOTIF, (char *)buf);
if (!ret)
ret = count;
- rtnl_unlock();
return ret;
}
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);
int bond_option_primary_reselect_set(struct bonding *bond,
int primary_reselect);
int bond_option_resend_igmp_set(struct bonding *bond, int resend_igmp);
-int bond_option_num_peer_notif_set(struct bonding *bond, int num_peer_notif);
int bond_option_all_slaves_active_set(struct bonding *bond,
int all_slaves_active);
int bond_option_lp_interval_set(struct bonding *bond, int min_links);