netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ding Tianhong <dingtianhong@huawei.com>
To: Jay Vosburgh <fubar@us.ibm.com>,
	Veaceslav Falico <vfalico@redhat.com>,
	"David S. Miller" <davem@davemloft.net>,
	Netdev <netdev@vger.kernel.org>
Subject: [PATCH net-next 2/4] bonding: do not save non-existent device to bond primary in check params
Date: Thu, 9 Jan 2014 19:20:39 +0800	[thread overview]
Message-ID: <52CE8607.1050103@huawei.com> (raw)

When install the bonding, the primay will be use to distinguish
the primary slave for ab, alb and tlb mode, but it is meanless
to save a no existed device, so add check for it.

Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
---
 drivers/net/bonding/bond_main.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index de646e2..651c5fd 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4246,13 +4246,19 @@ static int bond_check_params(struct bond_params *params)
 		pr_debug("Warning: either miimon or arp_interval and arp_ip_target module parameters must be specified, otherwise bonding will not detect link failures! see bonding.txt for details.\n");
 	}
 
-	if (primary && !USES_PRIMARY(bond_mode)) {
-		/* currently, using a primary only makes sense
-		 * in active backup, TLB or ALB modes
-		 */
-		pr_warning("Warning: %s primary device specified but has no effect in %s mode\n",
-			   primary, bond_mode_name(bond_mode));
-		primary = NULL;
+	if (primary) {
+		if (!__dev_get_by_name(&init_net, primary)) {
+			pr_warn("Warning: %s primary device is not exist\n",
+				primary);
+			primary = NULL;
+		} else if (!USES_PRIMARY(bond_mode)) {
+			/* currently, using a primary only makes sense
+			 * in active backup, TLB or ALB modes
+			 */
+			pr_warn("Warning: %s primary device specified but has no effect in %s mode\n",
+				primary, bond_mode_name(bond_mode));
+			primary = NULL;
+		}
 	}
 
 	if (primary && primary_reselect) {
-- 
1.8.0

             reply	other threads:[~2014-01-09 11:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-09 11:20 Ding Tianhong [this message]
2014-01-09 11:48 ` [PATCH net-next 2/4] bonding: do not save non-existent device to bond primary in check params Veaceslav Falico

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=52CE8607.1050103@huawei.com \
    --to=dingtianhong@huawei.com \
    --cc=davem@davemloft.net \
    --cc=fubar@us.ibm.com \
    --cc=netdev@vger.kernel.org \
    --cc=vfalico@redhat.com \
    /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).