From: Paolo Abeni <pabeni@redhat.com>
To: Hangbin Liu <liuhangbin@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
David Ahern <dsahern@kernel.org>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Simon Horman <horms@kernel.org>
Cc: David Ahern <dsahern@gmail.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Jiayuan Chen <jiayuan.chen@linux.dev>
Subject: Re: [PATCH net] ipv6: add READ_ONCE() annotations to fib6_metrics reader paths
Date: Tue, 7 Apr 2026 12:27:30 +0200 [thread overview]
Message-ID: <bc004773-aead-4431-95fc-860490773c49@redhat.com> (raw)
In-Reply-To: <20260403-fib6_metric_read_once-v1-1-45de44912b24@gmail.com>
On 4/3/26 6:16 AM, Hangbin Liu wrote:
> diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
> index 9f8b6814a96a..2dfb04fab5da 100644
> --- a/include/net/ip6_fib.h
> +++ b/include/net/ip6_fib.h
> @@ -594,7 +594,9 @@ void fib6_update_sernum_stub(struct net *net, struct fib6_info *f6i);
> void fib6_metric_set(struct fib6_info *f6i, int metric, u32 val);
> static inline bool fib6_metric_locked(struct fib6_info *f6i, int metric)
> {
> - return !!(f6i->fib6_metrics->metrics[RTAX_LOCK - 1] & (1 << metric));
> + struct dst_metrics *m = READ_ONCE(f6i->fib6_metrics);
> +
> + return !!(m->metrics[RTAX_LOCK - 1] & (1 << metric));
Sashiko notes that here you may want to add an additional READ_ONCE() on
m->metrics[RTAX_LOCK - 1], which in turn looks like more a
follow-up/separate change than a change specific to this patch
> }
> void fib6_info_hw_flags_set(struct net *net, struct fib6_info *f6i,
> bool offload, bool trap, bool offload_failed);
> diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
> index dd26657b6a4a..3c96580c2a03 100644
> --- a/net/ipv6/ip6_fib.c
> +++ b/net/ipv6/ip6_fib.c
> @@ -1144,9 +1144,11 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt,
> iter->fib6_flags &= ~RTF_PREFIX_RT;
> }
>
> - if (rt->fib6_pmtu)
> + u32 pmtu = READ_ONCE(rt->fib6_pmtu);
Here the READ_ONCE() on rt->metrics is still missing.
> @@ -1635,11 +1635,12 @@ __rt6_find_exception_rcu(struct rt6_exception_bucket **bucket,
> static unsigned int fib6_mtu(const struct fib6_result *res)
> {
> const struct fib6_nh *nh = res->nh;
> + struct dst_metrics *m;
> unsigned int mtu;
>
> - if (res->f6i->fib6_pmtu) {
> - mtu = res->f6i->fib6_pmtu;
> - } else {
> + m = READ_ONCE(res->f6i->fib6_metrics);
> + mtu = READ_ONCE(m->metrics[RTAX_MTU - 1]);
After this patch there will be a single usage of the `fib6_pmtu` macro.
I think it would be better to entirely drop it and replace with an helper:
static inline unsigned int fib6_mtu(const struct fib6_info *f6i)
{
const struct dst_metrics *m = READ_ONCE(f6i->fib6_metrics);
return READ_ONCE(m->metrics[RTAX_MTU - 1]);
}
/P
next prev parent reply other threads:[~2026-04-07 10:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-03 4:16 [PATCH net] ipv6: add READ_ONCE() annotations to fib6_metrics reader paths Hangbin Liu
2026-04-07 10:27 ` Paolo Abeni [this message]
2026-04-08 2:13 ` Hangbin Liu
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=bc004773-aead-4431-95fc-860490773c49@redhat.com \
--to=pabeni@redhat.com \
--cc=davem@davemloft.net \
--cc=dsahern@gmail.com \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jiayuan.chen@linux.dev \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuhangbin@gmail.com \
--cc=netdev@vger.kernel.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