Netdev List
 help / color / mirror / Atom feed
* [PATCH net v2 1/2] ipv4: keep scanning the leaf when a nexthop object is unusable
@ 2026-11-26 16:25 Yifei Sun
  2026-11-26 16:25 ` [PATCH net v2 2/2] selftests: net: test IPv4 nexthop fallback in the same trie leaf Yifei Sun
  2026-11-26 19:24 ` [PATCH net v2 1/2] ipv4: keep scanning the leaf when a nexthop object is unusable Ido Schimmel
  0 siblings, 2 replies; 4+ messages in thread
From: Yifei Sun @ 2026-11-26 16:25 UTC (permalink / raw)
  To: netdev
  Cc: Yifei Sun, idosch, dsahern, davem, edumazet, kuba, pabeni,
	willemb, horms, razor, shuah, linux-kselftest

With veth1 on 172.16.1.0/24 and veth3 on 172.16.2.0/24:

  # ip nexthop add id 12 via 172.16.1.2 dev veth1
  # ip route add 10.0.0.0/24 nhid 12
  # ip route add 10.0.0.0/16 via 172.16.2.2 dev veth3
  # ip route get fibmatch 10.0.0.1 oif veth3
  RTNETLINK answers: No route to host

When the /24's nexthop object has no path on veth3, fib_table_lookup()
backtracks past the /16 in the same leaf. A socket bound to veth3 then
ARPs for the destination instead of the gateway. Fix this by trying the
next alias in the same leaf. The lookup already does this when no
inline nexthop is usable.

Fixes: af7888ad9edb ("ipv4: Refactor nhc evaluation in fib_table_lookup")
Signed-off-by: Yifei Sun <yifei.sun@inria.fr>
---
Encountered this while work on a unrelated IPv4 SADR patch (not sure if
this is even needed...)

In QEMU with lockdep on 5e2976e52671, the selftest and device-bound
ping and UDP failed before the fix and passed after it.

v2: Reworded.
v1: https://lore.kernel.org/netdev/20261121182031.36626-1-yifei.sun@inria.fr/

 net/ipv4/fib_trie.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 394df1de1281..2a670e9b0417 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1591,7 +1591,7 @@ int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp,
 						     &nhsel);
 			if (nhc)
 				goto set_result;
-			goto miss;
+			continue;
 		}
 
 		for (nhsel = 0; nhsel < fib_info_num_path(fi); nhsel++) {
@@ -1622,7 +1622,6 @@ int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp,
 			return err;
 		}
 	}
-miss:
 #ifdef CONFIG_IP_FIB_TRIE_STATS
 	this_cpu_inc(stats->semantic_match_miss);
 #endif

base-commit: ae8e5ef9fa9eeaf4ee0a9a9bde0fc63023d9b154
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-26 19:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 16:25 [PATCH net v2 1/2] ipv4: keep scanning the leaf when a nexthop object is unusable Yifei Sun
2026-11-26 16:25 ` [PATCH net v2 2/2] selftests: net: test IPv4 nexthop fallback in the same trie leaf Yifei Sun
2026-11-26 19:28   ` Ido Schimmel
2026-11-26 19:24 ` [PATCH net v2 1/2] ipv4: keep scanning the leaf when a nexthop object is unusable Ido Schimmel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox