From: Eric Dumazet <edumazet@google.com>
To: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>,
Kuniyuki Iwashima <kuniyu@google.com>,
David Ahern <dsahern@kernel.org>,
netdev@vger.kernel.org, eric.dumazet@gmail.com,
Eric Dumazet <edumazet@google.com>
Subject: [PATCH net-next 03/10] net: dst: annotate data-races around dst->lastuse
Date: Fri, 27 Jun 2025 11:25:19 +0000 [thread overview]
Message-ID: <20250627112526.3615031-4-edumazet@google.com> (raw)
In-Reply-To: <20250627112526.3615031-1-edumazet@google.com>
(dst_entry)->lastuse is read and written locklessly,
add corresponding annotations.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/net/dst.h | 4 ++--
net/core/rtnetlink.c | 4 +++-
net/ipv6/route.c | 3 ++-
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/include/net/dst.h b/include/net/dst.h
index 1efe1e5d51a904a0fe907687835b8e07f32afaec..bef2f41c7220437b3cb177ea8c85b81b3f89e8f8 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -240,9 +240,9 @@ static inline void dst_hold(struct dst_entry *dst)
static inline void dst_use_noref(struct dst_entry *dst, unsigned long time)
{
- if (unlikely(time != dst->lastuse)) {
+ if (unlikely(time != READ_ONCE(dst->lastuse))) {
dst->__use++;
- dst->lastuse = time;
+ WRITE_ONCE(dst->lastuse, time);
}
}
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index c57692eb8da9d47c3b0943bf7b8d8b7f7d347836..a9555bfc372f5709a3b846343986dce1edf935be 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1026,9 +1026,11 @@ int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst, u32 id,
.rta_error = error,
.rta_id = id,
};
+ unsigned long delta;
if (dst) {
- ci.rta_lastuse = jiffies_delta_to_clock_t(jiffies - dst->lastuse);
+ delta = jiffies - READ_ONCE(dst->lastuse);
+ ci.rta_lastuse = jiffies_delta_to_clock_t(delta);
ci.rta_used = dst->__use;
ci.rta_clntref = rcuref_read(&dst->__rcuref);
}
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 1014dcea1200cb4d4fc63f7b335fd2663c4844a3..375112a59492ea3654d180c504946d96ed1592cd 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2133,7 +2133,8 @@ static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket,
* expired, independently from their aging, as per RFC 8201 section 4
*/
if (!(rt->rt6i_flags & RTF_EXPIRES)) {
- if (time_after_eq(now, rt->dst.lastuse + gc_args->timeout)) {
+ if (time_after_eq(now, READ_ONCE(rt->dst.lastuse) +
+ gc_args->timeout)) {
pr_debug("aging clone %p\n", rt);
rt6_remove_exception(bucket, rt6_ex);
return;
--
2.50.0.727.gbf7dc18ff4-goog
next prev parent reply other threads:[~2025-06-27 11:25 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-27 11:25 [PATCH net-next 00/10] net: add data-race annotations around dst fields Eric Dumazet
2025-06-27 11:25 ` [PATCH net-next 01/10] net: dst: annotate data-races around dst->obsolete Eric Dumazet
2025-06-27 17:36 ` Kuniyuki Iwashima
2025-06-27 11:25 ` [PATCH net-next 02/10] net: dst: annotate data-races around dst->expires Eric Dumazet
2025-06-27 17:41 ` Kuniyuki Iwashima
2025-06-27 11:25 ` Eric Dumazet [this message]
2025-06-27 17:44 ` [PATCH net-next 03/10] net: dst: annotate data-races around dst->lastuse Kuniyuki Iwashima
2025-06-27 11:25 ` [PATCH net-next 04/10] net: dst: annotate data-races around dst->input Eric Dumazet
2025-06-27 17:51 ` Kuniyuki Iwashima
2025-06-27 11:25 ` [PATCH net-next 05/10] net: dst: annotate data-races around dst->output Eric Dumazet
2025-06-27 17:54 ` Kuniyuki Iwashima
2025-06-27 11:25 ` [PATCH net-next 06/10] net: dst: add four helpers to annotate data-races around dst->dev Eric Dumazet
2025-06-27 17:57 ` Kuniyuki Iwashima
2025-06-27 11:25 ` [PATCH net-next 07/10] ipv4: adopt dst_dev, skb_dst_dev and skb_dst_dev_net[_rcu] Eric Dumazet
2025-06-27 21:01 ` Kuniyuki Iwashima
2025-06-27 11:25 ` [PATCH net-next 08/10] ipv6: adopt dst_dev() helper Eric Dumazet
2025-06-27 21:04 ` Kuniyuki Iwashima
2025-06-27 11:25 ` [PATCH net-next 09/10] ipv6: adopt skb_dst_dev() and skb_dst_dev_net[_rcu]() helpers Eric Dumazet
2025-06-27 21:07 ` Kuniyuki Iwashima
2025-06-28 2:15 ` kernel test robot
2025-06-27 11:25 ` [PATCH net-next 10/10] ipv6: ip6_mc_input() and ip6_mr_input() cleanups Eric Dumazet
2025-06-27 21:09 ` Kuniyuki Iwashima
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=20250627112526.3615031-4-edumazet@google.com \
--to=edumazet@google.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=eric.dumazet@gmail.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--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;
as well as URLs for NNTP newsgroup(s).