* [PATCH net-next 1/2] net: add NETDEV_PRECHANGEMTU to notify before mtu change happens
@ 2014-01-15 23:02 Veaceslav Falico
2014-01-15 23:02 ` [PATCH net-next 2/2] team: block mtu change before it happens via NETDEV_PRECHANGEMTU Veaceslav Falico
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Veaceslav Falico @ 2014-01-15 23:02 UTC (permalink / raw)
To: netdev
Cc: Veaceslav Falico, David S. Miller, Jiri Pirko, Eric Dumazet,
Nicolas Dichtel, Cong Wang
Currently, if a device changes its mtu, first the change happens (invloving
all the side effects), and after that the NETDEV_CHANGEMTU is sent so that
other devices can catch up with the new mtu. However, if they return
NOTIFY_BAD, then the change is reverted and error returned.
This is a really long and costy operation (sometimes). To fix this, add
NETDEV_PRECHANGEMTU notification which is called prior to any change
actually happening, and if any callee returns NOTIFY_BAD - the change is
aborted. This way we're skipping all the playing with apply/revert the mtu.
CC: "David S. Miller" <davem@davemloft.net>
CC: Jiri Pirko <jiri@resnulli.us>
CC: Eric Dumazet <edumazet@google.com>
CC: Nicolas Dichtel <nicolas.dichtel@6wind.com>
CC: Cong Wang <amwang@redhat.com>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
include/linux/netdevice.h | 3 ++-
net/core/dev.c | 5 +++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 5c88ab1..6fa2c91 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1718,7 +1718,7 @@ struct pcpu_sw_netstats {
#define NETDEV_CHANGE 0x0004 /* Notify device state change */
#define NETDEV_REGISTER 0x0005
#define NETDEV_UNREGISTER 0x0006
-#define NETDEV_CHANGEMTU 0x0007
+#define NETDEV_CHANGEMTU 0x0007 /* notify after mtu change happened */
#define NETDEV_CHANGEADDR 0x0008
#define NETDEV_GOING_DOWN 0x0009
#define NETDEV_CHANGENAME 0x000A
@@ -1734,6 +1734,7 @@ struct pcpu_sw_netstats {
#define NETDEV_JOIN 0x0014
#define NETDEV_CHANGEUPPER 0x0015
#define NETDEV_RESEND_IGMP 0x0016
+#define NETDEV_PRECHANGEMTU 0x0017 /* notify before mtu change happened */
int register_netdevice_notifier(struct notifier_block *nb);
int unregister_netdevice_notifier(struct notifier_block *nb);
diff --git a/net/core/dev.c b/net/core/dev.c
index 20c834e..cb78923 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5360,6 +5360,11 @@ int dev_set_mtu(struct net_device *dev, int new_mtu)
if (!netif_device_present(dev))
return -ENODEV;
+ err = call_netdevice_notifiers(NETDEV_PRECHANGEMTU, dev);
+ err = notifier_to_errno(err);
+ if (err)
+ return err;
+
orig_mtu = dev->mtu;
err = __dev_set_mtu(dev, new_mtu);
--
1.8.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next 2/2] team: block mtu change before it happens via NETDEV_PRECHANGEMTU
2014-01-15 23:02 [PATCH net-next 1/2] net: add NETDEV_PRECHANGEMTU to notify before mtu change happens Veaceslav Falico
@ 2014-01-15 23:02 ` Veaceslav Falico
2014-01-16 7:18 ` Jiri Pirko
2014-01-17 1:16 ` David Miller
2014-01-16 7:18 ` [PATCH net-next 1/2] net: add NETDEV_PRECHANGEMTU to notify before mtu change happens Jiri Pirko
2014-01-17 1:16 ` David Miller
2 siblings, 2 replies; 6+ messages in thread
From: Veaceslav Falico @ 2014-01-15 23:02 UTC (permalink / raw)
To: netdev; +Cc: Veaceslav Falico, Jiri Pirko
Now it catches the NETDEV_CHANGEMTU notification, which is signaled after
the actual change happened on the device, and returns NOTIFY_BAD, so that
the change on the device is reverted.
This might be quite costly and messy, so use the new NETDEV_PRECHANGEMTU to
catch the MTU change before the actual change happens and signal that it's
forbidden to do it.
CC: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
drivers/net/team/team.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index b75ae5b..dff24e3 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -2851,7 +2851,7 @@ static int team_device_event(struct notifier_block *unused,
case NETDEV_FEAT_CHANGE:
team_compute_features(port->team);
break;
- case NETDEV_CHANGEMTU:
+ case NETDEV_PRECHANGEMTU:
/* Forbid to change mtu of underlaying device */
return NOTIFY_BAD;
case NETDEV_PRE_TYPE_CHANGE:
--
1.8.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 1/2] net: add NETDEV_PRECHANGEMTU to notify before mtu change happens
2014-01-15 23:02 [PATCH net-next 1/2] net: add NETDEV_PRECHANGEMTU to notify before mtu change happens Veaceslav Falico
2014-01-15 23:02 ` [PATCH net-next 2/2] team: block mtu change before it happens via NETDEV_PRECHANGEMTU Veaceslav Falico
@ 2014-01-16 7:18 ` Jiri Pirko
2014-01-17 1:16 ` David Miller
2 siblings, 0 replies; 6+ messages in thread
From: Jiri Pirko @ 2014-01-16 7:18 UTC (permalink / raw)
To: Veaceslav Falico
Cc: netdev, David S. Miller, Eric Dumazet, Nicolas Dichtel, Cong Wang
Thu, Jan 16, 2014 at 12:02:18AM CET, vfalico@redhat.com wrote:
>Currently, if a device changes its mtu, first the change happens (invloving
>all the side effects), and after that the NETDEV_CHANGEMTU is sent so that
>other devices can catch up with the new mtu. However, if they return
>NOTIFY_BAD, then the change is reverted and error returned.
>
>This is a really long and costy operation (sometimes). To fix this, add
>NETDEV_PRECHANGEMTU notification which is called prior to any change
>actually happening, and if any callee returns NOTIFY_BAD - the change is
>aborted. This way we're skipping all the playing with apply/revert the mtu.
>
>CC: "David S. Miller" <davem@davemloft.net>
>CC: Jiri Pirko <jiri@resnulli.us>
>CC: Eric Dumazet <edumazet@google.com>
>CC: Nicolas Dichtel <nicolas.dichtel@6wind.com>
>CC: Cong Wang <amwang@redhat.com>
>Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
>---
> include/linux/netdevice.h | 3 ++-
> net/core/dev.c | 5 +++++
> 2 files changed, 7 insertions(+), 1 deletion(-)
>
>diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
>index 5c88ab1..6fa2c91 100644
>--- a/include/linux/netdevice.h
>+++ b/include/linux/netdevice.h
>@@ -1718,7 +1718,7 @@ struct pcpu_sw_netstats {
> #define NETDEV_CHANGE 0x0004 /* Notify device state change */
> #define NETDEV_REGISTER 0x0005
> #define NETDEV_UNREGISTER 0x0006
>-#define NETDEV_CHANGEMTU 0x0007
>+#define NETDEV_CHANGEMTU 0x0007 /* notify after mtu change happened */
> #define NETDEV_CHANGEADDR 0x0008
> #define NETDEV_GOING_DOWN 0x0009
> #define NETDEV_CHANGENAME 0x000A
>@@ -1734,6 +1734,7 @@ struct pcpu_sw_netstats {
> #define NETDEV_JOIN 0x0014
> #define NETDEV_CHANGEUPPER 0x0015
> #define NETDEV_RESEND_IGMP 0x0016
>+#define NETDEV_PRECHANGEMTU 0x0017 /* notify before mtu change happened */
>
> int register_netdevice_notifier(struct notifier_block *nb);
> int unregister_netdevice_notifier(struct notifier_block *nb);
>diff --git a/net/core/dev.c b/net/core/dev.c
>index 20c834e..cb78923 100644
>--- a/net/core/dev.c
>+++ b/net/core/dev.c
>@@ -5360,6 +5360,11 @@ int dev_set_mtu(struct net_device *dev, int new_mtu)
> if (!netif_device_present(dev))
> return -ENODEV;
>
>+ err = call_netdevice_notifiers(NETDEV_PRECHANGEMTU, dev);
>+ err = notifier_to_errno(err);
>+ if (err)
>+ return err;
>+
> orig_mtu = dev->mtu;
> err = __dev_set_mtu(dev, new_mtu);
>
>--
>1.8.4
>
I like this
Acked-by: Jiri Pirko <jiri@resnulli.us>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 2/2] team: block mtu change before it happens via NETDEV_PRECHANGEMTU
2014-01-15 23:02 ` [PATCH net-next 2/2] team: block mtu change before it happens via NETDEV_PRECHANGEMTU Veaceslav Falico
@ 2014-01-16 7:18 ` Jiri Pirko
2014-01-17 1:16 ` David Miller
1 sibling, 0 replies; 6+ messages in thread
From: Jiri Pirko @ 2014-01-16 7:18 UTC (permalink / raw)
To: Veaceslav Falico; +Cc: netdev
Thu, Jan 16, 2014 at 12:02:19AM CET, vfalico@redhat.com wrote:
>Now it catches the NETDEV_CHANGEMTU notification, which is signaled after
>the actual change happened on the device, and returns NOTIFY_BAD, so that
>the change on the device is reverted.
>
>This might be quite costly and messy, so use the new NETDEV_PRECHANGEMTU to
>catch the MTU change before the actual change happens and signal that it's
>forbidden to do it.
>
>CC: Jiri Pirko <jiri@resnulli.us>
>Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
>---
> drivers/net/team/team.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
>index b75ae5b..dff24e3 100644
>--- a/drivers/net/team/team.c
>+++ b/drivers/net/team/team.c
>@@ -2851,7 +2851,7 @@ static int team_device_event(struct notifier_block *unused,
> case NETDEV_FEAT_CHANGE:
> team_compute_features(port->team);
> break;
>- case NETDEV_CHANGEMTU:
>+ case NETDEV_PRECHANGEMTU:
> /* Forbid to change mtu of underlaying device */
> return NOTIFY_BAD;
> case NETDEV_PRE_TYPE_CHANGE:
>--
>1.8.4
>
Acked-by: Jiri Pirko <jiri@resnulli.us>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 1/2] net: add NETDEV_PRECHANGEMTU to notify before mtu change happens
2014-01-15 23:02 [PATCH net-next 1/2] net: add NETDEV_PRECHANGEMTU to notify before mtu change happens Veaceslav Falico
2014-01-15 23:02 ` [PATCH net-next 2/2] team: block mtu change before it happens via NETDEV_PRECHANGEMTU Veaceslav Falico
2014-01-16 7:18 ` [PATCH net-next 1/2] net: add NETDEV_PRECHANGEMTU to notify before mtu change happens Jiri Pirko
@ 2014-01-17 1:16 ` David Miller
2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2014-01-17 1:16 UTC (permalink / raw)
To: vfalico; +Cc: netdev, jiri, edumazet, nicolas.dichtel, amwang
From: Veaceslav Falico <vfalico@redhat.com>
Date: Thu, 16 Jan 2014 00:02:18 +0100
> Currently, if a device changes its mtu, first the change happens (invloving
> all the side effects), and after that the NETDEV_CHANGEMTU is sent so that
> other devices can catch up with the new mtu. However, if they return
> NOTIFY_BAD, then the change is reverted and error returned.
>
> This is a really long and costy operation (sometimes). To fix this, add
> NETDEV_PRECHANGEMTU notification which is called prior to any change
> actually happening, and if any callee returns NOTIFY_BAD - the change is
> aborted. This way we're skipping all the playing with apply/revert the mtu.
>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: Jiri Pirko <jiri@resnulli.us>
> CC: Eric Dumazet <edumazet@google.com>
> CC: Nicolas Dichtel <nicolas.dichtel@6wind.com>
> CC: Cong Wang <amwang@redhat.com>
> Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
Applied.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 2/2] team: block mtu change before it happens via NETDEV_PRECHANGEMTU
2014-01-15 23:02 ` [PATCH net-next 2/2] team: block mtu change before it happens via NETDEV_PRECHANGEMTU Veaceslav Falico
2014-01-16 7:18 ` Jiri Pirko
@ 2014-01-17 1:16 ` David Miller
1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2014-01-17 1:16 UTC (permalink / raw)
To: vfalico; +Cc: netdev, jiri
From: Veaceslav Falico <vfalico@redhat.com>
Date: Thu, 16 Jan 2014 00:02:19 +0100
> Now it catches the NETDEV_CHANGEMTU notification, which is signaled after
> the actual change happened on the device, and returns NOTIFY_BAD, so that
> the change on the device is reverted.
>
> This might be quite costly and messy, so use the new NETDEV_PRECHANGEMTU to
> catch the MTU change before the actual change happens and signal that it's
> forbidden to do it.
>
> CC: Jiri Pirko <jiri@resnulli.us>
> Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
Also applied, nice work.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-01-17 1:16 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-15 23:02 [PATCH net-next 1/2] net: add NETDEV_PRECHANGEMTU to notify before mtu change happens Veaceslav Falico
2014-01-15 23:02 ` [PATCH net-next 2/2] team: block mtu change before it happens via NETDEV_PRECHANGEMTU Veaceslav Falico
2014-01-16 7:18 ` Jiri Pirko
2014-01-17 1:16 ` David Miller
2014-01-16 7:18 ` [PATCH net-next 1/2] net: add NETDEV_PRECHANGEMTU to notify before mtu change happens Jiri Pirko
2014-01-17 1:16 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox