* [PATCH net v2 1/2] net: ipv4: fix incorrect MTU in broadcast routes
@ 2025-07-03 15:28 Oscar Maes
2025-07-03 15:28 ` [PATCH net v2 2/2] selftests: net: add test for variable PMTU " Oscar Maes
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Oscar Maes @ 2025-07-03 15:28 UTC (permalink / raw)
To: netdev
Cc: davem, dsahern, edumazet, kuba, pabeni, horms, stable,
linux-kernel, Oscar Maes
Currently, __mkroute_output overrules the MTU value configured for
broadcast routes.
This buggy behaviour can be reproduced with:
ip link set dev eth1 mtu 9000
ip route del broadcast 192.168.0.255 dev eth1 proto kernel scope link src 192.168.0.2
ip route add broadcast 192.168.0.255 dev eth1 proto kernel scope link src 192.168.0.2 mtu 1500
The maximum packet size should be 1500, but it is actually 8000:
ping -b 192.168.0.255 -s 8000
Fix __mkroute_output to allow MTU values to be configured for
for broadcast routes (to support a mixed-MTU local-area-network).
Signed-off-by: Oscar Maes <oscmaes92@gmail.com>
---
net/ipv4/route.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index fccb05fb3..a2a3b6482 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2585,7 +2585,6 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
do_cache = true;
if (type == RTN_BROADCAST) {
flags |= RTCF_BROADCAST | RTCF_LOCAL;
- fi = NULL;
} else if (type == RTN_MULTICAST) {
flags |= RTCF_MULTICAST | RTCF_LOCAL;
if (!ip_check_mc_rcu(in_dev, fl4->daddr, fl4->saddr,
--
2.39.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net v2 2/2] selftests: net: add test for variable PMTU in broadcast routes
2025-07-03 15:28 [PATCH net v2 1/2] net: ipv4: fix incorrect MTU in broadcast routes Oscar Maes
@ 2025-07-03 15:28 ` Oscar Maes
2025-07-03 15:34 ` [PATCH net v2 1/2] net: ipv4: fix incorrect MTU " kernel test robot
2025-07-09 1:54 ` Jakub Kicinski
2 siblings, 0 replies; 5+ messages in thread
From: Oscar Maes @ 2025-07-03 15:28 UTC (permalink / raw)
To: netdev
Cc: davem, dsahern, edumazet, kuba, pabeni, horms, stable,
linux-kernel, Oscar Maes
Added a test for variable PMTU in broadcast routes.
This test uses iputils' ping and attempts to send a ping between
two peers, which should result in a regular echo reply.
This test will fail when the receiving peer does not receive the echo
request due to a lack of packet fragmentation.
Signed-off-by: Oscar Maes <oscmaes92@gmail.com>
---
tools/testing/selftests/net/Makefile | 1 +
tools/testing/selftests/net/broadcast_pmtu.sh | 47 +++++++++++++++++++
2 files changed, 48 insertions(+)
create mode 100755 tools/testing/selftests/net/broadcast_pmtu.sh
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index 332f38761..f4aa94588 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -112,6 +112,7 @@ TEST_PROGS += skf_net_off.sh
TEST_GEN_FILES += skf_net_off
TEST_GEN_FILES += tfo
TEST_PROGS += tfo_passive.sh
+TEST_PROGS += broadcast_pmtu.sh
# YNL files, must be before "include ..lib.mk"
YNL_GEN_FILES := busy_poller netlink-dumps
diff --git a/tools/testing/selftests/net/broadcast_pmtu.sh b/tools/testing/selftests/net/broadcast_pmtu.sh
new file mode 100755
index 000000000..726eb5d25
--- /dev/null
+++ b/tools/testing/selftests/net/broadcast_pmtu.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# Ensures broadcast route MTU is respected
+
+CLIENT_NS=$(mktemp -u client-XXXXXXXX)
+CLIENT_IP4="192.168.0.1/24"
+CLIENT_BROADCAST_ADDRESS="192.168.0.255"
+
+SERVER_NS=$(mktemp -u server-XXXXXXXX)
+SERVER_IP4="192.168.0.2/24"
+
+setup() {
+ ip netns add "${CLIENT_NS}"
+ ip netns add "${SERVER_NS}"
+
+ ip -net "${SERVER_NS}" link add link1 type veth peer name link0 netns "${CLIENT_NS}"
+
+ ip -net "${CLIENT_NS}" link set link0 up
+ ip -net "${CLIENT_NS}" link set link0 mtu 9000
+ ip -net "${CLIENT_NS}" addr add "${CLIENT_IP4}" dev link0
+
+ ip -net "${SERVER_NS}" link set link1 up
+ ip -net "${SERVER_NS}" link set link1 mtu 1500
+ ip -net "${SERVER_NS}" addr add "${SERVER_IP4}" dev link1
+
+ read -r -a CLIENT_BROADCAST_ENTRY <<< "$(ip -net "${CLIENT_NS}" route show table local type broadcast)"
+ ip -net "${CLIENT_NS}" route del "${CLIENT_BROADCAST_ENTRY[@]}"
+ ip -net "${CLIENT_NS}" route add "${CLIENT_BROADCAST_ENTRY[@]}" mtu 1500
+
+ ip net exec "${SERVER_NS}" sysctl -wq net.ipv4.icmp_echo_ignore_broadcasts=0
+}
+
+cleanup() {
+ ip -net "${SERVER_NS}" link del link1
+ ip netns del "${CLIENT_NS}"
+ ip netns del "${SERVER_NS}"
+}
+
+trap cleanup EXIT
+
+setup &&
+ echo "Testing for broadcast route MTU" &&
+ ip net exec "${CLIENT_NS}" ping -f -M want -q -c 1 -s 8000 -w 1 -b "${CLIENT_BROADCAST_ADDRESS}" > /dev/null 2>&1
+
+exit $?
+
--
2.39.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net v2 1/2] net: ipv4: fix incorrect MTU in broadcast routes
2025-07-03 15:28 [PATCH net v2 1/2] net: ipv4: fix incorrect MTU in broadcast routes Oscar Maes
2025-07-03 15:28 ` [PATCH net v2 2/2] selftests: net: add test for variable PMTU " Oscar Maes
@ 2025-07-03 15:34 ` kernel test robot
2025-07-09 1:54 ` Jakub Kicinski
2 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2025-07-03 15:34 UTC (permalink / raw)
To: Oscar Maes; +Cc: stable, oe-kbuild-all
Hi,
Thanks for your patch.
FYI: kernel test robot notices the stable kernel rule is not satisfied.
The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1
Rule: add the tag "Cc: stable@vger.kernel.org" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH net v2 1/2] net: ipv4: fix incorrect MTU in broadcast routes
Link: https://lore.kernel.org/stable/20250703152838.2993-1-oscmaes92%40gmail.com
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net v2 1/2] net: ipv4: fix incorrect MTU in broadcast routes
2025-07-03 15:28 [PATCH net v2 1/2] net: ipv4: fix incorrect MTU in broadcast routes Oscar Maes
2025-07-03 15:28 ` [PATCH net v2 2/2] selftests: net: add test for variable PMTU " Oscar Maes
2025-07-03 15:34 ` [PATCH net v2 1/2] net: ipv4: fix incorrect MTU " kernel test robot
@ 2025-07-09 1:54 ` Jakub Kicinski
2025-07-10 14:16 ` Oscar Maes
2 siblings, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2025-07-09 1:54 UTC (permalink / raw)
To: Oscar Maes
Cc: netdev, davem, dsahern, edumazet, pabeni, horms, stable,
linux-kernel
On Thu, 3 Jul 2025 17:28:37 +0200 Oscar Maes wrote:
> if (type == RTN_BROADCAST) {
> flags |= RTCF_BROADCAST | RTCF_LOCAL;
> - fi = NULL;
> } else if (type == RTN_MULTICAST) {
> flags |= RTCF_MULTICAST | RTCF_LOCAL;
> if (!ip_check_mc_rcu(in_dev, fl4->daddr, fl4->saddr,
Not super familiar with this code, but do we not need to set
do_cache = false; ? I'm guessing cache interactions may have
been the reason fib_info was originally cleared, not sure if
that's still relevant..
I'd also target this at net-next, unless you can pinpoint
some kernel version where MTU on bcast routes worked..
--
pw-bot: cr
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net v2 1/2] net: ipv4: fix incorrect MTU in broadcast routes
2025-07-09 1:54 ` Jakub Kicinski
@ 2025-07-10 14:16 ` Oscar Maes
0 siblings, 0 replies; 5+ messages in thread
From: Oscar Maes @ 2025-07-10 14:16 UTC (permalink / raw)
To: Jakub Kicinski
Cc: netdev, davem, dsahern, edumazet, pabeni, horms, stable,
linux-kernel
On Tue, Jul 08, 2025 at 06:54:30PM -0700, Jakub Kicinski wrote:
> On Thu, 3 Jul 2025 17:28:37 +0200 Oscar Maes wrote:
> > if (type == RTN_BROADCAST) {
> > flags |= RTCF_BROADCAST | RTCF_LOCAL;
> > - fi = NULL;
> > } else if (type == RTN_MULTICAST) {
> > flags |= RTCF_MULTICAST | RTCF_LOCAL;
> > if (!ip_check_mc_rcu(in_dev, fl4->daddr, fl4->saddr,
>
> Not super familiar with this code, but do we not need to set
> do_cache = false; ? I'm guessing cache interactions may have
> been the reason fib_info was originally cleared, not sure if
> that's still relevant..
>
> I'd also target this at net-next, unless you can pinpoint
> some kernel version where MTU on bcast routes worked..
> --
> pw-bot: cr
The caching mechanism was introduced after this line, back when nhc was embedded in fib_info.
(see https://lore.kernel.org/netdev/20120720.142612.691540831359186107.davem@davemloft.net/)
I'll resend to net-next.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-07-10 14:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-03 15:28 [PATCH net v2 1/2] net: ipv4: fix incorrect MTU in broadcast routes Oscar Maes
2025-07-03 15:28 ` [PATCH net v2 2/2] selftests: net: add test for variable PMTU " Oscar Maes
2025-07-03 15:34 ` [PATCH net v2 1/2] net: ipv4: fix incorrect MTU " kernel test robot
2025-07-09 1:54 ` Jakub Kicinski
2025-07-10 14:16 ` Oscar Maes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).