bonding: convert resend_igmp to use the new option API
authorNikolay Aleksandrov <nikolay@redhat.com>
Wed, 22 Jan 2014 13:53:38 +0000 (14:53 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 22 Jan 2014 23:38:44 +0000 (15:38 -0800)
This patch adds the necessary changes so resend_igmp would use
the new bonding option API.

Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/bonding/bond_netlink.c
drivers/net/bonding/bond_options.c
drivers/net/bonding/bond_options.h
drivers/net/bonding/bond_sysfs.c
drivers/net/bonding/bonding.h

index 828013a16c5243f4c2b0704a4691e5c593c530e5..1e099c6e5dda0cf9b81c927439093d5a0e904c70 100644 (file)
@@ -265,7 +265,8 @@ static int bond_changelink(struct net_device *bond_dev,
                int resend_igmp =
                        nla_get_u32(data[IFLA_BOND_RESEND_IGMP]);
 
-               err = bond_option_resend_igmp_set(bond, resend_igmp);
+               bond_opt_initval(&newval, resend_igmp);
+               err = __bond_opt_set(bond, BOND_OPT_RESEND_IGMP, &newval);
                if (err)
                        return err;
        }
index 7fafc34ca47b6fa184e4b0c587747c6f37350c7c..1373093d1c6ac6bcb1d6c3c08b8a5eabb42cbfdf 100644 (file)
@@ -111,6 +111,13 @@ static struct bond_opt_value bond_all_slaves_active_tbl[] = {
        { NULL,  -1, 0}
 };
 
+static struct bond_opt_value bond_resend_igmp_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,
@@ -274,6 +281,13 @@ static struct bond_option bond_opts[] = {
                .values = bond_all_slaves_active_tbl,
                .set = bond_option_all_slaves_active_set
        },
+       [BOND_OPT_RESEND_IGMP] = {
+               .id = BOND_OPT_RESEND_IGMP,
+               .name = "resend_igmp",
+               .desc = "Number of IGMP membership reports to send on link failure",
+               .values = bond_resend_igmp_tbl,
+               .set = bond_option_resend_igmp_set
+       },
        { }
 };
 
@@ -1038,17 +1052,12 @@ int bond_option_xmit_hash_policy_set(struct bonding *bond,
        return 0;
 }
 
-int bond_option_resend_igmp_set(struct bonding *bond, int resend_igmp)
+int bond_option_resend_igmp_set(struct bonding *bond,
+                               struct bond_opt_value *newval)
 {
-       if (resend_igmp < 0 || resend_igmp > 255) {
-               pr_err("%s: Invalid resend_igmp value %d not in range 0-255; rejected.\n",
-                      bond->dev->name, resend_igmp);
-               return -EINVAL;
-       }
-
-       bond->params.resend_igmp = resend_igmp;
-       pr_info("%s: Setting resend_igmp to %d.\n",
-               bond->dev->name, resend_igmp);
+       pr_info("%s: Setting resend_igmp to %llu.\n",
+               bond->dev->name, newval->value);
+       bond->params.resend_igmp = newval->value;
 
        return 0;
 }
index 09ee8c8bb19bd7f03e7c0684cf105ca35c68068d..f0c2cbb0347890e22d068ca2bfa3b066ddaf7384 100644 (file)
@@ -59,6 +59,7 @@ enum {
        BOND_OPT_ACTIVE_SLAVE,
        BOND_OPT_QUEUE_ID,
        BOND_OPT_ALL_SLAVES_ACTIVE,
+       BOND_OPT_RESEND_IGMP,
        BOND_OPT_LAST
 };
 
@@ -159,4 +160,6 @@ int bond_option_queue_id_set(struct bonding *bond,
                             struct bond_opt_value *newval);
 int bond_option_all_slaves_active_set(struct bonding *bond,
                                      struct bond_opt_value *newval);
+int bond_option_resend_igmp_set(struct bonding *bond,
+                               struct bond_opt_value *newval);
 #endif /* _BOND_OPTIONS_H */
index 20210d29e86bb2dc8bf0206f611a94eb33351bd1..1693ebd7dcbe78743144c0bf189dbd5a38bb1eff 100644 (file)
@@ -1043,23 +1043,13 @@ static ssize_t bonding_store_resend_igmp(struct device *d,
                                         struct device_attribute *attr,
                                         const char *buf, size_t count)
 {
-       int new_value, ret = count;
        struct bonding *bond = to_bond(d);
+       int ret;
 
-       if (sscanf(buf, "%d", &new_value) != 1) {
-               pr_err("%s: no resend_igmp value specified.\n",
-                      bond->dev->name);
-               return -EINVAL;
-       }
-
-       if (!rtnl_trylock())
-               return restart_syscall();
-
-       ret = bond_option_resend_igmp_set(bond, new_value);
+       ret = bond_opt_tryset_rtnl(bond, BOND_OPT_RESEND_IGMP, (char *)buf);
        if (!ret)
                ret = count;
 
-       rtnl_unlock();
        return ret;
 }
 
index 9801c5d6cee4a9d90c45e7137dca900bfa02b3c0..1683e400768ca74a7656855c7ead2aa0b7d8de2b 100644 (file)
@@ -454,7 +454,6 @@ int bond_netlink_init(void);
 void bond_netlink_fini(void);
 int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target);
 int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target);
-int bond_option_resend_igmp_set(struct bonding *bond, int resend_igmp);
 int bond_option_lp_interval_set(struct bonding *bond, int min_links);
 struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond);
 struct net_device *bond_option_active_slave_get(struct bonding *bond);