netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: Jay Vousburgh <fubar@us.ibm.com>
Cc: bonding-devel@lists.sourceforge.net, netdev@vger.kernel.org
Subject: [PATCH 5/6] bonding: prevent MTU changes in slave devices
Date: Fri, 17 Oct 2008 21:32:57 -0700	[thread overview]
Message-ID: <20081018043323.724189700@vyatta.com> (raw)
In-Reply-To: 20081018043252.968940967@vyatta.com

[-- Attachment #1: bonding-mtu.patch --]
[-- Type: text/plain, Size: 1882 bytes --]

Check in bonding driver disallow changing MTU of one slave.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>


--- a/drivers/net/bonding/bond_main.c	2008-10-17 18:59:48.000000000 -0700
+++ b/drivers/net/bonding/bond_main.c	2008-10-17 19:02:58.000000000 -0700
@@ -3572,19 +3572,14 @@ static int bond_slave_netdev_event(unsig
 		}
 		break;
 	case NETDEV_CHANGEMTU:
-		/*
-		 * TODO: Should slaves be allowed to
-		 * independently alter their MTU?  For
-		 * an active-backup bond, slaves need
-		 * not be the same type of device, so
-		 * MTUs may vary.  For other modes,
-		 * slaves arguably should have the
-		 * same MTUs. To do this, we'd need to
-		 * take over the slave's change_mtu
-		 * function for the duration of their
-		 * servitude.
+		/* Can not independently change MTU of slave devices
+		 * NOTIFY_BAD causes EPERM in orignal change mtu call
+		 * NB: called on unwind as well
 		 */
+		if (slave_dev->mtu != bond_dev->mtu)
+			return NOTIFY_BAD;
 		break;
+
 	case NETDEV_CHANGENAME:
 		/*
 		 * TODO: handle changing the primary's name
@@ -4132,6 +4127,7 @@ static int bond_change_mtu(struct net_de
 {
 	struct bonding *bond = bond_dev->priv;
 	struct slave *slave, *stop_at;
+	int old_mtu = bond_dev->mtu;
 	int res = 0;
 	int i;
 
@@ -4152,7 +4148,7 @@ static int bond_change_mtu(struct net_de
 	 * list, but without holding a lock around the actual
 	 * call to the base driver.
 	 */
-
+	bond_dev->mtu = new_mtu;
 	bond_for_each_slave(bond, slave, i) {
 		dprintk("s %p s->p %p c_m %p\n", slave,
 			slave->prev, slave->dev->change_mtu);
@@ -4173,11 +4169,12 @@ static int bond_change_mtu(struct net_de
 		}
 	}
 
-	bond_dev->mtu = new_mtu;
 
 	return 0;
 
 unwind:
+	bond_dev->mtu = old_mtu;
+
 	/* unwind from head to the slave that failed */
 	stop_at = slave;
 	bond_for_each_slave_from_to(bond, slave, i, bond->first_slave, stop_at) {

-- 


  parent reply	other threads:[~2008-10-18  4:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-18  4:32 [PATCH 0/6] bonding related patches Stephen Hemminger
2008-10-18  4:32 ` [PATCH 1/6] bonding: allow configuration without sysfs Stephen Hemminger
2008-10-18  4:32 ` [PATCH 2/6] bonding: fix sparse warnings Stephen Hemminger
2008-10-18  4:32 ` [PATCH 3/6] bonding: event driven carrier detection Stephen Hemminger
2008-10-18  4:32 ` [PATCH 4/6] netdev: allow rejecting MTU changes from notifiers Stephen Hemminger
2008-10-18  4:32 ` Stephen Hemminger [this message]
2008-10-18  4:32 ` [PATCH 6/6] bonding: remove change name TODO Stephen Hemminger

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=20081018043323.724189700@vyatta.com \
    --to=shemminger@vyatta.com \
    --cc=bonding-devel@lists.sourceforge.net \
    --cc=fubar@us.ibm.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).