From: David Lamparter <equinox@diac24.net>
To: netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>
Cc: David Lamparter <equinox@diac24.net>,
Lorenzo Colitti <lorenzo@google.com>,
Patrick Rohr <prohr@google.com>
Subject: [RESEND PATCH net-next v2 1/4] net/ipv6: flatten ip6_route_get_saddr
Date: Tue, 4 Nov 2025 09:48:19 -0500 [thread overview]
Message-ID: <20251104144824.19648-2-equinox@diac24.net> (raw)
In-Reply-To: <20251104144824.19648-1-equinox@diac24.net>
Inline ip6_route_get_saddr()'s functionality in rt6_fill_node(), to
prepare for replacing the former with a dst based function.
NB: the l3mdev handling introduced by 252442f2ae31 "ipv6: fix source
address selection with route leak" is dropped here - the l3mdev ifindex
was a constant 0 on this call site, so that code was in fact dead.
Signed-off-by: David Lamparter <equinox@diac24.net>
---
net/ipv6/route.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index aee6a10b112a..9508e46b9e56 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -5822,9 +5822,19 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb,
if (nla_put_u32(skb, RTA_IIF, iif))
goto nla_put_failure;
} else if (dest) {
- struct in6_addr saddr_buf;
- if (ip6_route_get_saddr(net, rt, dest, 0, 0, &saddr_buf) == 0 &&
- nla_put_in6_addr(skb, RTA_PREFSRC, &saddr_buf))
+ struct in6_addr saddr_buf, *saddr = NULL;
+
+ if (rt->fib6_prefsrc.plen) {
+ saddr = &rt->fib6_prefsrc.addr;
+ } else {
+ struct net_device *dev = fib6_info_nh_dev(rt);
+
+ if (ipv6_dev_get_saddr(net, dev, dest, 0,
+ &saddr_buf) == 0)
+ saddr = &saddr_buf;
+ }
+
+ if (saddr && nla_put_in6_addr(skb, RTA_PREFSRC, saddr))
goto nla_put_failure;
}
--
2.50.1
next prev parent reply other threads:[~2025-11-04 14:50 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-04 14:48 [RESEND PATCH net-next v2 0/4] net/ipv6: RFC6724 rule 5.5 preparations David Lamparter
2025-11-04 14:48 ` David Lamparter [this message]
2025-11-04 17:52 ` [RESEND PATCH net-next v2 1/4] net/ipv6: flatten ip6_route_get_saddr Lorenzo Colitti
2025-11-04 14:48 ` [RESEND PATCH net-next v2 2/4] net/ipv6: create ipv6_fl_get_saddr David Lamparter
2025-11-04 17:51 ` Lorenzo Colitti
2025-11-04 20:47 ` David Lamparter
2025-11-04 21:16 ` David Lamparter
2025-11-11 9:50 ` Paolo Abeni
2025-11-04 14:48 ` [RESEND PATCH net-next v2 3/4] net/ipv6: use ipv6_fl_get_saddr in output David Lamparter
2025-11-04 17:52 ` Lorenzo Colitti
2025-11-11 9:56 ` Paolo Abeni
2025-11-04 14:48 ` [RESEND PATCH net-next v2 4/4] net/ipv6: drop ip6_route_get_saddr David Lamparter
2025-11-04 17:51 ` Lorenzo Colitti
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=20251104144824.19648-2-equinox@diac24.net \
--to=equinox@diac24.net \
--cc=kuba@kernel.org \
--cc=lorenzo@google.com \
--cc=netdev@vger.kernel.org \
--cc=prohr@google.com \
/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;
as well as URLs for NNTP newsgroup(s).