Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vrf: fix maximum MTU

My initial goal was to fix the default MTU, which is set to 65536, ie above
the maximum defined in the driver: 65535 (ETH_MAX_MTU).

In fact, it's seems more consistent, wrt min_mtu, to set the max_mtu to
IP6_MAX_MTU (65535 + sizeof(struct ipv6hdr)) and use it by default.

Let's also, for consistency, set the mtu in vrf_setup(). This function
calls ether_setup(), which set the mtu to 1500. Thus, the whole mtu config
is done in the same function.

Before the patch:
$ ip link add blue type vrf table 1234
$ ip link list blue
9: blue: <NOARP,MASTER> mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether fa:f5:27:70:24:2a brd ff:ff:ff:ff:ff:ff
$ ip link set dev blue mtu 65535
$ ip link set dev blue mtu 65536
Error: mtu greater than device maximum.

Fixes: 5055376a3b44 ("net: vrf: Fix ping failed when vrf mtu is set to 0")
CC: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Nicolas Dichtel and committed by
David S. Miller
9bb392f6 d439aa33

+2 -4
+2 -4
drivers/net/vrf.c
··· 1183 1183 1184 1184 dev->flags = IFF_MASTER | IFF_NOARP; 1185 1185 1186 - /* MTU is irrelevant for VRF device; set to 64k similar to lo */ 1187 - dev->mtu = 64 * 1024; 1188 - 1189 1186 /* similarly, oper state is irrelevant; set to up to avoid confusion */ 1190 1187 dev->operstate = IF_OPER_UP; 1191 1188 netdev_lockdep_set_classes(dev); ··· 1682 1685 * which breaks networking. 1683 1686 */ 1684 1687 dev->min_mtu = IPV6_MIN_MTU; 1685 - dev->max_mtu = ETH_MAX_MTU; 1688 + dev->max_mtu = IP6_MAX_MTU; 1689 + dev->mtu = dev->max_mtu; 1686 1690 } 1687 1691 1688 1692 static int vrf_validate(struct nlattr *tb[], struct nlattr *data[],