Skip to content

Commit 3b09b2b

Browse files
Eric Dumazetkuba-moo
authored andcommitted
net: dst_cache: annotate data-races around dst_cache->reset_ts
dst_cache->reset_ts is read or written locklessly, add READ_ONCE() and WRITE_ONCE() annotations. Signed-off-by: Eric Dumazet <[email protected]> Acked-by: Paolo Abeni <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e497c32 commit 3b09b2b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

include/net/dst_cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ struct dst_entry *dst_cache_get_ip6(struct dst_cache *dst_cache,
7676
*/
7777
static inline void dst_cache_reset(struct dst_cache *dst_cache)
7878
{
79-
dst_cache->reset_ts = jiffies;
79+
WRITE_ONCE(dst_cache->reset_ts, jiffies);
8080
}
8181

8282
/**

net/core/dst_cache.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ static struct dst_entry *dst_cache_per_cpu_get(struct dst_cache *dst_cache,
4747
/* the cache already hold a dst reference; it can't go away */
4848
dst_hold(dst);
4949

50-
if (unlikely(!time_after(idst->refresh_ts, dst_cache->reset_ts) ||
50+
if (unlikely(!time_after(idst->refresh_ts,
51+
READ_ONCE(dst_cache->reset_ts)) ||
5152
(dst->obsolete && !dst->ops->check(dst, idst->cookie)))) {
5253
dst_cache_per_cpu_dst_set(idst, NULL, 0);
5354
dst_release(dst);
@@ -170,7 +171,7 @@ void dst_cache_reset_now(struct dst_cache *dst_cache)
170171
if (!dst_cache->cache)
171172
return;
172173

173-
dst_cache->reset_ts = jiffies;
174+
dst_cache_reset(dst_cache);
174175
for_each_possible_cpu(i) {
175176
struct dst_cache_pcpu *idst = per_cpu_ptr(dst_cache->cache, i);
176177
struct dst_entry *dst = idst->dst;

0 commit comments

Comments
 (0)