public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Hangbin Liu <liuhangbin@gmail.com>
To: Paolo Abeni <pabeni@redhat.com>
Cc: "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>,
	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: Wed, 8 Apr 2026 02:13:51 +0000	[thread overview]
Message-ID: <adW539MBrLjt6Pl9@fedora> (raw)
In-Reply-To: <bc004773-aead-4431-95fc-860490773c49@redhat.com>

On Tue, Apr 07, 2026 at 12:27:30PM +0200, Paolo Abeni wrote:
> 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

OK, I will drop this change in the 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.

Which rt->metrics do you mean? I can't find it..


> 
> > @@ -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]);

This is already a fib6_mtu() function.
> 
> 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]);
> }
> 

Should we rename the helper? e.g. get_fib6_mtu ?

Hangbin

      reply	other threads:[~2026-04-08  2:13 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
2026-04-08  2:13   ` Hangbin Liu [this message]

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=adW539MBrLjt6Pl9@fedora \
    --to=liuhangbin@gmail.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=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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