netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikolay Aleksandrov <nikolay@redhat.com>
To: netdev@vger.kernel.org
Cc: Nikolay Aleksandrov <nikolay@redhat.com>
Subject: [PATCH net-next 13/25] bonding: convert min_links to use the new option API
Date: Tue, 21 Jan 2014 15:55:02 +0100	[thread overview]
Message-ID: <1390316114-17815-14-git-send-email-nikolay@redhat.com> (raw)
In-Reply-To: <1390316114-17815-1-git-send-email-nikolay@redhat.com>

This patch adds the necessary changes so min_links would use
the new bonding option API.

Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
---
 drivers/net/bonding/bond_netlink.c |  3 ++-
 drivers/net/bonding/bond_options.c | 16 ++++++++++++----
 drivers/net/bonding/bond_options.h |  3 +++
 drivers/net/bonding/bond_sysfs.c   | 14 +-------------
 drivers/net/bonding/bonding.h      |  1 -
 5 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
index 7737a91..7eee1a0 100644
--- a/drivers/net/bonding/bond_netlink.c
+++ b/drivers/net/bonding/bond_netlink.c
@@ -286,7 +286,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;
 	}
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index 01cbc7f..2c392e8 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -165,6 +165,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
+	},
 	{ }
 };
 
@@ -991,11 +998,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;
 }
diff --git a/drivers/net/bonding/bond_options.h b/drivers/net/bonding/bond_options.h
index 7ee1a78..cc8edef 100644
--- a/drivers/net/bonding/bond_options.h
+++ b/drivers/net/bonding/bond_options.h
@@ -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 */
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 98288dc..81e0581 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -587,23 +587,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,
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 05f4aa0..cb18727 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -461,7 +461,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);
-- 
1.8.4.2

  parent reply	other threads:[~2014-01-21 14:55 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-21 14:54 [PATCH net-next 00/25] bonding: introduce new option API Nikolay Aleksandrov
2014-01-21 14:54 ` [PATCH net-next 01/25] bonding: add infrastructure for an " Nikolay Aleksandrov
2014-01-21 14:54 ` [PATCH net-next 02/25] bonding: convert mode setting to use the new " Nikolay Aleksandrov
2014-01-21 14:54 ` [PATCH net-next 03/25] bonding: convert packets_per_slave " Nikolay Aleksandrov
2014-01-22  7:25   ` Hannes Frederic Sowa
2014-01-22 13:09     ` Nikolay Aleksandrov
2014-01-21 14:54 ` [PATCH net-next 04/25] bonding: convert xmit_hash_policy " Nikolay Aleksandrov
2014-01-21 14:54 ` [PATCH net-next 05/25] bonding: convert arp_validate " Nikolay Aleksandrov
2014-01-21 14:54 ` [PATCH net-next 06/25] bonding: convert arp_all_targets " Nikolay Aleksandrov
2014-01-21 14:54 ` [PATCH net-next 07/25] bonding: convert fail_over_mac " Nikolay Aleksandrov
2014-01-21 14:54 ` [PATCH net-next 08/25] bonding: convert arp_interval " Nikolay Aleksandrov
2014-01-21 14:54 ` [PATCH net-next 09/25] bonding: convert arp_ip_target " Nikolay Aleksandrov
2014-01-21 14:54 ` [PATCH net-next 10/25] bonding: convert downdelay " Nikolay Aleksandrov
2014-01-21 14:55 ` [PATCH net-next 11/25] bonding: convert updelay " Nikolay Aleksandrov
2014-01-21 14:55 ` [PATCH net-next 12/25] bonding: convert lacp_rate " Nikolay Aleksandrov
2014-01-21 14:55 ` Nikolay Aleksandrov [this message]
2014-01-21 14:55 ` [PATCH net-next 14/25] bonding: convert ad_select " Nikolay Aleksandrov
2014-01-21 14:55 ` [PATCH net-next 15/25] bonding: convert num_peer_notif " Nikolay Aleksandrov
2014-01-21 14:55 ` [PATCH net-next 16/25] bonding: convert miimon " Nikolay Aleksandrov
2014-01-21 14:55 ` [PATCH net-next 17/25] bonding: convert primary " Nikolay Aleksandrov
2014-01-21 14:55 ` [PATCH net-next 18/25] bonding: convert primary_reselect " Nikolay Aleksandrov
2014-01-21 14:55 ` [PATCH net-next 19/25] bonding: convert use_carrier " Nikolay Aleksandrov
2014-01-21 14:55 ` [PATCH net-next 20/25] bonding: convert active_slave " Nikolay Aleksandrov
2014-01-21 14:55 ` [PATCH net-next 21/25] bonding: convert queue_id " Nikolay Aleksandrov
2014-01-21 14:55 ` [PATCH net-next 22/25] bonding: convert all_slaves_active " Nikolay Aleksandrov
2014-01-21 14:55 ` [PATCH net-next 23/25] bonding: convert resend_igmp " Nikolay Aleksandrov
2014-01-21 14:55 ` [PATCH net-next 24/25] bonding: convert lp_interval " Nikolay Aleksandrov
2014-01-21 14:55 ` [PATCH net-next 25/25] bonding: convert slaves " Nikolay Aleksandrov
2014-01-21 15:59 ` [PATCH net-next 00/25] bonding: introduce " Dan Williams
2014-01-21 16:06   ` Nikolay Aleksandrov
2014-01-21 21:51   ` Scott Feldman
2014-01-22  2:01 ` Ding Tianhong
2014-01-22 13:23   ` Nikolay Aleksandrov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1390316114-17815-14-git-send-email-nikolay@redhat.com \
    --to=nikolay@redhat.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).