Skip to contentSkip to conversation

net: vrf: Fix ping failed when vrf mtu is set to 0

PATCH Superseded linmiaohe 2 participants 3 messages Apr 7, 2019 – Apr 8, 2019

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

linmiaohe

author
#0 lore raw

PATCH v2 1/1 net: vrf: Fix ping failed when vrf mtu is set to 0

From: Miaohe Lin <[email protected]>

When the mtu of a vrf device is set to 0, it would cause ping failed. So I think we should limit vrf mtu in a reasonable range to solve this problem. I set dev->min_mtu to 1280, so it will works for both ipv4 and ipv6. And if dev->max_mtu still be 0 can be confusing, so I set dev->max_mtu to 0xFFFFU.

Here is the reproduce step:

1.Config vrf interface and set mtu to 0:
3: enp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master vrf1 state UP mode DEFAULT group default qlen 1000

    link/ether 52:54:00:9e:dd:c1 brd ff:ff:ff:ff:ff:ff

2.Ping peer:
3: enp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master vrf1 state UP group default qlen 1000

    link/ether 52:54:00:9e:dd:c1 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.1/16 scope global enp4s0
       valid_lft forever preferred_lft forever

connect: Network is unreachable

3.Set mtu to default value, ping works:
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data. 64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=1.88 ms

Fixes ad49bc6361ca2 ("net: vrf: remove MTU limits for vrf device")

---
V1->V2:
- fix patch commit message
- adjust to work for ipv6

 drivers/net/vrf.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/net/vrf.c +8 -2
index 7c1430ed0244..4d35d37f225a 100644
@@ -43,6 +43,12 @@
 
 #define FIB_RULE_PREF  1000       /* default preference for FIB rules */
 
+/* The MTU is really irrelevant for VRF except for odd cases, so limit it
+ * to a reasonable range which both works for IPV4 and IPV6.
+ */
+#define VRF_MIN_MTU	1280      /* same as IPV6_MIN_MTU */
+#define VRF_MAX_MTU	0xFFFFU   /* same as IP_MAX_MTU */
+
 static unsigned int vrf_net_id;
 
 struct net_vrf {
@@ -1274,8 +1280,8 @@ static void vrf_setup(struct net_device *dev)
 	/* default to no qdisc; user can add if desired */
 	dev->priv_flags |= IFF_NO_QUEUE;
 
-	dev->min_mtu = 0;
-	dev->max_mtu = 0;
+	dev->min_mtu = VRF_MIN_MTU;
+	dev->max_mtu = VRF_MAX_MTU;
 }
 
 static int vrf_validate(struct nlattr *tb[], struct nlattr *data[],
Signature · 1 line
2.19.1
#1 lore raw

drivers/net/vrf.c line 50

Quoted 13 lines · linmiaohe
drivers/net/vrf.c +5 -0
index 7c1430ed0244..4d35d37f225a 100644
@@ -43,6 +43,12 @@
 
 #define FIB_RULE_PREF  1000       /* default preference for FIB rules */
 
+/* The MTU is really irrelevant for VRF except for odd cases, so limit it
+ * to a reasonable range which both works for IPV4 and IPV6.
+ */
+#define VRF_MIN_MTU	1280      /* same as IPV6_MIN_MTU */
+#define VRF_MAX_MTU	0xFFFFU   /* same as IP_MAX_MTU */

Since VRF does not care about MTU, there is no reason for VRF specific macros.

drivers/net/vrf.c static void vrf_setup(struct net_device *dev) · line 1284

Quoted 12 lines
drivers/net/vrf.c +3 -2
+
 static unsigned int vrf_net_id;
 
 struct net_vrf {
@@ -1274,8 +1280,8 @@ static void vrf_setup(struct net_device *dev)
 	/* default to no qdisc; user can add if desired */
 	dev->priv_flags |= IFF_NO_QUEUE;
 
-	dev->min_mtu = 0;
-	dev->max_mtu = 0;
+	dev->min_mtu = VRF_MIN_MTU;
+	dev->max_mtu = VRF_MAX_MTU;

Set these to IPV6_MIN_MTU and ETH_MAX_MTU and add a comment that VRF devices do not care about MTU, but if the MTU is set too low then the ipv4 and ipv6 protocols are disabled which breaks networking.

author
#2 lore raw
Quoted 26 lines · David Ahern

drivers/net/vrf.c line 50

Quoted 13 lines · linmiaohe
drivers/net/vrf.c +5 -0
index 7c1430ed0244..4d35d37f225a 100644
@@ -43,6 +43,12 @@
 
 #define FIB_RULE_PREF  1000       /* default preference for FIB rules */
 
+/* The MTU is really irrelevant for VRF except for odd cases, so limit it
+ * to a reasonable range which both works for IPV4 and IPV6.
+ */
+#define VRF_MIN_MTU	1280      /* same as IPV6_MIN_MTU */
+#define VRF_MAX_MTU	0xFFFFU   /* same as IP_MAX_MTU */

Since VRF does not care about MTU, there is no reason for VRF specific macros.

Quoted 8 lines
drivers/net/vrf.c +1 -0
+
 static unsigned int vrf_net_id;
 
 struct net_vrf {
@@ -1274,8 +1280,8 @@ static void vrf_setup(struct net_device *dev)
 	/* default to no qdisc; user can add if desired */
 	dev->priv_flags |= IFF_NO_QUEUE;
 
Quoted 10 lines

drivers/net/vrf.c static void vrf_setup(struct net_device *dev) · line 1284

Quoted 4 lines
drivers/net/vrf.c +2 -2
-	dev->min_mtu = 0;
-	dev->max_mtu = 0;
+	dev->min_mtu = VRF_MIN_MTU;
+	dev->max_mtu = VRF_MAX_MTU;

Set these to IPV6_MIN_MTU and ETH_MAX_MTU and add a comment that VRF devices do not care about MTU, but if the MTU is set too low then the ipv4 and ipv6 protocols are disabled which breaks networking.

Thanks a lot for your advice. I will send v3 latter.