summaryrefslogtreecommitdiff
path: root/net/core/dev.c
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2026-08-12 08:54:40 +0000
committerJakub Kicinski <kuba@kernel.org>2026-08-17 10:27:48 -0700
commit51b0aaafd9ee85adfa7623d6dca37c71e33777e8 (patch)
tree02040c9528c410fd32c3381d274338a13eb9d96d /net/core/dev.c
parent0c6c32a8c854e570998494b8368d314d526ddbd3 (diff)
net: add READ_ONCE()/WRITE_ONCE() annotations for dev->prio_tc_map
Concurrent fast-path readers access dev->prio_tc_map (e.g. via skb_tx_hash(), netdev_get_prio_tc_map(), and qdiscs) while writers update entries in dev->prio_tc_map or reset/clear the map via netdev_reset_tc() and netdev_unbind_sb_channel(). Furthermore, memset() in netdev_reset_tc() and netdev_unbind_sb_channel() provides no guarantee of performing atomic word/byte stores. Add READ_ONCE() and WRITE_ONCE() annotations to netdev_get_prio_tc_map() and netdev_set_prio_tc_map(), replace memset() in dev.c with explicit WRITE_ONCE() loops, and update direct array accesses in qdiscs to use netdev_get_prio_tc_map(). Signed-off-by: Eric Dumazet <edumazet@google.com> Link: https://patch.msgid.link/20260812085440.3917924-4-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/core/dev.c')
-rw-r--r--net/core/dev.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 9fc6eeb4d066..e63773beb39b 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3120,7 +3120,8 @@ void netdev_reset_tc(struct net_device *dev)
WRITE_ONCE(dev->num_tc, 0);
for (i = 0; i < TC_MAX_QUEUE; i++)
WRITE_ONCE(dev->tc_to_txq[i].combined, 0);
- memset(dev->prio_tc_map, 0, sizeof(dev->prio_tc_map));
+ for (i = 0; i <= TC_BITMASK; i++)
+ WRITE_ONCE(dev->prio_tc_map[i], 0);
}
EXPORT_SYMBOL(netdev_reset_tc);
@@ -3168,7 +3169,8 @@ void netdev_unbind_sb_channel(struct net_device *dev,
#endif
for (i = 0; i < TC_MAX_QUEUE; i++)
WRITE_ONCE(sb_dev->tc_to_txq[i].combined, 0);
- memset(sb_dev->prio_tc_map, 0, sizeof(sb_dev->prio_tc_map));
+ for (i = 0; i <= TC_BITMASK; i++)
+ WRITE_ONCE(sb_dev->prio_tc_map[i], 0);
while (txq-- != &dev->_tx[0]) {
if (txq->sb_dev == sb_dev)