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

net: ipv4: fix regression in local-broadcast routes

Commit 9e30ecf23b1b ("net: ipv4: fix incorrect MTU in broadcast routes")
introduced a regression where local-broadcast packets would have their
gateway set in __mkroute_output, which was caused by fi = NULL being
removed.

Fix this by resetting the fib_info for local-broadcast packets. This
preserves the intended changes for directed-broadcast packets.

Cc: stable@vger.kernel.org
Fixes: 9e30ecf23b1b ("net: ipv4: fix incorrect MTU in broadcast routes")
Reported-by: Brett A C Sheffield <bacs@librecast.net>
Closes: https://lore.kernel.org/regressions/20250822165231.4353-4-bacs@librecast.net
Signed-off-by: Oscar Maes <oscmaes92@gmail.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://patch.msgid.link/20250827062322.4807-1-oscmaes92@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Oscar Maes and committed by
Paolo Abeni
5189446b dac978e5

+7 -3
+7 -3
net/ipv4/route.c
··· 2575 2575 !netif_is_l3_master(dev_out)) 2576 2576 return ERR_PTR(-EINVAL); 2577 2577 2578 - if (ipv4_is_lbcast(fl4->daddr)) 2578 + if (ipv4_is_lbcast(fl4->daddr)) { 2579 2579 type = RTN_BROADCAST; 2580 - else if (ipv4_is_multicast(fl4->daddr)) 2580 + 2581 + /* reset fi to prevent gateway resolution */ 2582 + fi = NULL; 2583 + } else if (ipv4_is_multicast(fl4->daddr)) { 2581 2584 type = RTN_MULTICAST; 2582 - else if (ipv4_is_zeronet(fl4->daddr)) 2585 + } else if (ipv4_is_zeronet(fl4->daddr)) { 2583 2586 return ERR_PTR(-EINVAL); 2587 + } 2584 2588 2585 2589 if (dev_out->flags & IFF_LOOPBACK) 2586 2590 flags |= RTCF_LOCAL;