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 4/6] netdev: allow rejecting MTU changes from notifiers
Date: Fri, 17 Oct 2008 21:32:56 -0700 [thread overview]
Message-ID: <20081018043323.642235776@vyatta.com> (raw)
In-Reply-To: 20081018043252.968940967@vyatta.com
[-- Attachment #1: dev-mtu-rollback.patch --]
[-- Type: text/plain, Size: 1406 bytes --]
This patch allows notifiers to reject changes to MTU, and then does rollback
same way change name does).
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/net/core/dev.c 2008-10-17 18:59:11.000000000 -0700
+++ b/net/core/dev.c 2008-10-17 21:22:30.000000000 -0700
@@ -3453,9 +3453,10 @@ int dev_change_flags(struct net_device *
*/
int dev_set_mtu(struct net_device *dev, int new_mtu)
{
- int err;
+ int ret, err = 0;
+ int old_mtu = dev->mtu;
- if (new_mtu == dev->mtu)
+ if (new_mtu == old_mtu)
return 0;
/* MTU must be positive. */
@@ -3465,13 +3466,31 @@ int dev_set_mtu(struct net_device *dev,
if (!netif_device_present(dev))
return -ENODEV;
- err = 0;
- if (dev->change_mtu)
- err = dev->change_mtu(dev, new_mtu);
- else
+rollback:
+ if (dev->change_mtu) {
+ ret = dev->change_mtu(dev, new_mtu);
+ if (ret)
+ return ret;
+ } else
dev->mtu = new_mtu;
- if (!err && dev->flags & IFF_UP)
- call_netdevice_notifiers(NETDEV_CHANGEMTU, dev);
+
+ if (!err && (dev->flags & IFF_UP)) {
+ ret = call_netdevice_notifiers(NETDEV_CHANGEMTU, dev);
+ ret = notifier_to_errno(ret);
+ printk(KERN_DEBUG "dev_set_mtu notifier ret %d\n", ret);
+
+ if (ret) {
+ if (err) {
+ printk(KERN_ERR "%s: mtu rollback failed: %d\n",
+ dev->name, ret);
+ } else {
+ err = ret;
+ new_mtu = old_mtu;
+ goto rollback;
+ }
+ }
+
+ }
return err;
}
--
next prev parent reply other threads:[~2008-10-18 4:36 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 ` Stephen Hemminger [this message]
2008-10-18 4:32 ` [PATCH 5/6] bonding: prevent MTU changes in slave devices Stephen Hemminger
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.642235776@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.