From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796358432; b=s/5Ncio1PfpLbyG27WQInFtxT+eznouOUT5WYHUxSjb7L2CUxJg/oyCNJKUZcAW2wKJG D2yTaf0CzfS2MBbUT0ERMPBkXOF9FWoQ/LVS7M2nD94a0LQwbA3M+HJcyF4KOgwpKf+mY zQYhBzV6l9NK/xXb/lgrVyd6sqjyHeHicB9RWSjjhuHlGu8k2dRUyNO0DT+chTXjLtFbx X7+Jjq86TxnlUnAp4A1oR4RnTsdZYqK9OW/wMgyAGZcZ1s+0VAOfemFQGu7/gnK032wY0 gkLgpVHeIMe2DSX5UhzA9KPCy8RRqtEc2epvazoDefn8mRxFEYqz/3CXzcXR9Ct7iCw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796358432; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=nKjKBi9USecokVP3Y27pgKYSvXSoLivB5gEpSVqhIFI=; b=zsH/yiPBdACbbzvt3ZESWlK12nZdPczVx8ryvWZ2BPZaGrmNGfwQ7q14wzFpW78nSn6T CDqteDNlDjomuADM3Gk0oOoPiNu3rmPe33Cneezs4zr1jMcdTmO00adUkC0kUej3wF1j0 q/ddiHRQeB6ItzE3rIY0oCMf/zsqyeTrZ6D2DAmSlGubt4yzp3WRkyj4h2+yctz5QihWK KebMZVKjD9GWJ4TcO/zPCTeSWOVxPvwKJVRwA7aBw99LXTVziRrkl2KHypZgaf5jZbgBC pa3tEseS0p1JstAm1FawCBRQP8qirH3ThXFNZLfFvi9F0wbpjRmG++QlgJ32rsoGIjw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KQN3JOJY; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 951A7606A32C; Fri, 4 Dec 2026 04:27:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KQN3JOJY Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57CEA1F00897; Fri, 4 Dec 2026 04:27:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796358432; bh=nKjKBi9USecokVP3Y27pgKYSvXSoLivB5gEpSVqhIFI=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=KQN3JOJYcTbLkqAV3DZoyJfXOSe+X2WtdwzI+eKDfs7OqcB41LogrLi3bTGZeQjpC 5sxvWa5m+hHoO4ulep9lAvZSDBY7FsyEA9Fq1pFdpnxorUFm/B9qXivcaz+JM7RVks xwpD3SXR4BhjGFId6ta2hyCCxtC2PsKn0tJ4kh373gs62CMpar8utIpBT3BZw5ck+v KL2LUstNOr6QFO3gzgGbW90S3WA3W13tBKnO9HgBq6FjWsYS9C7zf1NyhDKpGYG5lo 8bGinFQB+H7LhcOf5JOmAIlFcfU9bZyD/4Ompjs9H/7++gLEuXVwm2LkOM0+2VscK8 gOXAqH/KFo0DQ== Subject: Re: [PATCH net-next 1/2] net: ipv6: add strict RFC 4861 6.3.6 default router selection From: netdev-bot+sashiko@kernel.org To: florian.fainelli@broadcom.com Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, yoshfuji@linux-ipv6.org, dsahern@kernel.org, shuah@kernel.org, kuniyu@google.com, jiayuan.chen@linux.dev, angus.peng@broadcom.com, maoyi.xie@ntu.edu.sg, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Date: Fri, 04 Dec 2026 04:27:10 +0000 Message-ID: <179635843084.3146.1303610985327893701@kernel.org> In-Reply-To: <20261130222631.1786545-2-florian.fainelli@broadcom.com> References: <20261130222631.1786545-2-florian.fainelli@broadcom.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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