public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Jiri Bohac <jbohac@suse•cz>
To: Jay Vosburgh <fubar@us•ibm.com>
Cc: netdev@vger•kernel.org
Subject: [PATCH] bonding: disallow enslaving a bond to itself
Date: Wed, 26 Feb 2014 18:20:13 +0100	[thread overview]
Message-ID: <20140226172013.GA18145@midget.suse.cz> (raw)

Enslaving a bond to itself leads to an endless loop and hangs the kernel.

Signed-off-by: Jiri Bohac <jbohac@suse•cz>

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 1c6104d..8f028ac 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1193,6 +1193,11 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
 		return -EBUSY;
 	}
 
+	if (bond_dev == slave_dev) {
+		pr_err("%s: cannot enslave bond to itself.\n", bond_dev->name);
+		return -EPERM;
+	}
+
 	/* vlan challenged mutual exclusion */
 	/* no need to lock since we're protected by rtnl_lock */
 	if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) {
-- 
Jiri Bohac <jbohac@suse•cz>
SUSE Labs, SUSE CZ

             reply	other threads:[~2014-02-26 17:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-26 17:20 Jiri Bohac [this message]
2014-02-27  1:30 ` [PATCH] bonding: disallow enslaving a bond to itself Ding Tianhong
2014-02-27  3:37 ` David Miller

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=20140226172013.GA18145@midget.suse.cz \
    --to=jbohac@suse$(echo .)cz \
    --cc=fubar@us$(echo .)ibm.com \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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