* [PATCH net-next 0/2] net: ipv6: add strict RFC 4861 6.3.6 default router selection
@ 2026-11-30 22:26 Florian Fainelli
2026-11-30 22:26 ` [PATCH net-next 1/2] " Florian Fainelli
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Florian Fainelli @ 2026-11-30 22:26 UTC (permalink / raw)
To: netdev
Cc: Florian Fainelli, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Hideaki YOSHIFUJI, David Ahern, Shuah Khan,
Kuniyuki Iwashima, Jiayuan Chen, Angus Peng, Maoyi Xie, open list,
open list:KERNEL SELFTEST FRAMEWORK, bcm-kernel-feedback-list
This patch series adds support for strict RFC 4861 section 6.3.6 default
router selection along with a self test to exercise the newly added
sysctl knob.
Angus Peng (1):
net: ipv6: add strict RFC 4861 6.3.6 default router selection
Florian Fainelli (1):
selftests: net: add test for ipv6 strict_router_selection
Documentation/networking/ip-sysctl.rst | 29 +
include/net/netns/ipv6.h | 1 +
net/ipv6/route.c | 101 +++-
tools/testing/selftests/net/Makefile | 1 +
.../net/ipv6_strict_router_select.sh | 507 ++++++++++++++++++
5 files changed, 637 insertions(+), 2 deletions(-)
create mode 100755 tools/testing/selftests/net/ipv6_strict_router_select.sh
--
2.34.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH net-next 1/2] net: ipv6: add strict RFC 4861 6.3.6 default router selection
2026-11-30 22:26 [PATCH net-next 0/2] net: ipv6: add strict RFC 4861 6.3.6 default router selection Florian Fainelli
@ 2026-11-30 22:26 ` Florian Fainelli
2026-12-04 4:27 ` netdev-bot+sashiko
2026-11-30 22:26 ` [PATCH net-next 2/2] selftests: net: add test for ipv6 strict_router_selection Florian Fainelli
2026-12-02 8:29 ` [PATCH net-next 0/2] net: ipv6: add strict RFC 4861 6.3.6 default router selection Ido Schimmel
2 siblings, 1 reply; 12+ messages in thread
From: Florian Fainelli @ 2026-11-30 22:26 UTC (permalink / raw)
To: netdev
Cc: Angus Peng, Florian Fainelli, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Hideaki YOSHIFUJI, David Ahern,
Shuah Khan, Kuniyuki Iwashima, Jiayuan Chen, Maoyi Xie, open list,
open list:KERNEL SELFTEST FRAMEWORK, bcm-kernel-feedback-list
From: Angus Peng <angus.peng@broadcom.com>
A CPE learns default routers from Router Advertisements on its WAN
and must apply RFC 4861 section 6.3.6 default router selection there.
Upstream does not, for three independent reasons:
- ip6_pol_route() only sets RT6_LOOKUP_F_REACHABLE when forwarding is
disabled, so neighbor reachability is never consulted on a router;
- with CONFIG_IPV6_ROUTER_PREF enabled, a missing or unresolved
neighbor entry is scored as reachable, so every candidate ties and
the round-robin required by 6.3.6 rule 2 never triggers;
- RT6_NUD_SUCCEED adds nothing to the route score. On the forwarding
path ip6_pol_route_input() passes flowi6_iif into the parameter
rt6_score_route() knows as oif, so it never matches the nexthop
device and the device score is zero. With no preference bonus
either (CONFIG_IPV6_ROUTER_PREF=n), a reachable nexthop ties with
an unreachable one and FIB leaf order decides.
Add net.ipv6.route.strict_router_selection, default 0, which leaves
the upstream paths bit-for-bit unchanged. When enabled,
reachability-based selection also applies with forwarding on, and
rt6_score_route() ranks candidates by neighbor state above the device
and preference scores, so preference only breaks ties between equally
reachable routers as RFC 4191 section 3 requires. RFC 4191 section
6.2.3 probing is suppressed in strict mode: soliciting a router that
was not selected is indistinguishable from address resolution, and a
CONFIG_IPV6_ROUTER_PREF=n kernel does not probe at all; unreachable
routers are recovered through round-robin and traffic-driven
resolution instead.
rt6_check_neigh() is left untouched: strict mode bypasses it and
derives both the verdict and the score from a single neighbor lookup,
so the semantics do not depend on CONFIG_IPV6_ROUTER_PREF.
Signed-off-by: Angus Peng <angus.peng@broadcom.com>
[florian: commit message, comments, forward porting]
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
Documentation/networking/ip-sysctl.rst | 29 +++++++
include/net/netns/ipv6.h | 1 +
net/ipv6/route.c | 101 ++++++++++++++++++++++++-
3 files changed, 129 insertions(+), 2 deletions(-)
diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst
index 671011c74e14..0ea2d7818ea2 100644
--- a/Documentation/networking/ip-sysctl.rst
+++ b/Documentation/networking/ip-sysctl.rst
@@ -2586,6 +2586,35 @@ skip_notify_on_dev_down - BOOLEAN
Default: 0 (disabled)
+route/strict_router_selection - BOOLEAN
+ Apply strict default router selection as described in RFC 4861
+ section 6.3.6.
+
+ By default, neighbour reachability is only taken into account
+ when IPv6 forwarding is disabled, and a router with no neighbour
+ entry is considered reachable when CONFIG_IPV6_ROUTER_PREF is
+ enabled. When enabled, reachability is also considered when
+ forwarding is enabled, for example on a CPE that learns its
+ default routers from Router Advertisements on the WAN.
+
+ Candidate routers are ranked by neighbour state first: routers
+ with a valid neighbour entry come first, then routers whose
+ address resolution is in progress, which stay selected until
+ resolution completes or fails. The device match and the RFC 4191
+ router preference (CONFIG_IPV6_ROUTER_PREF) only break ties
+ between routers of equal reachability. If no router is known to
+ be reachable, routers are selected in round-robin.
+
+ RFC 4191 section 6.2.3 router reachability probing is not
+ performed when enabled.
+
+ Possible values:
+
+ - 0 (disabled) - upstream default router selection
+ - 1 (enabled) - strict RFC 4861 section 6.3.6 selection
+
+ Default: 0 (disabled)
+
nexthop_compat_mode - BOOLEAN
New nexthop API provides a means for managing nexthops independent of
prefixes. Backwards compatibility with old route format is enabled by
diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
index aefce37c04a4..e34b3f846288 100644
--- a/include/net/netns/ipv6.h
+++ b/include/net/netns/ipv6.h
@@ -27,6 +27,7 @@ struct netns_sysctl_ipv6 {
int ip6_rt_gc_interval;
int ip6_rt_mtu_expires;
int ip6_rt_min_advmss;
+ u8 ip6_rt_strict_router_select;
u32 multipath_hash_fields;
u8 multipath_hash_policy;
u8 ip6_rt_gc_elasticity;
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index df843178e5ec..d1795e91602e 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -653,6 +653,61 @@ static void rt6_device_match(struct net *net, struct fib6_result *res,
res->nh = nh;
}
+/* Strict RFC 4861 6.3.6 default router selection, runtime-controlled
+ * via net.ipv6.route.strict_router_selection (default 0 = upstream
+ * behaviour, bit-for-bit). When enabled:
+ * - reachability-based selection also applies with forwarding on
+ * (a CPE learns default routers from RAs on its WAN and must
+ * behave like a host there): see ip6_pol_route(),
+ * - candidate routers are ranked strictly by neighbour state in
+ * rt6_strict_reach_rank(), replacing the rt6_check_neigh() verdict
+ * entirely; the rank sits above the device score (bit 1) and the
+ * RFC 4191 preference score (bits 2+), so preference only breaks
+ * ties between equally reachable routers (RFC 4191 sec 3). The
+ * reachability ordering itself does not depend on
+ * CONFIG_IPV6_ROUTER_PREF:
+ * NUD_VALID known/probably reachable -> highest rank
+ * NUD_INCOMPLETE resolution in progress -> middle rank; the
+ * router stays selected while its solicitations
+ * are in flight, so unrelated lookups cannot
+ * rotate away and spread NS across routers,
+ * which would consume rotation slots and defeat
+ * the rule 2 sequence below
+ * anything else not reachable -> RT6_NUD_FAIL_DO_RR
+ * round-robin per 6.3.6 rule 2
+ * - RFC 4191 6.2.3 router probing is suppressed (see rt6_probe()),
+ * since soliciting a router that was not selected is treated as
+ * address resolution.
+ */
+static bool rt6_strict_router_select(struct net *net)
+{
+ return READ_ONCE(net->ipv6.sysctl.ip6_rt_strict_router_select);
+}
+
+#define RT6_STRICT_RANK_VALID 0x200
+#define RT6_STRICT_RANK_PROBING 0x100
+#define RT6_STRICT_RANK_UNREACH 0x000
+
+static int rt6_strict_reach_rank(const struct fib6_nh *fib6_nh)
+{
+ struct neighbour *neigh;
+ int rank = RT6_STRICT_RANK_UNREACH;
+
+ rcu_read_lock();
+ neigh = __ipv6_neigh_lookup_noref(fib6_nh->fib_nh_dev,
+ &fib6_nh->fib_nh_gw6);
+ if (neigh) {
+ u8 nud_state = READ_ONCE(neigh->nud_state);
+
+ if (nud_state & NUD_VALID)
+ rank = RT6_STRICT_RANK_VALID;
+ else if (nud_state & NUD_INCOMPLETE)
+ rank = RT6_STRICT_RANK_PROBING;
+ }
+ rcu_read_unlock();
+ return rank;
+}
+
#ifdef CONFIG_IPV6_ROUTER_PREF
struct __rt6_probe_work {
struct work_struct work;
@@ -693,6 +748,12 @@ static void rt6_probe(struct fib6_nh *fib6_nh)
if (!fib6_nh->fib_nh_gw_family)
return;
+ /* See rt6_strict_router_select(): no RFC 4191 6.2.3 probing in
+ * strict RFC 4861 6.3.6 mode.
+ */
+ if (rt6_strict_router_select(dev_net(fib6_nh->fib_nh_dev)))
+ return;
+
nh_gw = &fib6_nh->fib_nh_gw6;
dev = fib6_nh->fib_nh_dev;
rcu_read_lock();
@@ -786,7 +847,28 @@ static int rt6_score_route(const struct fib6_nh *nh, u32 fib6_flags, int oif,
#endif
if ((strict & RT6_LOOKUP_F_REACHABLE) &&
!(fib6_flags & RTF_NONEXTHOP) && nh->fib_nh_gw_family) {
- int n = rt6_check_neigh(nh);
+ int n;
+
+ /* Strict mode replaces the rt6_check_neigh() verdict with a
+ * reachability rank ORed above the device and preference
+ * scores (single neighbour lookup, no state races between
+ * two reads). Rank 0 means not reachable: hand back
+ * FAIL_DO_RR so find_match() scores the candidate 0 and
+ * round-robin applies (RFC 4861 6.3.6 rule 2). A non-zero
+ * rank (VALID or INCOMPLETE) outranks every DO_RR candidate;
+ * INCOMPLETE additionally keeps selection on the router whose
+ * solicitations are in flight, so unrelated concurrent lookups
+ * cannot rotate it away before resolution completes or fails.
+ */
+ if (rt6_strict_router_select(dev_net(nh->fib_nh_dev))) {
+ int rank = rt6_strict_reach_rank(nh);
+
+ if (!rank)
+ return RT6_NUD_FAIL_DO_RR;
+ return m | rank;
+ }
+
+ n = rt6_check_neigh(nh);
if (n < 0)
return n;
}
@@ -2282,7 +2364,11 @@ struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table,
strict |= flags & RT6_LOOKUP_F_IFACE;
strict |= flags & RT6_LOOKUP_F_IGNORE_LINKSTATE;
- if (READ_ONCE(net->ipv6.devconf_all->forwarding) == 0)
+ /* Strict mode applies reachability-based selection also with
+ * forwarding enabled, see rt6_strict_router_select().
+ */
+ if (READ_ONCE(net->ipv6.devconf_all->forwarding) == 0 ||
+ rt6_strict_router_select(net))
strict |= RT6_LOOKUP_F_REACHABLE;
rcu_read_lock();
@@ -6696,6 +6782,15 @@ static const struct ctl_table ipv6_route_table_template[] = {
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_ONE,
},
+ {
+ .procname = "strict_router_selection",
+ .data = &init_net.ipv6.sysctl.ip6_rt_strict_router_select,
+ .maxlen = sizeof(u8),
+ .mode = 0644,
+ .proc_handler = proc_dou8vec_minmax,
+ .extra1 = SYSCTL_ZERO,
+ .extra2 = SYSCTL_ONE,
+ },
};
struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
@@ -6719,6 +6814,7 @@ struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
table[8].data = &net->ipv6.sysctl.ip6_rt_min_advmss;
table[9].data = &net->ipv6.sysctl.ip6_rt_gc_min_interval;
table[10].data = &net->ipv6.sysctl.skip_notify_on_dev_down;
+ table[11].data = &net->ipv6.sysctl.ip6_rt_strict_router_select;
}
return table;
@@ -6795,6 +6891,7 @@ static int __net_init ip6_route_net_init(struct net *net)
net->ipv6.sysctl.ip6_rt_mtu_expires = 10*60*HZ;
net->ipv6.sysctl.ip6_rt_min_advmss = IPV6_MIN_MTU - 20 - 40;
net->ipv6.sysctl.skip_notify_on_dev_down = 0;
+ net->ipv6.sysctl.ip6_rt_strict_router_select = 0;
atomic_set(&net->ipv6.ip6_rt_gc_expire, 30*HZ);
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH net-next 2/2] selftests: net: add test for ipv6 strict_router_selection
2026-11-30 22:26 [PATCH net-next 0/2] net: ipv6: add strict RFC 4861 6.3.6 default router selection Florian Fainelli
2026-11-30 22:26 ` [PATCH net-next 1/2] " Florian Fainelli
@ 2026-11-30 22:26 ` Florian Fainelli
2026-12-04 4:27 ` netdev-bot+sashiko
2026-12-02 8:29 ` [PATCH net-next 0/2] net: ipv6: add strict RFC 4861 6.3.6 default router selection Ido Schimmel
2 siblings, 1 reply; 12+ messages in thread
From: Florian Fainelli @ 2026-11-30 22:26 UTC (permalink / raw)
To: netdev
Cc: Florian Fainelli, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Hideaki YOSHIFUJI, David Ahern, Shuah Khan,
Kuniyuki Iwashima, Jiayuan Chen, Angus Peng, Maoyi Xie, open list,
open list:KERNEL SELFTEST FRAMEWORK, bcm-kernel-feedback-list
Add a selftest for net.ipv6.route.strict_router_selection, which
enables strict RFC 4861 6.3.6 default router selection.
The test builds a single namespace with two same-metric default
routes, via fe80::1 on r1 and fe80::2 on r2, with r1 first in FIB leaf
order. Neighbour entries are set by hand, so no router needs to
answer anything. The selected router is read back with "ip route
get", both for locally generated traffic and, using "iif", for
forwarded traffic, which takes the ip6_pol_route_input() path where
the incoming ifindex is handed to route scoring as the oif.
The following is checked:
- the sysctl defaults to 0 and only accepts 0 and 1
- disabled: with forwarding on, neighbour state is ignored, FIB leaf
order decides and there is no round-robin
- enabled: a router with a valid neighbour entry beats one with a
failed or missing entry, in either leaf order, with forwarding on
and off, on the output and input paths
- enabled: unreachable routers are selected in round-robin, and a
reachable router stops the rotation
- enabled: a router whose address resolution is in progress stays
selected instead of being rotated away
- enabled: RFC 4191 preference only breaks ties between equally
reachable routers
- enabled: RFC 4191 6.2.3 router probing is suppressed, with a
positive control showing a neighbour solicitation is sent with the
sysctl off
The preference and probing tests need CONFIG_IPV6_ROUTER_PREF and are
skipped at runtime when it is not enabled.
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
tools/testing/selftests/net/Makefile | 1 +
.../net/ipv6_strict_router_select.sh | 507 ++++++++++++++++++
2 files changed, 508 insertions(+)
create mode 100755 tools/testing/selftests/net/ipv6_strict_router_select.sh
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index fb0a64662053..caa92d9ff0ae 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -59,6 +59,7 @@ TEST_PROGS := \
ipv6_flowlabel.sh \
ipv6_force_forwarding.sh \
ipv6_route_update_soft_lockup.sh \
+ ipv6_strict_router_select.sh \
ipvtap_test.sh \
l2_tos_ttl_inherit.sh \
l2tp.sh \
diff --git a/tools/testing/selftests/net/ipv6_strict_router_select.sh b/tools/testing/selftests/net/ipv6_strict_router_select.sh
new file mode 100755
index 000000000000..54500b25c967
--- /dev/null
+++ b/tools/testing/selftests/net/ipv6_strict_router_select.sh
@@ -0,0 +1,507 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# Test net.ipv6.route.strict_router_selection (strict RFC 4861 6.3.6 default
+# router selection).
+#
+# The device under test (DUT) has two default routers, fe80::1 behind r1 and
+# fe80::2 behind r2, installed as two same-metric default routes in the order
+# r1, r2 (i.e. r1 is first in FIB leaf order). Neighbour entries for the
+# routers are set up by hand, so no router has to answer anything, and the
+# selected router is read back with "ip route get", both for locally
+# generated traffic (output path) and for forwarded traffic (input path,
+# emulated with "iif").
+#
+# +---------------------------+
+# | DUT |
+# | dum0 | PEER (no IPv6, only absorbs frames)
+# | 2001:db8:100::1/64 |
+# | |
+# | r1 (gw fe80::1) ----------+--- r1p
+# | r2 (gw fe80::2) ----------+--- r2p
+# +---------------------------+
+#
+# Checked behaviour:
+# - the sysctl defaults to 0 and only accepts 0 and 1
+# - disabled: with forwarding on, neighbour state is ignored and FIB leaf
+# order decides (upstream behaviour, unchanged)
+# - enabled: a router with a valid neighbour entry beats a failed or missing
+# one, whatever the leaf order and with forwarding on or off, on the
+# output and on the input path
+# - enabled: unreachable routers are selected in round-robin
+# - enabled: a router whose resolution is in progress stays selected
+# - enabled: RFC 4191 preference only breaks ties between equally reachable
+# routers (needs CONFIG_IPV6_ROUTER_PREF)
+# - enabled: RFC 4191 6.2.3 router probing is suppressed (needs
+# CONFIG_IPV6_ROUTER_PREF)
+
+source lib.sh
+
+ALL_TESTS="
+ test_sysctl_default_range
+ test_disabled_forwarding_ignores_neigh
+ test_enabled_prefers_reachable
+ test_enabled_round_robin
+ test_enabled_incomplete_sticky
+ test_enabled_preference_tiebreak
+ test_enabled_no_probing
+"
+
+SYSCTL=net.ipv6.route.strict_router_selection
+
+GW1=fe80::1
+GW2=fe80::2
+# Used through indirect expansion in neigh_set()
+# shellcheck disable=SC2034
+LLADDR1=00:00:5e:00:53:01
+# shellcheck disable=SC2034
+LLADDR2=00:00:5e:00:53:02
+DST=2001:db8:ffff::1
+SRC_IN=2001:db8:100::2
+
+DUT=""
+PEER=""
+
+dut()
+{
+ ip netns exec "$DUT" "$@"
+}
+
+cleanup()
+{
+ # Kill any background ping before dropping the namespaces
+ [ -n "$ping_pid" ] && kill "$ping_pid" 2>/dev/null
+ cleanup_ns "$DUT" "$PEER"
+}
+
+setup()
+{
+ setup_ns DUT PEER || exit $ksft_skip
+
+ # No DAD, no RA/RS, no autoconf: the only NS sent on r1/r2 must be the
+ # ones we trigger ourselves. Shorten the router probe interval (in
+ # seconds, the smallest the sysctl allows) so that probing can be
+ # observed without waiting a minute. Set the defaults before the devices are
+ # created or moved so that they apply to them.
+ dut sysctl -qw net.ipv6.conf.default.dad_transmits=0 \
+ net.ipv6.conf.default.accept_ra=0 \
+ net.ipv6.conf.default.router_solicitations=0 \
+ net.ipv6.conf.default.autoconf=0 \
+ net.ipv6.conf.default.router_probe_interval=1 || exit $ksft_skip
+ ip netns exec "$PEER" sysctl -qw net.ipv6.conf.default.disable_ipv6=1 ||
+ exit $ksft_skip
+
+ ip -n "$DUT" link add dum0 type dummy || exit $ksft_skip
+ ip -n "$DUT" link add r1 type veth peer name r1p netns "$PEER" ||
+ exit $ksft_skip
+ ip -n "$DUT" link add r2 type veth peer name r2p netns "$PEER" ||
+ exit $ksft_skip
+
+ ip -n "$DUT" link set dum0 up
+ ip -n "$DUT" link set r1 up
+ ip -n "$DUT" link set r2 up
+ ip -n "$PEER" link set r1p up
+ ip -n "$PEER" link set r2p up
+
+ ip -n "$DUT" addr add 2001:db8:100::1/64 dev dum0 nodad
+
+ # Make sure link-local addresses are in place before routes use them
+ slowwait 5 dut_has_lladdr r1 || exit $ksft_skip
+ slowwait 5 dut_has_lladdr r2 || exit $ksft_skip
+}
+
+dut_has_lladdr()
+{
+ dut ip -6 addr show dev "$1" scope link | grep -q "inet6 fe80:.*scope link$" &&
+ ! dut ip -6 addr show dev "$1" scope link | grep -q tentative
+}
+
+# Pristine state for every test: both routes (and their fib6_nh and the
+# round-robin pointer) recreated, no neighbour entries, strict mode off and
+# forwarding on. Extra arguments are appended to the r1 and r2 routes
+# respectively, e.g. "pref low".
+reset_state()
+{
+ local r1_opts=$1
+ local r2_opts=$2
+
+ dut sysctl -qw "$SYSCTL=0" net.ipv6.conf.all.forwarding=1
+ while dut ip -6 route del default 2>/dev/null; do :; done
+ dut ip neigh del "$GW1" dev r1 2>/dev/null
+ dut ip neigh del "$GW2" dev r2 2>/dev/null
+
+ # "append" is needed to get two same-metric default routes
+ # shellcheck disable=SC2086
+ dut ip -6 route append default via "$GW1" dev r1 $r1_opts || return 1
+ # shellcheck disable=SC2086
+ dut ip -6 route append default via "$GW2" dev r2 $r2_opts || return 1
+}
+
+# neigh_set <1|2> <permanent|failed|none>
+neigh_set()
+{
+ local gw=GW$1 dev=r$1 ll=LLADDR$1
+
+ if [ "$2" = none ]; then
+ dut ip -6 neigh del "${!gw}" dev "$dev" 2>/dev/null
+ return 0
+ fi
+ dut ip -6 neigh replace "${!gw}" dev "$dev" lladdr "${!ll}" nud "$2"
+}
+
+# selected_gw <out|in>: print the gateway chosen by a single route lookup
+selected_gw()
+{
+ local path=$1
+
+ if [ "$path" = in ]; then
+ dut ip -6 route get "$DST" from "$SRC_IN" iif dum0
+ else
+ dut ip -6 route get "$DST"
+ fi | grep -o ' via [^ ]*' | head -n1 | cut -d' ' -f3
+}
+
+# selected_gws <out|in> <count>: gateways chosen by <count> lookups
+selected_gws()
+{
+ local path=$1 count=$2 i
+
+ for ((i = 0; i < count; i++)); do
+ selected_gw "$path"
+ done | tr '\n' ' '
+}
+
+# check_selected <out|in> <expected gw> <description>
+check_selected()
+{
+ local path=$1 exp=$2 desc=$3
+ local got
+
+ got=$(selected_gw "$path")
+ if [ "$got" != "$exp" ]; then
+ RET=$ksft_fail
+ retmsg="$desc: $path path selected '$got', expected '$exp'"
+ return 1
+ fi
+}
+
+# Lookup paths exercised by the tests. Output is a locally generated flow, in
+# is a forwarded flow: the input path hands the incoming ifindex to the route
+# scoring in place of the output interface, so the device score never matches.
+PATHS="out in"
+
+strict_supported()
+{
+ dut test -f /proc/sys/net/ipv6/route/strict_router_selection
+}
+
+# Preference support: build a case where only RFC 4191 preference can tell the
+# two routes apart (both valid, strict mode off, forwarding off so that
+# reachability-based selection is used) and see whether it is honoured.
+pref_supported()
+{
+ local ret=1
+
+ reset_state "pref low" "pref high" || return 1
+ neigh_set 1 permanent
+ neigh_set 2 permanent
+ dut sysctl -qw net.ipv6.conf.all.forwarding=0
+ [ "$(selected_gw out)" = "$GW2" ] && ret=0
+ reset_state
+ return $ret
+}
+
+test_sysctl_default_range()
+{
+ local val
+
+ RET=0
+
+ val=$(dut sysctl -n "$SYSCTL")
+ [ "$val" = 0 ] || {
+ RET=$ksft_fail
+ retmsg="default is '$val', expected 0"
+ }
+
+ dut sysctl -qw "$SYSCTL=1" 2>/dev/null
+ val=$(dut sysctl -n "$SYSCTL")
+ [ "$val" = 1 ] || {
+ RET=$ksft_fail
+ retmsg="could not set $SYSCTL to 1"
+ }
+
+ if dut sysctl -qw "$SYSCTL=2" 2>/dev/null; then
+ RET=$ksft_fail
+ retmsg="accepted out of range value 2"
+ fi
+
+ dut sysctl -qw "$SYSCTL=0"
+ log_test "strict_router_selection: sysctl default and range"
+}
+
+# Strict mode off: with forwarding on, reachability is not looked at at all and
+# the first route in leaf order wins even if its router is unreachable.
+test_disabled_forwarding_ignores_neigh()
+{
+ local path
+
+ RET=0
+
+ reset_state || { RET=$ksft_fail; retmsg="route setup failed"; }
+ neigh_set 1 failed
+ neigh_set 2 permanent
+ for path in $PATHS; do
+ check_selected "$path" "$GW1" "strict off, r1 failed, r2 valid"
+ done
+
+ # And no round-robin either with both routers unreachable
+ reset_state
+ local seq
+ for path in $PATHS; do
+ seq=$(selected_gws "$path" 4)
+ if [ "$seq" != "$GW1 $GW1 $GW1 $GW1 " ]; then
+ RET=$ksft_fail
+ retmsg="strict off, forwarding on: $path path rotated: $seq"
+ fi
+ done
+
+ log_test "strict_router_selection: disabled, forwarding on, neighbour state ignored"
+}
+
+test_enabled_prefers_reachable()
+{
+ local path fwd st1 st2 exp
+
+ RET=0
+
+ # <r1 state> <r2 state> <expected gw>
+ local cases=(
+ "failed permanent $GW2"
+ "none permanent $GW2"
+ "permanent failed $GW1"
+ "permanent none $GW1"
+ "permanent permanent $GW1"
+ )
+ local c
+
+ for fwd in 1 0; do
+ for c in "${cases[@]}"; do
+ read -r st1 st2 exp <<< "$c"
+
+ reset_state || { RET=$ksft_fail; retmsg="route setup failed"; }
+ dut sysctl -qw "$SYSCTL=1"
+ # Forwarding is already on after reset_state
+ [ "$fwd" = 1 ] ||
+ dut sysctl -qw net.ipv6.conf.all.forwarding=0
+ neigh_set 1 "$st1"
+ neigh_set 2 "$st2"
+ for path in $PATHS; do
+ check_selected "$path" "$exp" \
+ "forwarding $fwd, r1 $st1, r2 $st2"
+ done
+ done
+ done
+
+ log_test "strict_router_selection: enabled, reachable router preferred"
+}
+
+test_enabled_round_robin()
+{
+ local path seq
+
+ RET=0
+
+ reset_state || { RET=$ksft_fail; retmsg="route setup failed"; }
+ dut sysctl -qw "$SYSCTL=1"
+
+ # RFC 4861 6.3.6 rule 2: no router known reachable, rotate between them
+ for path in $PATHS; do
+ seq=$(selected_gws "$path" 4)
+ if [[ "$seq" != *"$GW1"* || "$seq" != *"$GW2"* ]]; then
+ RET=$ksft_fail
+ retmsg="$path path did not round-robin: $seq"
+ fi
+ done
+
+ # Same with FAILED entries
+ neigh_set 1 failed
+ neigh_set 2 failed
+ for path in $PATHS; do
+ seq=$(selected_gws "$path" 4)
+ if [[ "$seq" != *"$GW1"* || "$seq" != *"$GW2"* ]]; then
+ RET=$ksft_fail
+ retmsg="$path path did not round-robin with failed entries: $seq"
+ fi
+ done
+
+ # A known reachable router stops the rotation
+ neigh_set 2 permanent
+ for path in $PATHS; do
+ seq=$(selected_gws "$path" 4)
+ if [ "$seq" != "$GW2 $GW2 $GW2 $GW2 " ]; then
+ RET=$ksft_fail
+ retmsg="$path path kept rotating with a reachable router: $seq"
+ fi
+ done
+
+ log_test "strict_router_selection: enabled, round-robin of unreachable routers"
+}
+
+test_enabled_incomplete_sticky()
+{
+ local path seq
+
+ RET=0
+
+ reset_state || { RET=$ksft_fail; retmsg="route setup failed"; }
+ dut sysctl -qw "$SYSCTL=1"
+
+ # Stretch address resolution so that the entry stays INCOMPLETE for the
+ # whole test
+ dut sysctl -qw net.ipv6.neigh.r2.retrans_time_ms=20000
+
+ # Start resolving r2's address: NS goes out, nobody answers
+ dut ping -6 -c 1 -W 1 -I r2 "$GW2" &>/dev/null &
+ ping_pid=$!
+
+ if ! busywait "$BUSYWAIT_TIMEOUT" dut_neigh_incomplete r2 "$GW2"; then
+ kill "$ping_pid" 2>/dev/null
+ ping_pid=""
+ dut sysctl -qw net.ipv6.neigh.r2.retrans_time_ms=1000
+ log_test_skip "strict_router_selection: enabled, router being resolved stays selected" \
+ "could not get an INCOMPLETE neighbour entry"
+ return
+ fi
+
+ # r1 (first in leaf order) has no neighbour entry, r2 is being resolved:
+ # r2 must be selected every time, not rotated away.
+ for path in $PATHS; do
+ seq=$(selected_gws "$path" 4)
+ if [ "$seq" != "$GW2 $GW2 $GW2 $GW2 " ]; then
+ RET=$ksft_fail
+ retmsg="$path path rotated away from INCOMPLETE router: $seq"
+ fi
+ done
+
+ kill "$ping_pid" 2>/dev/null
+ ping_pid=""
+ dut sysctl -qw net.ipv6.neigh.r2.retrans_time_ms=1000
+
+ log_test "strict_router_selection: enabled, router being resolved stays selected"
+}
+
+dut_neigh_incomplete()
+{
+ dut ip -6 neigh show dev "$1" "$2" | grep -q INCOMPLETE
+}
+
+test_enabled_preference_tiebreak()
+{
+ local path
+
+ RET=0
+
+ if ! pref_supported; then
+ log_test_skip "strict_router_selection: enabled, preference breaks ties only" \
+ "CONFIG_IPV6_ROUTER_PREF not enabled"
+ return
+ fi
+
+ dut sysctl -qw "$SYSCTL=1"
+
+ # Equally reachable: preference decides
+ reset_state "pref low" "pref high" || { RET=$ksft_fail; retmsg="route setup failed"; }
+ dut sysctl -qw "$SYSCTL=1"
+ neigh_set 1 permanent
+ neigh_set 2 permanent
+ for path in $PATHS; do
+ check_selected "$path" "$GW2" "both valid, r2 pref high"
+ done
+
+ # Less preferred but reachable beats preferred but unreachable
+ reset_state "pref low" "pref high" || { RET=$ksft_fail; retmsg="route setup failed"; }
+ dut sysctl -qw "$SYSCTL=1"
+ neigh_set 1 permanent
+ neigh_set 2 failed
+ for path in $PATHS; do
+ check_selected "$path" "$GW1" "r1 pref low valid, r2 pref high failed"
+ done
+
+ reset_state "pref high" "pref low" || { RET=$ksft_fail; retmsg="route setup failed"; }
+ dut sysctl -qw "$SYSCTL=1"
+ neigh_set 1 none
+ neigh_set 2 permanent
+ for path in $PATHS; do
+ check_selected "$path" "$GW2" "r1 pref high missing, r2 pref low valid"
+ done
+
+ log_test "strict_router_selection: enabled, preference breaks ties only"
+}
+
+nsol_out()
+{
+ dut awk '/Icmp6OutNeighborSolicits/ { print $2 }' \
+ "/proc/net/dev_snmp6/$1"
+}
+
+test_enabled_no_probing()
+{
+ local before after
+
+ RET=0
+
+ # Positive control: without strict mode (and with reachability-based
+ # selection, i.e. forwarding off) a lookup probes the routers it has no
+ # neighbour entry for with an NS (RFC 4191 6.2.3)
+ reset_state || { RET=$ksft_fail; retmsg="route setup failed"; }
+ dut sysctl -qw net.ipv6.conf.all.forwarding=0
+ sleep 1.2 # let the (shortened) probe interval elapse
+ before=$(nsol_out r1)
+ selected_gw out > /dev/null
+ if ! slowwait 3 ns_nsol_increased r1 "$before"; then
+ log_test_skip "strict_router_selection: enabled, router probing suppressed" \
+ "router probing not available (CONFIG_IPV6_ROUTER_PREF)"
+ return
+ fi
+
+ # Same with strict mode: fresh routes (probe rate limit state is per
+ # route), no NS may leave
+ reset_state || { RET=$ksft_fail; retmsg="route setup failed"; }
+ dut sysctl -qw "$SYSCTL=1" net.ipv6.conf.all.forwarding=0
+ sleep 1.2
+ before=$(nsol_out r1)
+ selected_gw out > /dev/null
+ selected_gw in > /dev/null
+ sleep 1
+ after=$(nsol_out r1)
+ if [ "$after" != "$before" ]; then
+ RET=$ksft_fail
+ retmsg="r1 sent $((after - before)) NS in strict mode"
+ fi
+
+ log_test "strict_router_selection: enabled, router probing suppressed"
+}
+
+ns_nsol_increased()
+{
+ [ "$(nsol_out "$1")" -gt "$2" ]
+}
+
+trap cleanup EXIT
+ping_pid=""
+
+require_command ip
+require_command ping
+require_command awk
+
+setup
+if ! strict_supported; then
+ echo "SKIP: $SYSCTL not available"
+ exit $ksft_skip
+fi
+
+for t in $ALL_TESTS; do
+ $t
+done
+
+exit "$EXIT_STATUS"
--
2.34.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 0/2] net: ipv6: add strict RFC 4861 6.3.6 default router selection
2026-11-30 22:26 [PATCH net-next 0/2] net: ipv6: add strict RFC 4861 6.3.6 default router selection Florian Fainelli
2026-11-30 22:26 ` [PATCH net-next 1/2] " Florian Fainelli
2026-11-30 22:26 ` [PATCH net-next 2/2] selftests: net: add test for ipv6 strict_router_selection Florian Fainelli
@ 2026-12-02 8:29 ` Ido Schimmel
2026-12-02 23:37 ` Florian Fainelli
2 siblings, 1 reply; 12+ messages in thread
From: Ido Schimmel @ 2026-12-02 8:29 UTC (permalink / raw)
To: Florian Fainelli
Cc: netdev, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Hideaki YOSHIFUJI, David Ahern, Shuah Khan,
Kuniyuki Iwashima, Jiayuan Chen, Angus Peng, Maoyi Xie, open list,
open list:KERNEL SELFTEST FRAMEWORK, bcm-kernel-feedback-list
On Mon, Nov 30, 2026 at 02:26:29PM -0800, Florian Fainelli wrote:
> This patch series adds support for strict RFC 4861 section 6.3.6 default
> router selection along with a self test to exercise the newly added
> sysctl knob.
FYI, I don't see this in the review queue:
https://netdev.bots.linux.dev/suie.html?delegate=netdev
Most likely because the selftest was skipped:
https://netdev-ctrl.bots.linux.dev/logs/vmksft/net/results/934728/176-ipv6-strict-router-select-sh/stdout
Reproduce using:
https://github.com/linux-netdev/nipa/wiki/How-to-run-netdev-selftests-CI-style
Please resolve this and wait for the AI review before posting v2.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 0/2] net: ipv6: add strict RFC 4861 6.3.6 default router selection
2026-12-02 8:29 ` [PATCH net-next 0/2] net: ipv6: add strict RFC 4861 6.3.6 default router selection Ido Schimmel
@ 2026-12-02 23:37 ` Florian Fainelli
2026-12-03 8:08 ` Ido Schimmel
0 siblings, 1 reply; 12+ messages in thread
From: Florian Fainelli @ 2026-12-02 23:37 UTC (permalink / raw)
To: Ido Schimmel
Cc: netdev, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Hideaki YOSHIFUJI, David Ahern, Shuah Khan,
Kuniyuki Iwashima, Jiayuan Chen, Angus Peng, Maoyi Xie, open list,
open list:KERNEL SELFTEST FRAMEWORK, bcm-kernel-feedback-list
On 12/2/26 00:29, Ido Schimmel wrote:
> On Mon, Nov 30, 2026 at 02:26:29PM -0800, Florian Fainelli wrote:
>> This patch series adds support for strict RFC 4861 section 6.3.6 default
>> router selection along with a self test to exercise the newly added
>> sysctl knob.
>
> FYI, I don't see this in the review queue:
>
> https://netdev.bots.linux.dev/suie.html?delegate=netdev
>
> Most likely because the selftest was skipped:
>
> https://netdev-ctrl.bots.linux.dev/logs/vmksft/net/results/934728/176-ipv6-strict-router-select-sh/stdout
>
> Reproduce using:
>
> https://github.com/linux-netdev/nipa/wiki/How-to-run-netdev-selftests-CI-style
>
> Please resolve this and wait for the AI review before posting v2.
Thank you Ido, is the AI review going to happen if it is not in the
review queue?
--
Florian
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 0/2] net: ipv6: add strict RFC 4861 6.3.6 default router selection
2026-12-02 23:37 ` Florian Fainelli
@ 2026-12-03 8:08 ` Ido Schimmel
2026-12-03 17:25 ` Florian Fainelli
0 siblings, 1 reply; 12+ messages in thread
From: Ido Schimmel @ 2026-12-03 8:08 UTC (permalink / raw)
To: Florian Fainelli
Cc: netdev, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Hideaki YOSHIFUJI, David Ahern, Shuah Khan,
Kuniyuki Iwashima, Jiayuan Chen, Angus Peng, Maoyi Xie, open list,
open list:KERNEL SELFTEST FRAMEWORK, bcm-kernel-feedback-list
On Wed, Dec 02, 2026 at 03:37:22PM -0800, Florian Fainelli wrote:
> Thank you Ido, is the AI review going to happen if it is not in the review
> queue?
I see that it was already reviewed and currently embargoed:
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130222631.1786545-1-florian.fainelli%40broadcom.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 0/2] net: ipv6: add strict RFC 4861 6.3.6 default router selection
2026-12-03 8:08 ` Ido Schimmel
@ 2026-12-03 17:25 ` Florian Fainelli
2026-12-03 22:37 ` Nicolai Buchwitz
0 siblings, 1 reply; 12+ messages in thread
From: Florian Fainelli @ 2026-12-03 17:25 UTC (permalink / raw)
To: Ido Schimmel
Cc: netdev, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Hideaki YOSHIFUJI, David Ahern, Shuah Khan,
Kuniyuki Iwashima, Jiayuan Chen, Angus Peng, Maoyi Xie, open list,
open list:KERNEL SELFTEST FRAMEWORK, bcm-kernel-feedback-list
On 12/3/26 00:08, Ido Schimmel wrote:
> On Wed, Dec 02, 2026 at 03:37:22PM -0800, Florian Fainelli wrote:
>> Thank you Ido, is the AI review going to happen if it is not in the review
>> queue?
>
> I see that it was already reviewed and currently embargoed:
>
> https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130222631.1786545-1-florian.fainelli%40broadcom.com
OK, what does that mean exactly? Is there an explanation of the
terminology and the different states available somewhere?
--
Florian
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 0/2] net: ipv6: add strict RFC 4861 6.3.6 default router selection
2026-12-03 17:25 ` Florian Fainelli
@ 2026-12-03 22:37 ` Nicolai Buchwitz
0 siblings, 0 replies; 12+ messages in thread
From: Nicolai Buchwitz @ 2026-12-03 22:37 UTC (permalink / raw)
To: Florian Fainelli
Cc: Ido Schimmel, netdev, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Hideaki YOSHIFUJI, David Ahern,
Shuah Khan, Kuniyuki Iwashima, Jiayuan Chen, Angus Peng,
Maoyi Xie, open list, open list:KERNEL SELFTEST FRAMEWORK,
bcm-kernel-feedback-list
On 3.12.2026 18:25, Florian Fainelli wrote:
> On 12/3/26 00:08, Ido Schimmel wrote:
>> On Wed, Dec 02, 2026 at 03:37:22PM -0800, Florian Fainelli wrote:
>>> Thank you Ido, is the AI review going to happen if it is not in the
>>> review
>>> queue?
>>
>> I see that it was already reviewed and currently embargoed:
>>
>> https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130222631.1786545-1-florian.fainelli%40broadcom.com
>
> OK, what does that mean exactly? Is there an explanation of the
> terminology and the different states available somewhere?
That's the normal behavior.
Each series is held under embargo for a while (usually 24h or netdev,
longer over weekends to give maintainers time to breathe)
to prevent quick respins driven by the AI review [1], and to keep people
from using (cl|s)ashiko as a personal LLM reviewer.
I don't know of a written explanation of the states, but Roman's talk at
this year's LPC covers the whole flow. If I remember
correctly the embargo feature was developed esp. for netdev. Each
subsystem does this differently
Once the embargo ends, the review is public at the link above.
[1] https://lists.openwall.net/netdev/2026/11/23/395
Regards
Nicolai
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 1/2] net: ipv6: add strict RFC 4861 6.3.6 default router selection
2026-11-30 22:26 ` [PATCH net-next 1/2] " Florian Fainelli
@ 2026-12-04 4:27 ` netdev-bot+sashiko
2026-12-04 20:54 ` Florian Fainelli
0 siblings, 1 reply; 12+ messages in thread
From: netdev-bot+sashiko @ 2026-12-04 4:27 UTC (permalink / raw)
To: florian.fainelli
Cc: netdev, davem, edumazet, kuba, pabeni, yoshfuji, dsahern, shuah,
kuniyu, jiayuan.chen, angus.peng, maoyi.xie, linux-kernel,
linux-kselftest, bcm-kernel-feedback-list
Thank you for your contribution! Sashiko AI review found 9 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 4 · Low: 5
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The commit message, the block comment over
rt6_strict_router_select() and the sysctl documentation all say strict…
- [Medium] The commit message says that with probing suppressed,
"unreachable routers are recovered through round-robin and traffic-…
- [Medium] In strict mode, rt6_score_route() returns RT6_NUD_FAIL_DO_RR
(-1) for any gateway nexthop whose neighbour is missing, NUD_NONE or…
- [Medium] The strict reachability rank (0x100 for INCOMPLETE, 0x200 for
VALID) is only added in rt6_score_route() for routes with a gateway…
- [Low] RFC 4861 6.3.6 rule 1 puts routers in INCOMPLETE state and
routers with no Neighbor Cache entry in the same "unknown or suspect"…
- [Low] The in-tree documentation and code comment describe value 0 as
"upstream default router selection" (Documentation/networking/ip-…
- [Low] The sysctl is documented as "strict default router selection" for
a CPE learning default routers from RAs on its WAN, but the code is…
- [Low] The block comment above rt6_strict_router_select() says that
ranking NUD_INCOMPLETE routers above DO_RR keeps selection on the…
- [Low] ip6_rt_strict_router_select is read with READ_ONCE() several
times during a single route lookup: once in ip6_pol_route() to decide…
--
net: ipv6: add strict RFC 4861 6.3.6 default router selection
This adds a per-netns sysctl, net.ipv6.route.strict_router_selection.
When set, reachability-based router selection also applies with forwarding
enabled, and rt6_score_route() ranks candidates by neighbour state above
the device and RFC 4191 preference scores. In that mode rt6_probe() also
skips RFC 4191 router reachability probing.
> diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst
> index 671011c74e14c..0ea2d7818ea29 100644
> --- a/Documentation/networking/ip-sysctl.rst
> +++ b/Documentation/networking/ip-sysctl.rst
> @@ -2586,6 +2586,35 @@ skip_notify_on_dev_down - BOOLEAN
>
> Default: 0 (disabled)
>
> +route/strict_router_selection - BOOLEAN
> + Apply strict default router selection as described in RFC 4861
> + section 6.3.6.
> +
> + By default, neighbour reachability is only taken into account
> + when IPv6 forwarding is disabled, and a router with no neighbour
> + entry is considered reachable when CONFIG_IPV6_ROUTER_PREF is
> + enabled. When enabled, reachability is also considered when
> + forwarding is enabled, for example on a CPE that learns its
> + default routers from Router Advertisements on the WAN.
> +
> + Candidate routers are ranked by neighbour state first: routers
> + with a valid neighbour entry come first, then routers whose
> + address resolution is in progress, which stay selected until
> + resolution completes or fails. The device match and the RFC 4191
> + router preference (CONFIG_IPV6_ROUTER_PREF) only break ties
> + between routers of equal reachability. If no router is known to
> + be reachable, routers are selected in round-robin.
[Severity: Low]
Is the scope described here accurate? The text only mentions default router
selection. Once the sysctl is set, though, ip6_pol_route() sets
RT6_LOOKUP_F_REACHABLE for every lookup in the netns, including forwarded
traffic.
The strict branch in rt6_score_route() only checks this:
if ((strict & RT6_LOOKUP_F_REACHABLE) &&
!(fib6_flags & RTF_NONEXTHOP) && nh->fib_nh_gw_family) {
There is no RTF_DEFAULT or RTF_ADDRCONF check. Static gateway routes of any
prefix length are ranked by neighbour state too, including static ECMP
siblings, and probing is suppressed for them.
The last sentence also seems to conflict with the INCOMPLETE handling. A
NUD_INCOMPLETE router is not known to be reachable, but it gets
RT6_STRICT_RANK_PROBING (0x100). find_match() then leaves do_rr false, so
no round-robin happens while such a router exists.
Could the documentation cover both of these points?
> +
> + RFC 4191 section 6.2.3 router reachability probing is not
> + performed when enabled.
> +
> + Possible values:
> +
> + - 0 (disabled) - upstream default router selection
[Severity: Low]
This isn't a bug, but once this is merged the documentation is itself
upstream, so "upstream default router selection" no longer says what value
0 does. The block comment above rt6_strict_router_select() uses the same
wording ("default 0 = upstream behaviour, bit-for-bit").
Could both describe the behaviour directly? For example: reachability is
only considered when forwarding is disabled, and with
CONFIG_IPV6_ROUTER_PREF, routers without a neighbour entry are assumed
reachable.
[ ... ]
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index df843178e5ecc..d1795e91602e6 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -653,6 +653,61 @@ static void rt6_device_match(struct net *net, struct fib6_result *res,
> res->nh = nh;
> }
>
> +/* Strict RFC 4861 6.3.6 default router selection, runtime-controlled
> + * via net.ipv6.route.strict_router_selection (default 0 = upstream
> + * behaviour, bit-for-bit). When enabled:
> + * - reachability-based selection also applies with forwarding on
> + * (a CPE learns default routers from RAs on its WAN and must
> + * behave like a host there): see ip6_pol_route(),
> + * - candidate routers are ranked strictly by neighbour state in
> + * rt6_strict_reach_rank(), replacing the rt6_check_neigh() verdict
> + * entirely; the rank sits above the device score (bit 1) and the
> + * RFC 4191 preference score (bits 2+), so preference only breaks
> + * ties between equally reachable routers (RFC 4191 sec 3). The
[Severity: Medium]
Does this ordering actually follow RFC 4191? The commit message makes the
same claim ("so preference only breaks ties between equally reachable
routers as RFC 4191 section 3 requires"). It also lists this as a defect:
with CONFIG_IPV6_ROUTER_PREF enabled, a missing or unresolved
neighbor entry is scored as reachable
That scoring was added deliberately by commit 3630d40067a2 ("ipv6:
rt6_check_neigh should successfully verify neigh if no NUD information are
available"). That commit quotes RFC 4191:
"If the host has no information about the router's reachability, then
the host assumes the router is reachable."
Strict mode does the opposite. For a missing, NUD_NONE or NUD_FAILED
neighbour, rt6_strict_reach_rank() returns RT6_STRICT_RANK_UNREACH.
rt6_score_route() turns that into RT6_NUD_FAIL_DO_RR, and find_match()
scores it 0. That is below any VALID router (0x200), whatever the
preference.
As a result, a high-preference router the host knows nothing about loses
to a low-preference router with a VALID entry. Under RFC 4191 the
high-preference router would win. rt6_probe() also drops RFC 4191 router
probing in this mode.
Would it be more accurate for the commit message, this comment and
ip-sysctl.rst to describe this mode as RFC 4861 host behaviour with the
RFC 4191 changes turned off?
> + * reachability ordering itself does not depend on
> + * CONFIG_IPV6_ROUTER_PREF:
> + * NUD_VALID known/probably reachable -> highest rank
> + * NUD_INCOMPLETE resolution in progress -> middle rank; the
> + * router stays selected while its solicitations
> + * are in flight, so unrelated lookups cannot
> + * rotate away and spread NS across routers,
[Severity: Low]
Does this guarantee hold when lookups run concurrently? The rank only takes
effect once a neighbour entry exists and is NUD_INCOMPLETE. That entry is
created later, in the output path:
ip6_finish_output2()->__neigh_create()->__neigh_event_send()
Nothing orders that against the rr_ptr rotation in rt6_select(). For
example, with three routers R1, R2 and R3 and no neighbour entries yet:
CPU0
rt6_select()
R1 scores DO_RR, R1 selected, rr_ptr rotated to R2
CPU1, before CPU0's packet creates R1's neighbour
rt6_select()
R1 and R2 still score DO_RR, R2 selected, rr_ptr rotated to R3
CPU2
rt6_select()
R3 selected
All three routers are then solicited at once. tb6_lock only serialises the
rr_ptr store.
There is also a short window where a new neighbour is NUD_NONE (rank 0)
before __neigh_event_send() moves it to NUD_INCOMPLETE.
The outcome is harmless, because the first router to become VALID wins.
Could the comment be reworded so it does not claim a guarantee?
[ ... ]
> +static int rt6_strict_reach_rank(const struct fib6_nh *fib6_nh)
> +{
> + struct neighbour *neigh;
> + int rank = RT6_STRICT_RANK_UNREACH;
> +
> + rcu_read_lock();
> + neigh = __ipv6_neigh_lookup_noref(fib6_nh->fib_nh_dev,
> + &fib6_nh->fib_nh_gw6);
> + if (neigh) {
> + u8 nud_state = READ_ONCE(neigh->nud_state);
> +
> + if (nud_state & NUD_VALID)
> + rank = RT6_STRICT_RANK_VALID;
> + else if (nud_state & NUD_INCOMPLETE)
> + rank = RT6_STRICT_RANK_PROBING;
[Severity: Low]
This isn't a bug, but it departs from the RFC the mode is named after. RFC
4861 6.3.6 rule 1 puts routers in INCOMPLETE state and routers with no
Neighbor Cache entry in the same "unknown or suspect" class. Rule 2 then
requires round-robin among them.
Here NUD_INCOMPLETE gets its own middle rank, above no-entry, NUD_NONE and
NUD_FAILED. While any router is INCOMPLETE, find_match() picks it, do_rr
stays false, and rt6_select() never advances rr_ptr.
The code comment and ip-sysctl.rst present this as a deliberate choice. The
subject, the commit message and the sysctl name still call it "strict RFC
4861 section 6.3.6" selection.
Could the commit message mention this departure from rules 1 and 2?
[ ... ]
> @@ -693,6 +748,12 @@ static void rt6_probe(struct fib6_nh *fib6_nh)
> if (!fib6_nh->fib_nh_gw_family)
> return;
>
> + /* See rt6_strict_router_select(): no RFC 4191 6.2.3 probing in
> + * strict RFC 4861 6.3.6 mode.
> + */
> + if (rt6_strict_router_select(dev_net(fib6_nh->fib_nh_dev)))
> + return;
[Severity: Medium]
Can a router that failed once stay deselected indefinitely after it comes
back? The commit message says:
unreachable routers are recovered through round-robin and
traffic-driven resolution instead.
That only works when no candidate is VALID or INCOMPLETE. A VALID candidate
scores m | 0x200. A FAILED, NONE or missing router returns
RT6_NUD_FAIL_DO_RR, which find_match() scores as 0. find_match() only takes
do_rr from the winner:
if (m > *mpri) {
*do_rr = match_do_rr;
*mpri = m;
rc = true;
}
So do_rr stays false and rt6_select() never rotates. The deselected router
gets no traffic, so no traffic-driven resolution happens. With this early
return, no NS is sent to it either.
That leaves inbound ND as the only way back. For an RA without a Source
Link-Layer Address option, ndisc_router_discovery() calls ndisc_update()
with lladdr == NULL and NUD_STALE. __neigh_update() rejects that when the
old state is not NUD_VALID:
err = -EINVAL;
if (!(old & NUD_VALID)) {
NL_SET_ERR_MSG(extack, "No link layer address given");
goto out;
}
Take R1 (high preference) FAILED and R2 (low preference) STALE or
REACHABLE. R2 is used until R1 sends an RA with SLLA, which is optional in
RFC 4861, or an NS.
Before this patch, a CONFIG_IPV6_ROUTER_PREF=y host scored R1 as
RT6_NUD_FAIL_PROBE and probed it once per rtr_probe_interval.
The reason given for suppressing all probing does not seem to apply while
a VALID router exists. A probe would move R1 to INCOMPLETE (0x100). That is
still below VALID (0x200), so the selection could not change until R1
answers.
Could probing be kept in that case?
> nh_gw = &fib6_nh->fib_nh_gw6;
> dev = fib6_nh->fib_nh_dev;
> rcu_read_lock();
> @@ -786,7 +847,28 @@ static int rt6_score_route(const struct fib6_nh *nh, u32 fib6_flags, int oif,
> #endif
> if ((strict & RT6_LOOKUP_F_REACHABLE) &&
> !(fib6_flags & RTF_NONEXTHOP) && nh->fib_nh_gw_family) {
> - int n = rt6_check_neigh(nh);
> + int n;
> +
> + /* Strict mode replaces the rt6_check_neigh() verdict with a
> + * reachability rank ORed above the device and preference
> + * scores (single neighbour lookup, no state races between
> + * two reads). Rank 0 means not reachable: hand back
> + * FAIL_DO_RR so find_match() scores the candidate 0 and
> + * round-robin applies (RFC 4861 6.3.6 rule 2). A non-zero
> + * rank (VALID or INCOMPLETE) outranks every DO_RR candidate;
> + * INCOMPLETE additionally keeps selection on the router whose
> + * solicitations are in flight, so unrelated concurrent lookups
> + * cannot rotate it away before resolution completes or fails.
> + */
> + if (rt6_strict_router_select(dev_net(nh->fib_nh_dev))) {
> + int rank = rt6_strict_reach_rank(nh);
> +
> + if (!rank)
> + return RT6_NUD_FAIL_DO_RR;
[Severity: Medium]
The comment above only describes find_match(), but fib6_select_path() also
calls rt6_score_route(). What happens to legacy ECMP siblings there?
fib6_select_path() treats any negative score as an unusable sibling:
if (rt6_score_route(first->fib6_nh, first->fib6_flags, oif,
strict) >= 0)
match = first;
...
if (rt6_score_route(nh, sibling->fib6_flags, oif, strict) < 0)
break;
ip6_pol_route() now passes RT6_LOOKUP_F_REACHABLE for every lookup,
including forwarded traffic.
Take a static multipath route on a forwarding router, via fe80::a (A) dev
eth1 and fe80::b (B) dev eth2. A is VALID or INCOMPLETE, and B is missing
or FAILED. rt6_select() picks A. Every hash bucket owned by B breaks out on
-1 and falls back to A.
rt6_probe() also returns early in strict mode, so B is never solicited. B
carries no traffic either, so it is never resolved, or re-resolved after a
failure, unless the gateway itself sends ND.
Before this patch, a forwarding router ignored neighbour state in
fib6_select_path(). Nexthop-object multipath also treats a missing
neighbour as good, in ipv6_good_nh():
int state = NUD_REACHABLE;
So under the same sysctl, ECMP behaves differently for nexthop objects and
legacy siblings. Is that intended?
> + return m | rank;
[Severity: Medium]
How does this rank compare with gateway-less routes in the same leaf?
Those skip this block and score at most 0xe (2 | 3 << 2). Consider two
routes at the same metric:
ip -6 route add default dev ppp0
default via fe80::1 dev wan0 (from an RA)
Neither route qualifies for ECMP, so both exist side by side at metric
1024.
While fe80::1 is only NUD_INCOMPLETE, it is not known to be reachable, yet
the gateway route scores m | 0x100 and beats the device route. Packets then
queue or are dropped behind a router that may be dead, until it goes
FAILED and drops to rank 0.
Once fe80::1 is VALID, a low-preference RA route (2 | 1 << 2 | 0x200) beats
a medium-preference device route (0xa), whatever the RFC 4191 preference.
Before this patch, a CONFIG_IPV6_ROUTER_PREF=y host picked the device route
on preference.
Doesn't this conflict with the stated rule that preference only breaks ties
between equally reachable candidates? A device route needs no router
resolution, yet it ranks below every gateway that is not FAILED or missing.
> }
> +
> + n = rt6_check_neigh(nh);
> if (n < 0)
> return n;
> }
> @@ -2282,7 +2364,11 @@ struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table,
>
> strict |= flags & RT6_LOOKUP_F_IFACE;
> strict |= flags & RT6_LOOKUP_F_IGNORE_LINKSTATE;
> - if (READ_ONCE(net->ipv6.devconf_all->forwarding) == 0)
> + /* Strict mode applies reachability-based selection also with
> + * forwarding enabled, see rt6_strict_router_select().
> + */
> + if (READ_ONCE(net->ipv6.devconf_all->forwarding) == 0 ||
> + rt6_strict_router_select(net))
> strict |= RT6_LOOKUP_F_REACHABLE;
[Severity: Low]
Can a single lookup see the sysctl change partway through? It is read here,
then again for each candidate in rt6_score_route() (from both find_match()
and fib6_select_path()), and again in rt6_probe().
If an admin writes the sysctl at the same time, candidates in the same
__find_rr_leaf() pass can be scored on different scales. Some get legacy
rt6_check_neigh() scoring (at most 0xe), others get m | 0x100 or
m | 0x200.
On a forwarding router, a change from 1 to 0 after this point also runs
the legacy rt6_check_neigh() path with forwarding on, which neither mode
intends.
Would it be cleaner to read the sysctl once here and carry the result in
strict as a new RT6_LOOKUP_F_* bit? That would also remove the dev_net()
lookups for each candidate.
>
> rcu_read_lock();
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130222631.1786545-1-florian.fainelli%40broadcom.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 2/2] selftests: net: add test for ipv6 strict_router_selection
2026-11-30 22:26 ` [PATCH net-next 2/2] selftests: net: add test for ipv6 strict_router_selection Florian Fainelli
@ 2026-12-04 4:27 ` netdev-bot+sashiko
2026-12-04 19:52 ` Florian Fainelli
0 siblings, 1 reply; 12+ messages in thread
From: netdev-bot+sashiko @ 2026-12-04 4:27 UTC (permalink / raw)
To: florian.fainelli
Cc: netdev, davem, edumazet, kuba, pabeni, yoshfuji, dsahern, shuah,
kuniyu, jiayuan.chen, angus.peng, maoyi.xie, linux-kernel,
linux-kselftest, bcm-kernel-feedback-list
Thank you for your contribution! Sashiko AI review found 8 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 5 · Low: 3
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] dut_has_lladdr() in
tools/testing/selftests/net/ipv6_strict_router_select.sh (line 115)…
- [Medium] reset_state() (lines 135/137) creates the two default routes
with `ip -6 route append default via fe80::N dev rN`.
- [Medium] The strict-mode ranking added by commit "net: ipv6: add strict
RFC 4861 6.3.6 default router selection" does not hold for ECMP…
- [Medium] pref_supported() and the positive control in
test_enabled_no_probing() infer the kernel config from runtime…
- [Medium] setup() writes net.ipv6.conf.default.router_probe_interval=1
in the same sysctl command as the required…
- [Low] The setup() comment (line 83) says router_probe_interval=1 second
is "the smallest the sysctl allows".
- [Low] ip-sysctl.rst and the RT6_STRICT_RANK_* constants (VALID 0x200 >
PROBING 0x100 > UNREACH 0) define three reachability tiers.
- [Low] test_enabled_incomplete_sticky() starts the resolver with `dut
ping -6 -c 1 -W 1 -I r2 "$GW2" &>/dev/null &` (line 364).
--
selftests: net: add test for ipv6 strict_router_selection
This adds a selftest for net.ipv6.route.strict_router_selection. It builds
a namespace with two same-metric default routes via fe80::1 and fe80::2
and sets the neighbour entries by hand. It then reads back the selected
router with "ip route get" on the output and input paths.
> diff --git a/tools/testing/selftests/net/ipv6_strict_router_select.sh b/tools/testing/selftests/net/ipv6_strict_router_select.sh
> new file mode 100755
> index 0000000000000..54500b25c9674
> --- /dev/null
> +++ b/tools/testing/selftests/net/ipv6_strict_router_select.sh
> @@ -0,0 +1,507 @@
[ ... ]
> +setup()
> +{
> + setup_ns DUT PEER || exit $ksft_skip
> +
> + # No DAD, no RA/RS, no autoconf: the only NS sent on r1/r2 must be the
> + # ones we trigger ourselves. Shorten the router probe interval (in
> + # seconds, the smallest the sysctl allows) so that probing can be
[Severity: Low]
This isn't a bug, but is "the smallest the sysctl allows" accurate? The
router_probe_interval entry in net/ipv6/addrconf.c uses
proc_dointvec_jiffies with no extra1/extra2 bounds, so 0 is also accepted.
1 is only the smallest non-zero value the seconds interface can express.
> + # observed without waiting a minute. Set the defaults before the devices are
> + # created or moved so that they apply to them.
> + dut sysctl -qw net.ipv6.conf.default.dad_transmits=0 \
> + net.ipv6.conf.default.accept_ra=0 \
> + net.ipv6.conf.default.router_solicitations=0 \
> + net.ipv6.conf.default.autoconf=0 \
> + net.ipv6.conf.default.router_probe_interval=1 || exit $ksft_skip
[Severity: Medium]
Will this skip the whole suite on kernels without CONFIG_IPV6_ROUTER_PREF?
In net/ipv6/addrconf.c the router_probe_interval ctl_table entry is only
registered under #ifdef CONFIG_IPV6_ROUTER_PREF. On those kernels this
sysctl write fails and setup() exits with $ksft_skip.
That also skips the sysctl range, prefers-reachable, round-robin and
incomplete-sticky tests, none of which need ROUTER_PREF. Strict mode on
ROUTER_PREF=n kernels, where the non-strict rt6_check_neigh() behaviour
is different, is never tested either.
The commit message says:
The preference and probing tests need CONFIG_IPV6_ROUTER_PREF and are
skipped at runtime when it is not enabled.
Those per-test skips can't be reached in that configuration. Could the
router_probe_interval write be done separately, without the exit?
[ ... ]
> + # Make sure link-local addresses are in place before routes use them
> + slowwait 5 dut_has_lladdr r1 || exit $ksft_skip
> + slowwait 5 dut_has_lladdr r2 || exit $ksft_skip
> +}
> +
> +dut_has_lladdr()
> +{
> + dut ip -6 addr show dev "$1" scope link | grep -q "inet6 fe80:.*scope link$" &&
[Severity: Medium]
Can the "scope link$" pattern ever match? iproute2 prints the scope as
"scope %s ", which leaves a trailing space. The kernel also sets
IFAPROT_KERNEL_LL on autoconfigured link-local addresses and emits it:
net/ipv6/addrconf.c:inet6_fill_ifaddr() {
...
if (proto && nla_put_u8(skb, IFA_PROTO, proto))
...
}
So the line reads "inet6 fe80::x/64 scope link proto kernel_ll ", or
"... scope link " with older iproute2. Neither ends in "scope link".
If that's right, slowwait 5 dut_has_lladdr r1 always times out. setup()
then exits with $ksft_skip before strict_supported() or any test in
ALL_TESTS runs.
Doesn't that mean the script always reports a skip without giving a
reason, so none of the new cases ever run?
> + ! dut ip -6 addr show dev "$1" scope link | grep -q tentative
> +}
[ ... ]
> + # "append" is needed to get two same-metric default routes
> + # shellcheck disable=SC2086
> + dut ip -6 route append default via "$GW1" dev r1 $r1_opts || return 1
> + # shellcheck disable=SC2086
> + dut ip -6 route append default via "$GW2" dev r2 $r2_opts || return 1
> +}
[Severity: Medium]
Do these two routes become ECMP siblings instead of independent routes in
leaf order? Both are static gateway routes with the same metric and no
nexthop object. So rt6_qualify_for_ecmp() is true and fib6_add_rt2node()
links them:
net/ipv6/ip6_fib.c:fib6_add_rt2node() {
...
if (rt_can_ecmp &&
rt6_qualify_for_ecmp(iter))
WRITE_ONCE(rt->fib6_nsiblings,
rt->fib6_nsiblings + 1);
...
}
In ip6_pol_route(), have_oif_match is false on both the output path and
the iif path. fib6_select_path() therefore hashes the flow with a seed
picked at random once per boot. Whenever the hashed sibling's score is
non-negative, it replaces the rt6_select() choice:
net/ipv6/route.c:fib6_select_path() {
...
if (rt6_score_route(nh, sibling->fib6_flags, oif, strict) < 0)
break;
match = sibling;
...
}
With this, the following expectations depend on the hash and not on
leaf order:
test_disabled_forwarding_ignores_neigh(): GW1, and GW1 four times
test_enabled_prefers_reachable(): "permanent permanent $GW1"
pref_supported(): the out path must return GW2
test_enabled_preference_tiebreak(): GW2 on both paths, both valid
The out flow and the in flow each land in one half for the whole boot.
The disabled test needs both flows in r1's half, and the preference tests
need both in r2's half.
On a CONFIG_IPV6_ROUTER_PREF=y kernel, wouldn't the suite fail on most
boots? On the others, it would pass only because pref_supported() skips
the preference test.
Strict-mode cases with one unreachable sibling are not affected, because
RT6_NUD_FAIL_DO_RR is negative and keeps the rt6_select() result.
The commit message says:
The test builds a single namespace with two same-metric default
routes, via fe80::1 on r1 and fe80::2 on r2, with r1 first in FIB leaf
order.
and:
- disabled: with forwarding on, neighbour state is ignored, FIB leaf
order decides and there is no round-robin
Neither seems to hold for this topology. The topology also doesn't model
the RA-learned (RTF_ADDRCONF) routes the feature targets, since those
never become ECMP siblings.
Could the routes be built so that they can't coalesce, for example with
separate nhid nexthop objects, or as RA-learned routes?
[ ... ]
> + # Start resolving r2's address: NS goes out, nobody answers
> + dut ping -6 -c 1 -W 1 -I r2 "$GW2" &>/dev/null &
> + ping_pid=$!
[Severity: Low]
Is ping_pid really ping's PID? dut is a shell function, so backgrounding
it forks a bash subshell that runs the function body. $! is that
subshell's PID, and ip netns exec (and then ping) runs as its child.
If so, the kill "$ping_pid" calls on the skip path, on the normal path
and in cleanup() only signal the subshell. The cleanup() comment "Kill
any background ping before dropping the namespaces" would then be
inaccurate.
The impact is small, since ping exits on its own after -W 1 and
cleanup_ns() kills any processes left in the namespace.
> +
> + if ! busywait "$BUSYWAIT_TIMEOUT" dut_neigh_incomplete r2 "$GW2"; then
[ ... ]
> + # r1 (first in leaf order) has no neighbour entry, r2 is being resolved:
> + # r2 must be selected every time, not rotated away.
> + for path in $PATHS; do
> + seq=$(selected_gws "$path" 4)
> + if [ "$seq" != "$GW2 $GW2 $GW2 $GW2 " ]; then
[Severity: Low]
This only compares a missing entry with an INCOMPLETE one. No case in the
script puts a valid router against an INCOMPLETE one. Would the test still
pass if RT6_STRICT_RANK_PROBING were ranked equal to or above
RT6_STRICT_RANK_VALID?
A case with r1 INCOMPLETE and r2 permanent, expecting r2, would cover the
middle rank.
[Severity: Medium]
Related to the ECMP question above: does the strict-mode ranking from
"net: ipv6: add strict RFC 4861 6.3.6 default router selection" hold for
sibling routes? rt6_score_route() gives an INCOMPLETE neighbour a
non-negative score:
net/ipv6/route.c:rt6_score_route() {
...
if (!rank)
return RT6_NUD_FAIL_DO_RR;
return m | rank;
...
}
fib6_select_path() only rejects the hashed sibling when the score is
negative. With r1 valid and r2 INCOMPLETE as siblings, rt6_select() picks
r1. Wouldn't every flow that hashes into r2's half still go to the
unresolved r2?
That seems to contradict Documentation/networking/ip-sysctl.rst:
Candidate routers are ranked by neighbour state first: routers
with a valid neighbour entry come first, then routers whose
address resolution is in progress
RFC 4191 preference between two valid siblings is also ignored, because
the hash decides. The wrong choice only lasts until resolution completes
or fails. It also needs a static ECMP setup, since RA-learned routes are
not ECMP-eligible.
Neither the commit message nor ip-sysctl.rst mentions this limitation.
Should it be handled in fib6_select_path(), or at least be documented?
[ ... ]
> +test_enabled_preference_tiebreak()
> +{
> + local path
> +
> + RET=0
> +
> + if ! pref_supported; then
> + log_test_skip "strict_router_selection: enabled, preference breaks ties only" \
> + "CONFIG_IPV6_ROUTER_PREF not enabled"
> + return
> + fi
[Severity: Medium]
Does a pref_supported() failure always mean the config is missing? Any
lookup that doesn't return GW2 is reported as a skip with this reason.
That includes a real regression in preference scoring, or the ECMP hash
landing on r1.
The positive control in test_enabled_no_probing() has the same problem:
if ! slowwait 3 ns_nsol_increased r1 "$before"; then
log_test_skip "strict_router_selection: enabled, router probing suppressed" \
"router probing not available (CONFIG_IPV6_ROUTER_PREF)"
Here, if no NS goes out within 3 seconds for any reason, including an
rt6_probe() regression, the test reports a skip.
tools/testing/selftests/net/config sets CONFIG_IPV6_ROUTER_PREF=y, so on
CI kernels these real failures would show up as skips. The code also
doesn't match the commit message, which says these tests are skipped only
when CONFIG_IPV6_ROUTER_PREF is not enabled.
Could these checks report a failure when the config is enabled?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130222631.1786545-1-florian.fainelli%40broadcom.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 2/2] selftests: net: add test for ipv6 strict_router_selection
2026-12-04 4:27 ` netdev-bot+sashiko
@ 2026-12-04 19:52 ` Florian Fainelli
0 siblings, 0 replies; 12+ messages in thread
From: Florian Fainelli @ 2026-12-04 19:52 UTC (permalink / raw)
To: netdev-bot+sashiko
Cc: netdev, davem, edumazet, kuba, pabeni, yoshfuji, dsahern, shuah,
kuniyu, jiayuan.chen, angus.peng, maoyi.xie, linux-kernel,
linux-kselftest, bcm-kernel-feedback-list
On 12/3/26 20:27, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 8 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 5 · Low: 3
>
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork
> know by including "pw-bot: cr" as a separate line at the end of your reply
> (one such reply per series is enough).
>
> - [Medium] dut_has_lladdr() in
> tools/testing/selftests/net/ipv6_strict_router_select.sh (line 115)…
> - [Medium] reset_state() (lines 135/137) creates the two default routes
> with `ip -6 route append default via fe80::N dev rN`.
> - [Medium] The strict-mode ranking added by commit "net: ipv6: add strict
> RFC 4861 6.3.6 default router selection" does not hold for ECMP…
> - [Medium] pref_supported() and the positive control in
> test_enabled_no_probing() infer the kernel config from runtime…
> - [Medium] setup() writes net.ipv6.conf.default.router_probe_interval=1
> in the same sysctl command as the required…
> - [Low] The setup() comment (line 83) says router_probe_interval=1 second
> is "the smallest the sysctl allows".
> - [Low] ip-sysctl.rst and the RT6_STRICT_RANK_* constants (VALID 0x200 >
> PROBING 0x100 > UNREACH 0) define three reachability tiers.
> - [Low] test_enabled_incomplete_sticky() starts the resolver with `dut
> ping -6 -c 1 -W 1 -I r2 "$GW2" &>/dev/null &` (line 364).
All five Medium points are addressed in v2. The scope link$ match, the
ECMP-coalesced routes (now nexthop objects) and the hard skip on
router_probe_interval were real and are fixed. CONFIG_IPV6_ROUTER_PREF
is now detected from the sysctl it registers, so the preference and
probing tests fail on a regression instead of skipping. The ECMP-sibling
ranking limitation is now documented in the commit message and
ip-sysctl.rst. The three Low points are fixed too.
pw-bot: cr
--
Florian
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 1/2] net: ipv6: add strict RFC 4861 6.3.6 default router selection
2026-12-04 4:27 ` netdev-bot+sashiko
@ 2026-12-04 20:54 ` Florian Fainelli
0 siblings, 0 replies; 12+ messages in thread
From: Florian Fainelli @ 2026-12-04 20:54 UTC (permalink / raw)
To: netdev-bot+sashiko
Cc: netdev, davem, edumazet, kuba, pabeni, yoshfuji, dsahern, shuah,
kuniyu, jiayuan.chen, angus.peng, maoyi.xie, linux-kernel,
linux-kselftest, bcm-kernel-feedback-list
On 12/3/26 20:27, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 9 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 4 · Low: 5
>
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork
> know by including "pw-bot: cr" as a separate line at the end of your reply
> (one such reply per series is enough).
>
> - [Medium] The commit message, the block comment over
> rt6_strict_router_select() and the sysctl documentation all say strict…
Right, the wording was wrong. Strict mode ranks a router without a
neighbour entry below a reachable one whatever its preference, which is
the opposite of the "assume reachable" rule that 3630d40067a2 implements
from RFC 4191. v2 describes the mode as RFC 4861 host behaviour with the
RFC 4191 reachability assumption turned off, in all three places.
> - [Medium] The commit message says that with probing suppressed,
> "unreachable routers are recovered through round-robin and traffic-…
Agreed, and the commit message claim was inaccurate: round-robin and
traffic-driven resolution only recover routers while no router is
reachable. v2 states that a router which is unreachable while another
one is valid carries no traffic and is not solicited, and is used again
once it sends an RA with a Source Link-Layer Address option or an NS.
It si correct that probing it would be harmless while a valid router
exists, since INCOMPLETE ranks below VALID. v2 keeps probing suppressed
unconditionally to keep the mode simple, and documents the consequence
rather than hiding it. When no router is valid, a probe would put the
probed router in INCOMPLETE, which outranks the round-robin candidates
and defeats rule 2, which is why it cannot simply be left on.
> - [Medium] In strict mode, rt6_score_route() returns RT6_NUD_FAIL_DO_RR
> (-1) for any gateway nexthop whose neighbour is missing, NUD_NONE or…
The mode is meant for netns whose routers are learned from RAs, which
are never ECMP siblings. For legacy multipath routes, v2 documents the
behaviour in the commit message and in ip-sysctl.rst: a sibling whose
score is negative (unresolved or failed) is skipped, and otherwise the
flow hash decides, so neither the ranking of INCOMPLETE below VALID nor
the router preference applies among siblings. Nexthop objects keep their
existing ipv6_good_nh() behaviour.
> - [Medium] The strict reachability rank (0x100 for INCOMPLETE, 0x200 for
> VALID) is only added in rt6_score_route() for routes with a gateway…
Same answer: the ranking applies to routes with a gateway and gateway-
less routes are not ranked, so they lose to any gateway that is
reachable or being resolved. This is now stated in the sysctl
documentation and in the commit message instead of being implied.
> - [Low] RFC 4861 6.3.6 rule 1 puts routers in INCOMPLETE state and
> routers with no Neighbor Cache entry in the same "unknown or suspect"…
> - [Low] The in-tree documentation and code comment describe value 0 as
> "upstream default router selection" (Documentation/networking/ip-…
> - [Low] The sysctl is documented as "strict default router selection" for
> a CPE learning default routers from RAs on its WAN, but the code is…
> - [Low] The block comment above rt6_strict_router_select() says that
> ranking NUD_INCOMPLETE routers above DO_RR keeps selection on the…
> - [Low] ip6_rt_strict_router_select is read with READ_ONCE() several
> times during a single route lookup: once in ip6_pol_route() to decide…
- the documentation and comment no longer call value 0 "upstream
behaviour", they describe what it does
- the scope (every route with a gateway, not only default routes) and
the INCOMPLETE rank (a departure from rule 1, and no rotation while such
a router exists) are documented, and the "round-robin" sentence now says
"none known reachable and none being resolved"
- the comment no longer claims a guarantee under concurrent lookups
- the sysctl is sampled once in ip6_pol_route() and passed down as
RT6_LOOKUP_F_STRICT_RTR, which also drops the per-candidate dev_net()
lookups and the rt6_probe() early return.
pw-bot: cr
--
Florian
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2026-12-04 20:54 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 22:26 [PATCH net-next 0/2] net: ipv6: add strict RFC 4861 6.3.6 default router selection Florian Fainelli
2026-11-30 22:26 ` [PATCH net-next 1/2] " Florian Fainelli
2026-12-04 4:27 ` netdev-bot+sashiko
2026-12-04 20:54 ` Florian Fainelli
2026-11-30 22:26 ` [PATCH net-next 2/2] selftests: net: add test for ipv6 strict_router_selection Florian Fainelli
2026-12-04 4:27 ` netdev-bot+sashiko
2026-12-04 19:52 ` Florian Fainelli
2026-12-02 8:29 ` [PATCH net-next 0/2] net: ipv6: add strict RFC 4861 6.3.6 default router selection Ido Schimmel
2026-12-02 23:37 ` Florian Fainelli
2026-12-03 8:08 ` Ido Schimmel
2026-12-03 17:25 ` Florian Fainelli
2026-12-03 22:37 ` Nicolai Buchwitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox