From: Jonathan Corbet <corbet@lwn.net>
To: David 'equinox' Lamparter <equinox@diac24.net>,
Paolo Abeni <pabeni@redhat.com>, Jakub Kicinski <kuba@kernel.org>,
Ido Schimmel <idosch@nvidia.com>
Cc: "David Ahern" <dsahern@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Simon Horman" <horms@kernel.org>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Fernando Fernandez Mancera" <fmancera@suse.de>,
"Lorenzo Colitti" <lorenzo@google.com>,
"Maciej Żenczykowski" <maze@google.com>,
"Patrick Rohr" <prohr@google.com>,
netdev@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kselftest@vger.kernel.org,
"David 'equinox' Lamparter" <equinox@diac24.net>
Subject: Re: [PATCH net-next 9/9] net: document RFC6724 rule 5.5 implementation
Date: Tue, 14 Jul 2026 07:01:13 -0600 [thread overview]
Message-ID: <87zeztg1ye.fsf@trenco.lwn.net> (raw)
In-Reply-To: <20260714094030.136317-10-equinox@diac24.net>
David 'equinox' Lamparter <equinox@diac24.net> writes:
> RFC6724 rule 5.5 is anything but obvious, especially if trying to do it
> well. (RFC8028 and its errata kinda proves the point.)
>
> This documents what exactly the Linux kernel does for RFC6724 rule 5.5,
> especially what the routing table needs to look like for it to work.
>
> Signed-off-by: David 'equinox' Lamparter <equinox@diac24.net>
> ---
> Documentation/networking/ipv6-addrsel.rst | 75 +++++++++++++++++++++++
> MAINTAINERS | 1 +
> 2 files changed, 76 insertions(+)
> create mode 100644 Documentation/networking/ipv6-addrsel.rst
You need to add this new document to the index.rst file or it won't be
part of the docs build...you should have seen a warning when you built
the docs.
> diff --git a/Documentation/networking/ipv6-addrsel.rst b/Documentation/networking/ipv6-addrsel.rst
> new file mode 100644
> index 000000000000..bed032e69570
> --- /dev/null
> +++ b/Documentation/networking/ipv6-addrsel.rst
> @@ -0,0 +1,75 @@
> +.. SPDX-License-Identifier: GPL-2.0
> +
> +====================================
> +IPv6 source address selection trivia
> +====================================
> +
> +
> +RFC6724 rule 5.5 support
> +------------------------
Please stick with the section markup guidelines in
Documentation/doc-guide/sphinx.rst.
> +RFC6724 rule 5.5 is a very short paragraph in a complex RFC that has turned
> +out quite tricky, but also immensely useful in multihoming scenarios. For
> +reference, it says:
> +
> +::
You'll likely get more visually pleasing results if you just leave out
the "::" here; you don't need literal formatting.
> + Rule 5.5: Prefer addresses in a prefix advertised by the next-hop.
> + If SA or SA's prefix is assigned by the selected next-hop that will
> + be used to send to D and SB or SB's prefix is assigned by a different
> + next-hop, then prefer SA. Similarly, if SB or SB's prefix is
> + assigned by the next-hop that will be used to send to D and SA or
> + SA's prefix is assigned by a different next-hop, then prefer SB.
> +
> +The way this works on Linux is as follows:
> +
> +- prior to any source address selection happening, when receiving a RA, more
> + than the installation of a default route (or ::/128 route) needs to happen:
> + for each PIO, a source-specific (subtree) route is *additionally* installed.
> + The effect of this is that *after* a source address has been selected, one
> + of the routers that advertised it will remain in use (this is *not* RFC 6724
> + related, but rather RFC 8028.) At the same time, these extra routes serve
> + to remember which router advertised what.
> +
> +- per usual, a route lookup for the IPv6 destination address in consideration
> + is done first. This is passed around in kernel as a dst_entry.
> +
> +- the source address selection code iterates through the various rules in
> + RFC 6724.
> +
> +- if/when rule 5.5 is reached, first of all, there is a check if *any* source
> + specific routes exist in the routing table. If there are none, the entire
> + code for 5.5 is skipped because it cannot have any effect, but is not free
> + to execute (can involve multiple routing lookups.) **In applications that
> + use a lot of unbound (e.g. UDP) sockets, installing subtree routes should
> + therefore be avoided to not incur this cost on each source address selection
> + pass.** Alternatively, applications should bind their sockets to a specific
> + source address such that the selection code is never hit.
> +
> +- if subtree routes do exist, the source address selection code now repeats
> + the routing lookup done before source address selection is entered, except
> + with the source address under consideration filled in. This lookup will hit
> + the subtree routes that were installed (see first item), giving a fresh
> + dst_entry. If the new dst_entry matches the original dst_entry, that means
> + the original router has in fact sent RAs with PIOs for this source address,
> + so it is preferred. Otherwise it is not.
> +
> +
> +There are a few caveats to consider:
> +
> +- the kernel currently does not create the subtree routes mentioned in the
> + first item. This is a separate work item, partially done at the time of
> + writing this. But this can equally well be performed in userspace processing
> + of RAs, e.g. NetworkManager or plain static configuration.
> +
> +- since addresses can also be acquired from DHCPv6, even RA/PIO combinations
> + that didn't result in the creation of any addresses (e.g. A=0) should have
> + subtree routes added. Those routes *may* be relevant for DHCPv6-generated
> + addresses.
> +
> +- the "announce check" lookup does not backtrack. Only the destination prefix
> + that provided the "unspecific" (::/128) match is checked for source prefixes
> + to see what routers advertised what. This means that for e.g. RIOs, subtree
> + routes also have to be created. (Backtracking for this case would further
> + increase the cost of source address selection, for a pretty rare situation
> + that has an easy fix/workaround.)
> diff --git a/MAINTAINERS b/MAINTAINERS
> index f3218abefd0c..4edf48362a07 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -18912,6 +18912,7 @@ F: Documentation/netlink/specs/rt-addr.yaml
> F: Documentation/netlink/specs/rt-neigh.yaml
> F: Documentation/netlink/specs/rt-route.yaml
> F: Documentation/netlink/specs/rt-rule.yaml
> +F: Documentation/networking/ipv6-addrsel.rst
It seems weird to add this one file here - I wonder why there isn't just
an entry for Documentation/networking ?
Thanks,
jon
next prev parent reply other threads:[~2026-07-14 13:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 9:40 [PATCH net-next 0/9] RFC 6724 rule 5.5 support David 'equinox' Lamparter
2026-07-14 9:40 ` [PATCH net-next 1/9] net/ipv6: fix lookup for ::/0 (non-)subtree route David 'equinox' Lamparter
2026-07-14 9:40 ` [PATCH net-next 2/9] net/ipv6: flatten ip6_route_get_saddr David 'equinox' Lamparter
2026-07-14 9:40 ` [PATCH net-next 3/9] net/ipv6: create ipv6_fl_get_saddr David 'equinox' Lamparter
2026-07-14 9:40 ` [PATCH net-next 4/9] net/ipv6: use ipv6_fl_get_saddr in output David 'equinox' Lamparter
2026-07-14 9:40 ` [PATCH net-next 5/9] net/ipv6: drop ip6_route_get_saddr David 'equinox' Lamparter
2026-07-14 9:40 ` [PATCH net-next 6/9] net/ipv6: flip IPV6_SUBTREES default to Y David 'equinox' Lamparter
2026-07-14 9:40 ` [PATCH net-next 7/9] net/ipv6: support RFC6724 rule 5.5 via subtrees David 'equinox' Lamparter
2026-07-14 9:40 ` [PATCH net-next 8/9] selftests: net: RFC6724 rule 5.5 tests David 'equinox' Lamparter
2026-07-14 9:40 ` [PATCH net-next 9/9] net: document RFC6724 rule 5.5 implementation David 'equinox' Lamparter
2026-07-14 13:01 ` Jonathan Corbet [this message]
2026-07-14 17:16 ` David 'equinox' Lamparter
2026-07-14 17:31 ` Jonathan Corbet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zeztg1ye.fsf@trenco.lwn.net \
--to=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=equinox@diac24.net \
--cc=fmancera@suse.de \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=lorenzo@google.com \
--cc=maze@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=prohr@google.com \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox