summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2021-10-25 18:48:20 +0200
committerJakub Kicinski <kuba@kernel.org>2021-10-26 03:02:13 +0200
commit09b898466792b0c387040e6df90a16e7a9f2a5d9 (patch)
treef59306eb7b70c5d168db4b2e3ae087320431c671 /include
parentnet: avoid dirtying sk->sk_rx_queue_mapping (diff)
downloadlinux-09b898466792b0c387040e6df90a16e7a9f2a5d9.tar.xz
linux-09b898466792b0c387040e6df90a16e7a9f2a5d9.zip
net: annotate accesses to sk->sk_rx_queue_mapping
sk->sk_rx_queue_mapping can be modified locklessly, add a couple of READ_ONCE()/WRITE_ONCE() to document this fact. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/net/sock.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index b4d3744b188a..b76be30674ef 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1925,15 +1925,19 @@ static inline void sk_rx_queue_set(struct sock *sk, const struct sk_buff *skb)
static inline void sk_rx_queue_clear(struct sock *sk)
{
#ifdef CONFIG_SOCK_RX_QUEUE_MAPPING
- sk->sk_rx_queue_mapping = NO_QUEUE_MAPPING;
+ WRITE_ONCE(sk->sk_rx_queue_mapping, NO_QUEUE_MAPPING);
#endif
}
static inline int sk_rx_queue_get(const struct sock *sk)
{
#ifdef CONFIG_SOCK_RX_QUEUE_MAPPING
- if (sk && sk->sk_rx_queue_mapping != NO_QUEUE_MAPPING)
- return sk->sk_rx_queue_mapping;
+ if (sk) {
+ int res = READ_ONCE(sk->sk_rx_queue_mapping);
+
+ if (res != NO_QUEUE_MAPPING)
+ return res;
+ }
#endif
return -1;