Skip to content

Commit 5055376

Browse files
MiaoheLindavem330
authored andcommitted
net: vrf: Fix ping failed when vrf mtu is set to 0
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 IPV6_MIN_MTU, 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 ETH_MAX_MTU. 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: ad49bc6 ("net: vrf: remove MTU limits for vrf device") Signed-off-by: Miaohe Lin <[email protected]> Reviewed-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b959ecf commit 5055376

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/net/vrf.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,8 +1275,12 @@ static void vrf_setup(struct net_device *dev)
12751275
dev->priv_flags |= IFF_NO_QUEUE;
12761276
dev->priv_flags |= IFF_NO_RX_HANDLER;
12771277

1278-
dev->min_mtu = 0;
1279-
dev->max_mtu = 0;
1278+
/* VRF devices do not care about MTU, but if the MTU is set
1279+
* too low then the ipv4 and ipv6 protocols are disabled
1280+
* which breaks networking.
1281+
*/
1282+
dev->min_mtu = IPV6_MIN_MTU;
1283+
dev->max_mtu = ETH_MAX_MTU;
12801284
}
12811285

12821286
static int vrf_validate(struct nlattr *tb[], struct nlattr *data[],

0 commit comments

Comments
 (0)