* [PATCH net v2 0/2] ipv6: ignore link state in gateway check
@ 2026-11-04 19:56 Yaroslav Dudkov
2026-11-04 19:56 ` [PATCH net v2 1/2] " Yaroslav Dudkov
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Yaroslav Dudkov @ 2026-11-04 19:56 UTC (permalink / raw)
To: netdev
Cc: dsahern, idosch, davem, edumazet, kuba, pabeni, horms, shuah,
weiwan, linux-kernel, linux-kselftest, Yaroslav Dudkov
IPv6 gateway validation can reject routes in non-main tables when
ignore_routes_with_linkdown is enabled and the nexthop device has
no carrier, even though these routes should be added.
Fix this by ignoring link state during gateway validation and add a
regression selftest covering IPv4 and IPv6 route installation.
Changes in v2:
- Fix variable ordering.
- Add a regression selftest.
v1: https://lore.kernel.org/netdev/20261028152634.3355852-1-aroslavdudkov622@gmail.com/
Yaroslav Dudkov (2):
ipv6: ignore link state in gateway check
selftests: fib_tests: Add carrier gateway test
net/ipv6/route.c | 2 +-
tools/testing/selftests/net/fib_tests.sh | 40 ++++++++++++++++++++++++
2 files changed, 41 insertions(+), 1 deletion(-)
--
2.54.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net v2 1/2] ipv6: ignore link state in gateway check
2026-11-04 19:56 [PATCH net v2 0/2] ipv6: ignore link state in gateway check Yaroslav Dudkov
@ 2026-11-04 19:56 ` Yaroslav Dudkov
2026-11-04 19:56 ` [PATCH net v2 2/2] selftests: fib_tests: Add carrier gateway test Yaroslav Dudkov
2026-11-04 20:09 ` [PATCH net v2 0/2] ipv6: ignore link state in gateway check netdev-bot+sinfo
2 siblings, 0 replies; 4+ messages in thread
From: Yaroslav Dudkov @ 2026-11-04 19:56 UTC (permalink / raw)
To: netdev
Cc: dsahern, idosch, davem, edumazet, kuba, pabeni, horms, shuah,
weiwan, linux-kernel, linux-kselftest, Yaroslav Dudkov
IPv6 route cannot be added in table when all
following conditions are true:
- gateway is not link-local address
- ignore_routes_with_linkdown=1 on device
- nexthop has no carrier
- gateway is not present or covered by any route in table already
Also multipath routes addition is invalidated by kernel even
if only one of added nexthops satisfies all above conditions.
Reproducer:
ip netns add t
ip -n t link add va type veth peer name vb
ip -n t link set va up
ip -n t addr add fd00::1/64 dev va nodad
ip netns exec t sysctl -w \
net.ipv6.conf.va.ignore_routes_with_linkdown=1
ip -n t -6 route add 2001:db8::/64 via fd00::2 dev va
# added
ip -n t -6 route add 2001:db8::/64 table 100 via fd00::2 dev va
# RTNETLINK answers: No route to host
ip -n t -6 route show table all
ip netns del t
Route should be added because:
- RT6_LOOKUP_F_IGNORE_LINKSTATE in commit d5d32e4b7668
("net: ipv6: Do not consider link state for nexthop validation")
was added for this
- the same route is valid in main table (when no specifying table id
while adding route)
- fib6_nh_init() initializes nexthops with no carrier
- IPv4 already does this (fib_check_nh_v4_gw() ignores link state
using the FIB_LOOKUP_IGNORE_LINKSTATE flag)
Before commit b2c709cce682 ("ipv6: Convert gateway validation to
use fib6_info") rt6_lookup() was used for checking if nexthop is
valid, rt6_lookup called rt6_device_match() which does not check the
link state. After change rt6_lookup() to fib6_lookup()
find_match() under fib6_lookup() started to invalidate linkdown
devices, because RT6_LOOKUP_F_IGNORE_LINKSTATE is not passed to it.
Adding RT6_LOOKUP_F_IGNORE_LINKSTATE to flags for ip6_route_check_nh()
solves the problem. RT6_LOOKUP_F_IGNORE_LINKSTATE is already used
inside the first search ip6_nh_lookup_table() and fixes the
bug in second search fib6_lookup(). Also RT6_LOOKUP_F_IGNORE_LINKSTATE
isn't read inside fib6_select_path().
Fixes: b2c709cce682 ("ipv6: Convert gateway validation to use fib6_info")
Signed-off-by: Yaroslav Dudkov <aroslavdudkov622@gmail.com>
---
IPv4 example of this situation:
ip netns add t
ip -n t link add va type veth peer name vb
ip -n t link set va up
ip -n t addr add 192.168.0.1/24 dev va
ip netns exec t sysctl -w \
net.ipv4.conf.va.ignore_routes_with_linkdown=1
ip -n t route add 192.0.2.0/24 table 100 via 192.168.0.2 dev va
# added
ip -n t route show table all
ip netns del t
Also when adding RT6_LOOKUP_F_IGNORE_LINKSTATE to flags of
ip6_route_check_nh() makes adding this flag inside of
ip6_nh_lookup_table() unnecessary for this call, making another call in
ip6_route_check_nh_onlink() with flags=0 the only place where it is
needed.
---
net/ipv6/route.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 94e5ef1c4f83..73d8a2c95602 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -3424,9 +3424,9 @@ static int ip6_route_check_nh(struct net *net,
netdevice_tracker *dev_tracker,
struct inet6_dev **idev)
{
+ int flags = RT6_LOOKUP_F_IFACE | RT6_LOOKUP_F_IGNORE_LINKSTATE;
const struct in6_addr *gw_addr = &cfg->fc_gateway;
struct net_device *dev = _dev ? *_dev : NULL;
- int flags = RT6_LOOKUP_F_IFACE;
struct fib6_result res = {};
int err = -EHOSTUNREACH;
--
2.54.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net v2 2/2] selftests: fib_tests: Add carrier gateway test
2026-11-04 19:56 [PATCH net v2 0/2] ipv6: ignore link state in gateway check Yaroslav Dudkov
2026-11-04 19:56 ` [PATCH net v2 1/2] " Yaroslav Dudkov
@ 2026-11-04 19:56 ` Yaroslav Dudkov
2026-11-04 20:09 ` [PATCH net v2 0/2] ipv6: ignore link state in gateway check netdev-bot+sinfo
2 siblings, 0 replies; 4+ messages in thread
From: Yaroslav Dudkov @ 2026-11-04 19:56 UTC (permalink / raw)
To: netdev
Cc: dsahern, idosch, davem, edumazet, kuba, pabeni, horms, shuah,
weiwan, linux-kernel, linux-kselftest, Yaroslav Dudkov
Test adds routes with a gateway while the nexthop device
has no carrier and ignore_routes_with_linkdown is enabled on it. The
routes are added to the main table and to a non-main table, with and
without a device, for both IPv4 and IPv6. Routes are expected to be
accepted disregarding the link state.
Without the previous patch, the IPv6 non-main table cases fail:
Without fix:
Gateway validation with carrier down
TEST: IPv4 route in main table [ OK ]
TEST: IPv6 route in main table [ OK ]
TEST: IPv4 route in non-main table [ OK ]
TEST: IPv6 route in non-main table [FAIL]
TEST: IPv4 route in non-main table without device [ OK ]
TEST: IPv6 route in non-main table without device [FAIL]
TEST: IPv4 linkdown flag set [ OK ]
TEST: IPv6 linkdown flag set [FAIL]
With fix:
Gateway validation with carrier down
TEST: IPv4 route in main table [ OK ]
TEST: IPv6 route in main table [ OK ]
TEST: IPv4 route in non-main table [ OK ]
TEST: IPv6 route in non-main table [ OK ]
TEST: IPv4 route in non-main table without device [ OK ]
TEST: IPv6 route in non-main table without device [ OK ]
TEST: IPv4 linkdown flag set [ OK ]
TEST: IPv6 linkdown flag set [ OK ]
Suggested-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Yaroslav Dudkov <aroslavdudkov622@gmail.com>
---
tools/testing/selftests/net/fib_tests.sh | 40 ++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/tools/testing/selftests/net/fib_tests.sh b/tools/testing/selftests/net/fib_tests.sh
index 7c47d7fe250d..d7ac3c727f70 100755
--- a/tools/testing/selftests/net/fib_tests.sh
+++ b/tools/testing/selftests/net/fib_tests.sh
@@ -406,10 +406,50 @@ fib_carrier_unicast_test()
cleanup
}
+fib_carrier_gw_test()
+{
+ echo
+ echo "Gateway validation with carrier down"
+
+ setup
+
+ set -e
+ $NS_EXEC sysctl -qw net.ipv4.conf.dummy0.ignore_routes_with_linkdown=1
+ $NS_EXEC sysctl -qw net.ipv6.conf.dummy0.ignore_routes_with_linkdown=1
+ $IP link set dev dummy0 carrier off
+ sleep 1
+ set +e
+
+ $IP route add 203.0.113.0/25 via 198.51.100.2 dev dummy0 &> /dev/null
+ log_test $? 0 "IPv4 route in main table"
+ $IP -6 route add 2001:db8:10::/64 via 2001:db8:1::2 dev dummy0 &> /dev/null
+ log_test $? 0 "IPv6 route in main table"
+
+ $IP route add 203.0.113.0/25 table 100 via 198.51.100.2 dev dummy0 &> /dev/null
+ log_test $? 0 "IPv4 route in non-main table"
+ $IP -6 route add 2001:db8:10::/64 table 100 via 2001:db8:1::2 dev dummy0 &> /dev/null
+ log_test $? 0 "IPv6 route in non-main table"
+
+ $IP route add 203.0.113.128/25 table 100 via 198.51.100.2 &> /dev/null
+ log_test $? 0 "IPv4 route in non-main table without device"
+ $IP -6 route add 2001:db8:11::/64 table 100 via 2001:db8:1::2 &> /dev/null
+ log_test $? 0 "IPv6 route in non-main table without device"
+
+ $IP route show table 100 203.0.113.0/25 | \
+ grep -q "linkdown"
+ log_test $? 0 "IPv4 linkdown flag set"
+ $IP -6 route show table 100 2001:db8:10::/64 | \
+ grep -q "linkdown"
+ log_test $? 0 "IPv6 linkdown flag set"
+
+ cleanup
+}
+
fib_carrier_test()
{
fib_carrier_local_test
fib_carrier_unicast_test
+ fib_carrier_gw_test
}
fib_rp_filter_test()
--
2.54.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net v2 0/2] ipv6: ignore link state in gateway check
2026-11-04 19:56 [PATCH net v2 0/2] ipv6: ignore link state in gateway check Yaroslav Dudkov
2026-11-04 19:56 ` [PATCH net v2 1/2] " Yaroslav Dudkov
2026-11-04 19:56 ` [PATCH net v2 2/2] selftests: fib_tests: Add carrier gateway test Yaroslav Dudkov
@ 2026-11-04 20:09 ` netdev-bot+sinfo
2 siblings, 0 replies; 4+ messages in thread
From: netdev-bot+sinfo @ 2026-11-04 20:09 UTC (permalink / raw)
To: Yaroslav Dudkov
Cc: netdev, dsahern, idosch, davem, edumazet, kuba, pabeni, horms,
shuah, weiwan, linux-kernel, linux-kselftest
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. If the series needs another revision for
other reasons, please include the information in the commit messages
then.
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-04 20:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-04 19:56 [PATCH net v2 0/2] ipv6: ignore link state in gateway check Yaroslav Dudkov
2026-11-04 19:56 ` [PATCH net v2 1/2] " Yaroslav Dudkov
2026-11-04 19:56 ` [PATCH net v2 2/2] selftests: fib_tests: Add carrier gateway test Yaroslav Dudkov
2026-11-04 20:09 ` [PATCH net v2 0/2] ipv6: ignore link state in gateway check netdev-bot+sinfo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®