]> git.karo-electronics.de Git - linux-beck.git/commitdiff
bonding: convert lp_interval to use the new option API
authorNikolay Aleksandrov <nikolay@redhat.com>
Wed, 22 Jan 2014 13:53:39 +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 lp_interval 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 1e099c6e5dda0cf9b81c927439093d5a0e904c70..a8fa7256b7b1498ce6e72b048e0c1fbf897f13a8 100644 (file)
@@ -301,7 +301,8 @@ static int bond_changelink(struct net_device *bond_dev,
                int lp_interval =
                        nla_get_u32(data[IFLA_BOND_LP_INTERVAL]);
 
-               err = bond_option_lp_interval_set(bond, lp_interval);
+               bond_opt_initval(&newval, lp_interval);
+               err = __bond_opt_set(bond, BOND_OPT_LP_INTERVAL, &newval);
                if (err)
                        return err;
        }
index 1373093d1c6ac6bcb1d6c3c08b8a5eabb42cbfdf..60d7001398118d45e19678b4914b8d837e0aec1c 100644 (file)
@@ -118,6 +118,11 @@ static struct bond_opt_value bond_resend_igmp_tbl[] = {
        { NULL,      -1,  0}
 };
 
+static struct bond_opt_value bond_lp_interval_tbl[] = {
+       { "minval",  1,       BOND_VALFLAG_MIN | BOND_VALFLAG_DEFAULT},
+       { "maxval",  INT_MAX, BOND_VALFLAG_MAX},
+};
+
 static struct bond_option bond_opts[] = {
        [BOND_OPT_MODE] = {
                .id = BOND_OPT_MODE,
@@ -288,6 +293,13 @@ static struct bond_option bond_opts[] = {
                .values = bond_resend_igmp_tbl,
                .set = bond_option_resend_igmp_set
        },
+       [BOND_OPT_LP_INTERVAL] = {
+               .id = BOND_OPT_LP_INTERVAL,
+               .name = "lp_interval",
+               .desc = "The number of seconds between instances where the bonding driver sends learning packets to each slave's peer switch",
+               .values = bond_lp_interval_tbl,
+               .set = bond_option_lp_interval_set
+       },
        { }
 };
 
@@ -1101,15 +1113,10 @@ int bond_option_min_links_set(struct bonding *bond,
        return 0;
 }
 
-int bond_option_lp_interval_set(struct bonding *bond, int lp_interval)
+int bond_option_lp_interval_set(struct bonding *bond,
+                               struct bond_opt_value *newval)
 {
-       if (lp_interval <= 0) {
-               pr_err("%s: lp_interval must be between 1 and %d\n",
-                      bond->dev->name, INT_MAX);
-               return -EINVAL;
-       }
-
-       bond->params.lp_interval = lp_interval;
+       bond->params.lp_interval = newval->value;
 
        return 0;
 }
index f0c2cbb0347890e22d068ca2bfa3b066ddaf7384..eb3a773cb5a895a5055788783f0c32f408d7821e 100644 (file)
@@ -60,6 +60,7 @@ enum {
        BOND_OPT_QUEUE_ID,
        BOND_OPT_ALL_SLAVES_ACTIVE,
        BOND_OPT_RESEND_IGMP,
+       BOND_OPT_LP_INTERVAL,
        BOND_OPT_LAST
 };
 
@@ -162,4 +163,6 @@ 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);
+int bond_option_lp_interval_set(struct bonding *bond,
+                               struct bond_opt_value *newval);
 #endif /* _BOND_OPTIONS_H */
index 1693ebd7dcbe78743144c0bf189dbd5a38bb1eff..f7bc7917739ecc38d7434797b2bb3589a7519b25 100644 (file)
@@ -1070,22 +1070,12 @@ static ssize_t bonding_store_lp_interval(struct device *d,
                                         const char *buf, size_t count)
 {
        struct bonding *bond = to_bond(d);
-       int new_value, ret;
-
-       if (sscanf(buf, "%d", &new_value) != 1) {
-               pr_err("%s: no lp interval value specified.\n",
-                       bond->dev->name);
-               return -EINVAL;
-       }
-
-       if (!rtnl_trylock())
-               return restart_syscall();
+       int ret;
 
-       ret = bond_option_lp_interval_set(bond, new_value);
+       ret = bond_opt_tryset_rtnl(bond, BOND_OPT_LP_INTERVAL, (char *)buf);
        if (!ret)
                ret = count;
 
-       rtnl_unlock();
        return ret;
 }
 
index 1683e400768ca74a7656855c7ead2aa0b7d8de2b..8032e07fec0e52eab2d757a8a011bcdde90afb0d 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_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);
 const char *bond_slave_link_status(s8 link);