Skip to content

Commit 20993af

Browse files
edumazetgregkh
authored andcommitted
macvlan: annotate data-races around port->bc_queue_len_used
[ Upstream commit 1ef5789 ] port->bc_queue_len_used is read and written locklessly, add READ_ONCE()/WRITE_ONCE() annotations. While WRITE_ONCE() in macvlan_fill_info() is not yet needed, it is a prereq for future RTNL avoidance. Fixes: d4bff72 ("macvlan: Support for high multicast packet rate") Signed-off-by: Eric Dumazet <edumazet@google.com> Link: https://patch.msgid.link/20260401103809.3038139-2-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 2b4b955 commit 20993af

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

drivers/net/macvlan.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ static void macvlan_broadcast_enqueue(struct macvlan_port *port,
351351
const struct macvlan_dev *src,
352352
struct sk_buff *skb)
353353
{
354+
u32 bc_queue_len_used = READ_ONCE(port->bc_queue_len_used);
354355
struct sk_buff *nskb;
355356
int err = -ENOMEM;
356357

@@ -361,7 +362,7 @@ static void macvlan_broadcast_enqueue(struct macvlan_port *port,
361362
MACVLAN_SKB_CB(nskb)->src = src;
362363

363364
spin_lock(&port->bc_queue.lock);
364-
if (skb_queue_len(&port->bc_queue) < port->bc_queue_len_used) {
365+
if (skb_queue_len(&port->bc_queue) < bc_queue_len_used) {
365366
if (src)
366367
dev_hold(src->dev);
367368
__skb_queue_tail(&port->bc_queue, nskb);
@@ -1723,7 +1724,8 @@ static int macvlan_fill_info(struct sk_buff *skb,
17231724
}
17241725
if (nla_put_u32(skb, IFLA_MACVLAN_BC_QUEUE_LEN, vlan->bc_queue_len_req))
17251726
goto nla_put_failure;
1726-
if (nla_put_u32(skb, IFLA_MACVLAN_BC_QUEUE_LEN_USED, port->bc_queue_len_used))
1727+
if (nla_put_u32(skb, IFLA_MACVLAN_BC_QUEUE_LEN_USED,
1728+
READ_ONCE(port->bc_queue_len_used)))
17271729
goto nla_put_failure;
17281730
if (port->bc_cutoff != 1 &&
17291731
nla_put_s32(skb, IFLA_MACVLAN_BC_CUTOFF, port->bc_cutoff))
@@ -1783,7 +1785,7 @@ static void update_port_bc_queue_len(struct macvlan_port *port)
17831785
if (vlan->bc_queue_len_req > max_bc_queue_len_req)
17841786
max_bc_queue_len_req = vlan->bc_queue_len_req;
17851787
}
1786-
port->bc_queue_len_used = max_bc_queue_len_req;
1788+
WRITE_ONCE(port->bc_queue_len_used, max_bc_queue_len_req);
17871789
}
17881790

17891791
static int macvlan_device_event(struct notifier_block *unused,

0 commit comments

Comments
 (0)