netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: vlan: allow vlan device MTU change follow real device from smaller to bigger
@ 2022-02-21 12:46 Ziyang Xuan
  2022-02-21 15:43 ` Eric Dumazet
  0 siblings, 1 reply; 17+ messages in thread
From: Ziyang Xuan @ 2022-02-21 12:46 UTC (permalink / raw)
  To: davem, kuba, netdev; +Cc: edumazet, vvs, keescook, linux-kernel

vlan device MTU can only follow real device change from bigger to smaller
but from smaller to bigger under the premise of vlan device MTU not exceed
the real device MTU.

This issue can be seen using the following commands:

ip link add link eth1 dev eth1.100 type vlan id 100
ip link set eth1 mtu 256
ip link set eth1 mtu 1500
ip link show

Modify to allow vlan device follow real device MTU change from smaller
to bigger when user has not configured vlan device MTU which is not
equal to real device MTU. That also ensure user configuration has higher
priority.

Fixes: 2e477c9bd2bb ("vlan: Propagate physical MTU changes")
Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
---
 net/8021q/vlan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 788076b002b3..7de4f462525a 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -361,6 +361,7 @@ static int __vlan_device_event(struct net_device *dev, unsigned long event)
 static int vlan_device_event(struct notifier_block *unused, unsigned long event,
 			     void *ptr)
 {
+	unsigned int orig_mtu = ((struct netdev_notifier_info_ext *)ptr)->ext.mtu;
 	struct netlink_ext_ack *extack = netdev_notifier_info_to_extack(ptr);
 	struct net_device *dev = netdev_notifier_info_to_dev(ptr);
 	struct vlan_group *grp;
@@ -419,7 +420,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
 
 	case NETDEV_CHANGEMTU:
 		vlan_group_for_each_dev(grp, i, vlandev) {
-			if (vlandev->mtu <= dev->mtu)
+			if (vlandev->mtu <= dev->mtu && vlandev->mtu != orig_mtu)
 				continue;
 
 			dev_set_mtu(vlandev, dev->mtu);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2022-02-23 19:46 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-21 12:46 [PATCH net] net: vlan: allow vlan device MTU change follow real device from smaller to bigger Ziyang Xuan
2022-02-21 15:43 ` Eric Dumazet
2022-02-22  0:58   ` Herbert Xu
2022-02-22  2:06     ` Ziyang Xuan (William)
2022-02-22  2:27       ` Eric Dumazet
2022-02-22  7:31         ` Ziyang Xuan (William)
2022-02-23  1:55           ` Ziyang Xuan (William)
2022-02-22 10:37         ` Guillaume Nault
2022-02-22 23:28           ` Jakub Kicinski
2022-02-23 11:26             ` Guillaume Nault
2022-02-23 15:17               ` Stephen Hemminger
2022-02-23 16:34                 ` Guillaume Nault
2022-02-23 16:03               ` Jakub Kicinski
2022-02-23 16:58                 ` Guillaume Nault
2022-02-23 17:37                   ` Jakub Kicinski
2022-02-23 19:46                     ` Guillaume Nault
2022-02-23 17:05                 ` Stephen Hemminger

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).