net-ipv6: on device mtu change do not add mtu to mtu-less routes
Subsystems (3)
PATCH 1/1 net-ipv6: on device mtu change do not add mtu to mtu-less routes
From: Maciej Żenczykowski <[email protected]>
Routes can specify an mtu explicitly or inherit the mtu from the underlying device - this inheritance is implemented in dst->ops->mtu handlers ip6_mtu() and ip6_blackhole_mtu().
Currently changing the mtu of a device adds mtu explicitly to routes using that device.
ie.
# ip link set dev lo mtu 65536 # ip -6 route add local 2000::1 dev lo # ip -6 route get 2000::1 local 2000::1 dev lo table local src ... metric 1024 pref medium
# ip link set dev lo mtu 65535 # ip -6 route get 2000::1 local 2000::1 dev lo table local src ... metric 1024 mtu 65535 pref medium
# ip link set dev lo mtu 65536 # ip -6 route get 2000::1 local 2000::1 dev lo table local src ... metric 1024 mtu 65536 pref medium
# ip -6 route del local 2000::1
After this patch the route entry no longer changes unless it already has an mtu. There is no need: this inheritance is already done in ip6_mtu()
# ip link set dev lo mtu 65536 # ip -6 route add local 2000::1 dev lo # ip -6 route add local 2000::2 dev lo mtu 2000 # ip -6 route get 2000::1; ip -6 route get 2000::2 local 2000::1 dev lo table local src ... metric 1024 pref medium local 2000::2 dev lo table local src ... metric 1024 mtu 2000 pref medium
# ip link set dev lo mtu 65535 # ip -6 route get 2000::1; ip -6 route get 2000::2 local 2000::1 dev lo table local src ... metric 1024 pref medium local 2000::2 dev lo table local src ... metric 1024 mtu 2000 pref medium
# ip link set dev lo mtu 1501 # ip -6 route get 2000::1; ip -6 route get 2000::2 local 2000::1 dev lo table local src ... metric 1024 pref medium local 2000::2 dev lo table local src ... metric 1024 mtu 1501 pref medium
# ip link set dev lo mtu 65536 # ip -6 route get 2000::1; ip -6 route get 2000::2 local 2000::1 dev lo table local src ... metric 1024 pref medium local 2000::2 dev lo table local src ... metric 1024 mtu 65536 pref medium
# ip -6 route del local 2000::1 # ip -6 route del local 2000::2
This is desirable because changing device mtu and then resetting it to the previous value shouldn't change the user visible routing table.
--- net/ipv6/route.c | 1 + 1 file changed, 1 insertion(+)
net/ipv6/route.c +1 -0
@@ -2758,6 +2758,7 @@ static int rt6_mtu_change_route(struct rt6_info *rt, void *p_arg)PMTU discouvery. */ if (rt->dst.dev == arg->dev && +dst_metric_raw (&rt->dst,RTAX_MTU ) && !dst_metric_locked (&rt->dst,RTAX_MTU )) {if (rt->rt6i_flags &RTF_CACHE ) {/* For RTF_CACHE with rt6i_pmtu == 0
Signature · 1 line
2.8.0.rc3.226.g39d4020
Quoted 68 lines · Maciej Żenczykowski
From: Maciej Żenczykowski <[email protected]>
Routes can specify an mtu explicitly or inherit the mtu from the underlying device - this inheritance is implemented in
dst->ops->mtuhandlersip6_mtu()andip6_blackhole_mtu().Currently changing the mtu of a device adds mtu explicitly to routes using that device.
ie.
# ip link set dev lo mtu 65536 # ip -6 route add local 2000::1 dev lo # ip -6 route get 2000::1 local 2000::1 dev lo table local src ... metric 1024 pref medium# ip link set dev lo mtu 65535 # ip -6 route get 2000::1 local 2000::1 dev lo table local src ... metric 1024 mtu 65535 pref medium# ip link set dev lo mtu 65536 # ip -6 route get 2000::1 local 2000::1 dev lo table local src ... metric 1024 mtu 65536 pref medium# ip -6 route del local 2000::1After this patch the route entry no longer changes unless it already has an mtu. There is no need: this inheritance is already done in
ip6_mtu()# ip link set dev lo mtu 65536 # ip -6 route add local 2000::1 dev lo # ip -6 route add local 2000::2 dev lo mtu 2000 # ip -6 route get 2000::1; ip -6 route get 2000::2 local 2000::1 dev lo table local src ... metric 1024 pref medium local 2000::2 dev lo table local src ... metric 1024 mtu 2000 pref medium# ip link set dev lo mtu 65535 # ip -6 route get 2000::1; ip -6 route get 2000::2 local 2000::1 dev lo table local src ... metric 1024 pref medium local 2000::2 dev lo table local src ... metric 1024 mtu 2000 pref medium# ip link set dev lo mtu 1501 # ip -6 route get 2000::1; ip -6 route get 2000::2 local 2000::1 dev lo table local src ... metric 1024 pref medium local 2000::2 dev lo table local src ... metric 1024 mtu 1501 pref medium# ip link set dev lo mtu 65536 # ip -6 route get 2000::1; ip -6 route get 2000::2 local 2000::1 dev lo table local src ... metric 1024 pref medium local 2000::2 dev lo table local src ... metric 1024 mtu 65536 pref medium# ip -6 route del local 2000::1 # ip -6 route del local 2000::2This is desirable because changing device mtu and then resetting it to the previous value shouldn't change the user visible routing table.
Signed-off-by Maciej Żenczykowski <[email protected]>CC Eric Dumazet <[email protected]>--- net/ipv6/route.c | 1 + 1 file changed, 1 insertion(+)net/ipv6/route.c +0
-0
net/ipv6/route.c static int rt6_mtu_change_route(struct rt6_info *rt, void *p_arg) · line 2764
Quoted 7 lines
net/ipv6/route.c +1
-0@@ -2758,6 +2758,7 @@ static int rt6_mtu_change_route(struct rt6_info *rt, void *p_arg)PMTU discouvery. */ if (rt->dst.dev == arg->dev && +dst_metric_raw (&rt->dst,RTAX_MTU ) && !dst_metric_locked (&rt->dst,RTAX_MTU )) {if (rt->rt6i_flags &RTF_CACHE ) {/* For RTF_CACHE with rt6i_pmtu == 0
Yep, that makes sense.
From: Maciej Żenczykowski <[email protected]>
Date: Fri, 4 Nov 2016 14:51:54 -0700
Quoted 8 lines
From: Maciej Żenczykowski <[email protected]>
Routes can specify an mtu explicitly or inherit the mtu from the underlying device - this inheritance is implemented in
dst->ops->mtuhandlersip6_mtu()andip6_blackhole_mtu().Currently changing the mtu of a device adds mtu explicitly to routes using that device.
...
Quoted 4 lines
This is desirable because changing device mtu and then resetting it to the previous value shouldn't change the user visible routing table.
Signed-off-by Maciej Żenczykowski <[email protected]>
Applied, thank you.