bonding: convert min_links to use the new option API
authorNikolay Aleksandrov <nikolay@redhat.com>
Wed, 22 Jan 2014 13:53:28 +0000 (14:53 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 22 Jan 2014 23:38:43 +0000 (15:38 -0800)
This patch adds the necessary changes so min_links 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 508f2f51adadc16cb424e137b5318efbe5ddd4d3..a85466c0b0e3b37912d623ca4be5f7c0bca8f225 100644 (file)
@@ -285,7 +285,8 @@ static int bond_changelink(struct net_device *bond_dev,
                int min_links =
                        nla_get_u32(data[IFLA_BOND_MIN_LINKS]);
 
-               err = bond_option_min_links_set(bond, min_links);
+               bond_opt_initval(&newval, min_links);
+               err = __bond_opt_set(bond, BOND_OPT_MINLINKS, &newval);
                if (err)
                        return err;
        }
index 680296c279dcaeb3c62d53c8697a0513f8356fc0..f8821696f82376d8f7ad6a336e3f303be281c45d 100644 (file)
@@ -164,6 +164,13 @@ static struct bond_option bond_opts[] = {
                .values = bond_lacp_rate_tbl,
                .set = bond_option_lacp_rate_set
        },
+       [BOND_OPT_MINLINKS] = {
+               .id = BOND_OPT_MINLINKS,
+               .name = "min_links",
+               .desc = "Minimum number of available links before turning on carrier",
+               .values = bond_intmax_tbl,
+               .set = bond_option_min_links_set
+       },
        { }
 };
 
@@ -990,11 +997,12 @@ int bond_option_all_slaves_active_set(struct bonding *bond,
        return 0;
 }
 
-int bond_option_min_links_set(struct bonding *bond, int min_links)
+int bond_option_min_links_set(struct bonding *bond,
+                             struct bond_opt_value *newval)
 {
-       pr_info("%s: Setting min links value to %u\n",
-               bond->dev->name, min_links);
-       bond->params.min_links = min_links;
+       pr_info("%s: Setting min links value to %llu\n",
+               bond->dev->name, newval->value);
+       bond->params.min_links = newval->value;
 
        return 0;
 }
index 7ee1a78abd8d4f2a91deee04cf4113a038e67832..cc8edef812c4e792e854273629debd8d0a665481 100644 (file)
@@ -49,6 +49,7 @@ enum {
        BOND_OPT_DOWNDELAY,
        BOND_OPT_UPDELAY,
        BOND_OPT_LACP_RATE,
+       BOND_OPT_MINLINKS,
        BOND_OPT_LAST
 };
 
@@ -130,4 +131,6 @@ int bond_option_updelay_set(struct bonding *bond,
                            struct bond_opt_value *newval);
 int bond_option_lacp_rate_set(struct bonding *bond,
                              struct bond_opt_value *newval);
+int bond_option_min_links_set(struct bonding *bond,
+                             struct bond_opt_value *newval);
 #endif /* _BOND_OPTIONS_H */
index a0a54d035c526ac8eb3514a4cddf66954bba6b14..3ae9bfd8e65e8bc87eced2896b45c630bad75dd6 100644 (file)
@@ -586,23 +586,11 @@ static ssize_t bonding_store_min_links(struct device *d,
 {
        struct bonding *bond = to_bond(d);
        int ret;
-       unsigned int new_value;
 
-       ret = kstrtouint(buf, 0, &new_value);
-       if (ret < 0) {
-               pr_err("%s: Ignoring invalid min links value %s.\n",
-                      bond->dev->name, buf);
-               return ret;
-       }
-
-       if (!rtnl_trylock())
-               return restart_syscall();
-
-       ret = bond_option_min_links_set(bond, new_value);
+       ret = bond_opt_tryset_rtnl(bond, BOND_OPT_MINLINKS, (char *)buf);
        if (!ret)
                ret = count;
 
-       rtnl_unlock();
        return ret;
 }
 static DEVICE_ATTR(min_links, S_IRUGO | S_IWUSR,
index da03ede3e0a51bdf8fa5c41b9b272e4b441f7dfb..df8c5ae44cdcf54bed963e8d920979cb91f5a068 100644 (file)
@@ -464,7 +464,6 @@ 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_min_links_set(struct bonding *bond, int min_links);
 int bond_option_lp_interval_set(struct bonding *bond, int min_links);
 int bond_option_ad_select_set(struct bonding *bond, int ad_select);
 struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond);