From: James Sawyer <jam…@jamessawyer.co.uk> IPVS checks the MTU toward the real server with dst_mtu(), which returns a path MTU learned from ICMP. Any host that can send ICMP to the director can create such an exception: udp_err() and udpv6_err() create it before socket matching (4c3499f79f8c, ac76cab50e89), and for IPv4 an ICMP quoting an Echo Reply did the same before that. One forged "fragmentation needed" or "packet too big" quoting a made-up UDP datagram to a real server's address makes ensure_mtu_is_adequate() reject clients' DF packets above the forged value. The real server may be on a directly connected network, because the ICMP does not have to come from the path to it. Use ip_dst_mtu_maybe_forward(dst, true) and ip6_dst_mtu_maybe_forward(dst, true) instead, as the MTU checks in ip_forward() and ip6_forward() do, for all forwarding methods. A learned PMTU is then ignored by the check unless net.ipv4.ip_forward_use_pmtu is set or the route MTU is locked, and a real PMTU problem is reported by the next router on the path. For IPv6 the check also ignores an unlocked route MTU, as the ip6_forward() check does; "mtu lock" keeps one. The learned PMTU and an unlocked IPv6 route MTU still apply on output. IPVS sets ignore_df, so a packet that passes the check but is larger than that MTU is now fragmented by the director instead of rejected. This includes IPv4 packets with DF set. Tested on 7.0 with the director in NAT and in IPIP mode, client on the director's LAN, real server behind a router, DF UDP to the VIP: NAT, forged MTU 1000 (IPv4) / 1300 (IPv6): 0/3 before, 3/3 after (fragmented by the director) IPIP, forged MTU 1000: 0/6 before, 6/6 after (outer packet fragmented) IPv4 route "mtu 1100", IPv6 route "mtu lock 1300": still enforced IPv6 route "mtu 1300" (unlocked): no longer enforced, packets above it are fragmented A forged IPv4 value below min_pmtu is stored as a locked exception and is still honoured after this change. The separate netdev patch "ipv4: do not trust ICMP-locked PMTU while forwarding" closes that case for both ip_forward() and IPVS. This was found and tested with the help of an AI coding assistant (Claude). The measurements ran on the author's lab machines. Suggested-by: Julian Anastasov <j…@ssi.bg> Link: https://lore.kernel.org/all/0851…@ssi.bg/ Signed-off-by: James Sawyer <jam…@jamessawyer.co.uk> --- The change you suggested in the thread linked above. On rp_filter: with rp_filter=1 on the director, the forged ICMP still sets the exception. The check applies to the ICMP's own source, and here that is the sender's real, routable address. Packets that now pass the check are fragmented by the director when the learned PMTU is lower, because of ignore_df. Plain ip_forward() on the same director sent them whole, because IPSKB_FORWARDED makes ip_skb_dst_mtu() use the forwarding MTU on output too. If you prefer that for IPVS, I can look at it. With IPIP and a real 1400-byte link behind the director, clients were told 1380 before, by the MTU check once the director had learned the PMTU. After the change they kept sending 1450-byte DF datagrams, and the director fragmented the outer packets. A route MTU on the director gives the old result. The ip_vs_core.c hunk made no difference to what the client was sent in this test, so it is build-tested only (W=1, no new warnings). DR and the GUE and GRE tunnels are not tested. I used nf-next because this changes behaviour for tunnels and for unlocked IPv6 route MTUs. I can resend for nf if you prefer. --- net/netfilter/ipvs/ip_vs_core.c | 3 ++- net/netfilter/ipvs/ip_vs_xmit.c | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c index f3eb72e95024..d8985a7ab4c3 100644 --- a/net/netfilter/ipvs/ip_vs_core.c +++ b/net/netfilter/ipvs/ip_vs_core.c @@ -1945,7 +1945,8 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related, dest_dst = rcu_dereference(dest->dest_dst); if (dest_dst) - mtu = dst_mtu(dest_dst->dst_cache); + mtu = ip_dst_mtu_maybe_forward(dest_dst->dst_cache, + true); } if (mtu > 68 + hlen_ipip + ulen) mtu -= hlen_ipip + ulen; diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c index ebc6b697ae51..c6c75c9799a2 100644 --- a/net/netfilter/ipvs/ip_vs_xmit.c +++ b/net/netfilter/ipvs/ip_vs_xmit.c @@ -395,9 +395,10 @@ __ip_vs_get_out_rt(struct netns_ipvs *ipvs, int skb_af, struct sk_buff *skb, goto err_put; if (likely(!(rt_mode & IP_VS_RT_MODE_TUNNEL))) { - mtu = dst_mtu(&rt->dst); + mtu = ip_dst_mtu_maybe_forward(&rt->dst, true); } else { - mtu = dst_mtu(&rt->dst) - sizeof(struct iphdr); + mtu = ip_dst_mtu_maybe_forward(&rt->dst, true) - + sizeof(struct iphdr); if (!dest) goto err_put; if (dest->tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GUE) { @@ -573,9 +574,10 @@ __ip_vs_get_out_rt_v6(struct netns_ipvs *ipvs, int skb_af, struct sk_buff *skb, /* MTU checking */ if (likely(!(rt_mode & IP_VS_RT_MODE_TUNNEL))) - mtu = dst_mtu(&rt->dst); + mtu = ip6_dst_mtu_maybe_forward(&rt->dst, true); else { - mtu = dst_mtu(&rt->dst) - sizeof(struct ipv6hdr); + mtu = ip6_dst_mtu_maybe_forward(&rt->dst, true) - + sizeof(struct ipv6hdr); if (!dest) goto err_put; if (dest->tun_type == IP_VS_CONN_F_TUNNEL_TYPE_GUE) { --- base-commit: 693c2e04e3f1d4c59af236e1211b7b8cb165a790 change-id: 20261204-ipvs-forwarding-mtu-412810cdcf2b Best regards, -- James Sawyer <jam…@jamessawyer.co.uk>