ipv4: Don't cache a pmtu above the device mtu of a path
Subsystems (4)
cover ipv4: Don't cache a pmtu above the device mtu of a path
The mtu of a Fragmentation Needed is cached on every path of a multipath route, but checked against the looked-up path only. A path whose device mtu is lower gets a pmtu above what it can carry, and its flows blackhole until the exception expires. Patch 1 skips such a path, patch 2 adds a test for it.
Split out of [1] with Ido's suggestion; the IPv6 part follows once this is in.
[1] https://lore.kernel.org/netdev/[email protected]/
Vladimir Vdovin (2):
ipv4: Don't cache a pmtu above the device mtu of a path
selftests: net: pmtu: Add a multipath test with paths of different MTU
net/ipv4/route.c | 2 + tools/testing/selftests/net/pmtu.sh | 74 ++++++++++++++++++++++++++++- 2 files changed, 75 insertions(+), 1 deletion(-)
base-commit: 2388bb763e323442f4dd8189238ac0c5f334c4a0
Signature · 1 line
2.56.0
PATCH 1/2 ipv4: Don't cache a pmtu above the device mtu of a path
The mtu of a Fragmentation Needed is cached on every path of a multipath route, checked against the path the lookup picked only. A path whose device mtu is below it gets a pmtu it can't carry: packets above the device mtu pass the pmtu check and are dropped at the device, no ICMP comes back, and the flows on that path blackhole until the exception expires.
Skip such a path.
--- net/ipv4/route.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv4/route.c +2 -0
@@ -1094,6 +1094,8 @@ static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu) nhc =fib_info_nhc (res.fi, nhsel);if (!nhc)break ; +if (mtu >READ_ONCE (nhc->nhc_dev->mtu)) +continue ;update_or_create_fnhe (nhc, fl4->daddr,0 , mtu, lock, jiffies + net->ipv4.ip_rt_mtu_expires); }
Signature · 1 line
2.56.0
PATCH 2/2 selftests: net: pmtu: Add a multipath test with paths of different MTU
In reply to Vladimir VdovinAdd pmtu_ipv4_mp_asym_exceptions: the topology of pmtu_ipv4_mp_exceptions with an MTU of 1400 behind one router, and 1350 on the link to the other router with 1300 behind it. Pick a flow through each router, a source address as the IPv4 multipath hash covers addresses only by default, and check that a Fragmentation Needed from the first router is cached on its path only, as the second one can't carry 1400, then that a flow through the second router lowers the PMTU of both paths.
Without the preceding patch the test fails with both legacy nexthops and nexthop objects.
--- tools/testing/selftests/net/pmtu.sh | 74 ++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-)
tools/testing/selftests/net/pmtu.sh +73 -1
@@ -203,6 +203,13 @@ # on host A and B on lo reachable via both routers. Host A and B # addresses have multipath routes to each other, b_r1 mtu = 1500. # Check that PMTU exceptions are created for both paths. +# +# - pmtu_ipv4_mp_asym_exceptions +# Same topology as pmtu_ipv4_mp_exceptions, with b_r1 mtu = 1400, +# a_r2 mtu = 1350 and b_r2 mtu = 1300. Pick a flow through each router +# and check that a Fragmentation Needed from R1 creates a PMTU +# exception on the path via R1 only, as the path via R2 can't carry +# 1400, then that a flow through R2 lowers the PMTU of both paths source lib.sh
@@ -272,7 +279,8 @@ tests=" list_flush_ipv6_exception ipv6: list and flush cached exceptions 1 pmtu_ipv4_route_change ipv4: PMTU exception w/route replace 1 pmtu_ipv6_route_change ipv6: PMTU exception w/route replace 1 - pmtu_ipv4_mp_exceptions ipv4: PMTU multipath nh exceptions 1" + pmtu_ipv4_mp_exceptions ipv4: PMTU multipath nh exceptions 1 + pmtu_ipv4_mp_asym_exceptions ipv4: PMTU multipath exceptions, asym MTU 1" # Addressing and routing for tests with routers: four network segments, with # index SEGMENT between 1 and 4, a common prefix (PREFIX4 or PREFIX6) and an
@@ -350,6 +358,7 @@ tunnel6_b_addr="fd00:2::b" tunnel6_mask="64" host4_a_addr="192.168.99.99" +host4_a_net="192.168.97" host4_b_addr="192.168.88.88" dummy6_0_prefix="fc00:1000::"
@@ -2407,6 +2416,69 @@ test_pmtu_ipv4_mp_exceptions() { check_pmtu_value "1500" "${pmtu_a_R2}" "exceeding MTU (veth_A-R2)" || return 1 } +# Pick a source address out of ${host4_a_net} for a flow from host A to +# ${1} through ${2}: the IPv4 multipath hash covers addresses only by +# default +mp_flow_via() { + dst="${1}" + oif="${2}" + + for i in $(seq 1 32); do + flow="${host4_a_net}.${i}" + ${ns_a} ip route get ${dst} from ${flow} | + grep -q " dev ${oif} " && echo "${flow}" && return + done + + return 1 +} + +test_pmtu_ipv4_mp_asym_exceptions() { + setup namespaces routing multipath || return $ksft_skip + + trace "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \ + "${ns_r1}" veth_R1-B "${ns_b}" veth_B-R1 \ + "${ns_a}" veth_A-R2 "${ns_r2}" veth_R2-A \ + "${ns_r2}" veth_R2-B "${ns_b}" veth_B-R2 + + # Source addresses for mp_flow_via(), with routes back to them + run_cmd ${ns_a} ip route add local ${host4_a_net}.0/24 dev lo + run_cmd ${ns_r1} ip route add ${host4_a_net}.0/24 via ${prefix4}.${a_r1}.1 + run_cmd ${ns_r2} ip route add ${host4_a_net}.0/24 via ${prefix4}.${a_r2}.1 + + # Set up initial MTU values: 1400 behind R1, 1350 to R2, 1300 behind R2 + mtu "${ns_a}" veth_A-R1 2000 + mtu "${ns_r1}" veth_R1-A 2000 + mtu "${ns_r1}" veth_R1-B 1400 + mtu "${ns_b}" veth_B-R1 1400 + + mtu "${ns_a}" veth_A-R2 1350 + mtu "${ns_r2}" veth_R2-A 1350 + mtu "${ns_r2}" veth_R2-B 1300 + mtu "${ns_b}" veth_B-R2 1300 + + flow_r1="$(mp_flow_via ${host4_b_addr} veth_A-R1)" || { + err " no flow through veth_A-R1 found"; return 1; } + flow_r2="$(mp_flow_via ${host4_b_addr} veth_A-R2)" || { + err " no flow through veth_A-R2 found"; return 1; } + + # A Fragmentation Needed from R1 is cached on the path via R1, not on + # the path via R2, whose link can't carry 1400 + run_cmd ${ns_a} ping -I ${flow_r1} -q -M want -i 0.1 -c 1 -s 1800 "${host4_b_addr}" + + pmtu_a_R1="$(route_get_dst_pmtu_from_exception "${ns_a}" "${host4_b_addr}" oif veth_A-R1)" + pmtu_a_R2="$(route_get_dst_pmtu_from_exception "${ns_a}" "${host4_b_addr}" oif veth_A-R2)" + check_pmtu_value "1400" "${pmtu_a_R1}" "exceeding MTU via R1 (veth_A-R1)" || return 1 + check_pmtu_value "" "${pmtu_a_R2}" "exceeding MTU via R1 (veth_A-R2)" || return 1 + + # The lower MTU behind R2 lowers the PMTU of both paths + run_cmd ${ns_a} ping -I ${flow_r2} -q -M want -i 0.1 -c 1 -s 1280 "${host4_b_addr}" + + pmtu_a_R1="$(route_get_dst_pmtu_from_exception "${ns_a}" "${host4_b_addr}" oif veth_A-R1)" + pmtu_a_R2="$(route_get_dst_pmtu_from_exception "${ns_a}" "${host4_b_addr}" oif veth_A-R2)" + check_pmtu_value "1300" "${pmtu_a_R1}" "exceeding MTU via R2 (veth_A-R1)" || return 1 + check_pmtu_value "1300" "${pmtu_a_R2}" "exceeding MTU via R2 (veth_A-R2)" || return 1 +} + usage() { echo echo "$0 [OPTIONS] [TEST]..."
Signature · 1 line
2.56.0
[email protected]
AI reviewThis is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages.
Signature · 2 lines
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
Quoted 10 lines · Vladimir Vdovin
The mtu of a Fragmentation Needed is cached on every path of a multipath route, but checked against the looked-up path only. A path whose device mtu is lower gets a pmtu above what it can carry, and its flows blackhole until the exception expires. Patch 1 skips such a path, patch 2 adds a test for it.
Split out of [1] with Ido's suggestion; the IPv6 part follows once this is in.
A few notes:
1. The bot will most likely complain about a missing Fixes tag. I don't think it's worth it. Nobody reported encountering this problem, it requires an unusual setup (nexthop devices with different MTU) and the PMTU needs to fall between these MTUs.
2. The patch doesn't handle an even more unlikely case where the PTB lookup resolves a dst entry on a different nexthop than the nexthop via which the quoted packet egressed, and the MTU of that nexthop is lower than the PMTU. It's not worth the complexity. See more in [1].
3. An exception can be cached with a PMTU above the device MTU if the device MTU is lowered concurrently. It's pre-existing and very unlikely.
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 10 lines · On Tue, 24 Nov 2026 18:37:28 +0300 you wrote:
The mtu of a Fragmentation Needed is cached on every path of a multipath route, but checked against the looked-up path only. A path whose device mtu is lower gets a pmtu above what it can carry, and its flows blackhole until the exception expires. Patch 1 skips such a path, patch 2 adds a test for it.
Split out of [1] with Ido's suggestion; the IPv6 part follows once this is in.
[...]
Here is the summary with links:
- [net-next,1/2] ipv4: Don't cache a pmtu above the device mtu of a path
https://git.kernel.org/netdev/net-next/c/c9a1d4867a38 - [net-next,2/2] selftests: net: pmtu: Add a multipath test with paths of different MTU https://git.kernel.org/netdev/net-next/c/a91bfe99ddbd
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html