]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
macvlan: annotate data-races around port->bc_queue_len_used
authorEric Dumazet <edumazet@google.com>
Wed, 1 Apr 2026 10:38:08 +0000 (10:38 +0000)
committerJakub Kicinski <kuba@kernel.org>
Fri, 3 Apr 2026 00:56:35 +0000 (17:56 -0700)
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: d4bff72c8401 ("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>
drivers/net/macvlan.c

index ea22909cb09de43fbf26b16144430b4d6687de3e..bbb5c32541f996fdf97caa19d2c6d99e5c994a3d 100644 (file)
@@ -356,6 +356,7 @@ static void macvlan_broadcast_enqueue(struct macvlan_port *port,
                                      const struct macvlan_dev *src,
                                      struct sk_buff *skb)
 {
+       u32 bc_queue_len_used = READ_ONCE(port->bc_queue_len_used);
        struct sk_buff *nskb;
        int err = -ENOMEM;
 
@@ -366,7 +367,7 @@ static void macvlan_broadcast_enqueue(struct macvlan_port *port,
        MACVLAN_SKB_CB(nskb)->src = src;
 
        spin_lock(&port->bc_queue.lock);
-       if (skb_queue_len(&port->bc_queue) < port->bc_queue_len_used) {
+       if (skb_queue_len(&port->bc_queue) < bc_queue_len_used) {
                if (src)
                        dev_hold(src->dev);
                __skb_queue_tail(&port->bc_queue, nskb);
@@ -1731,7 +1732,8 @@ static int macvlan_fill_info(struct sk_buff *skb,
        }
        if (nla_put_u32(skb, IFLA_MACVLAN_BC_QUEUE_LEN, vlan->bc_queue_len_req))
                goto nla_put_failure;
-       if (nla_put_u32(skb, IFLA_MACVLAN_BC_QUEUE_LEN_USED, port->bc_queue_len_used))
+       if (nla_put_u32(skb, IFLA_MACVLAN_BC_QUEUE_LEN_USED,
+                       READ_ONCE(port->bc_queue_len_used)))
                goto nla_put_failure;
        if (port->bc_cutoff != 1 &&
            nla_put_s32(skb, IFLA_MACVLAN_BC_CUTOFF, port->bc_cutoff))
@@ -1791,7 +1793,7 @@ static void update_port_bc_queue_len(struct macvlan_port *port)
                if (vlan->bc_queue_len_req > max_bc_queue_len_req)
                        max_bc_queue_len_req = vlan->bc_queue_len_req;
        }
-       port->bc_queue_len_used = max_bc_queue_len_req;
+       WRITE_ONCE(port->bc_queue_len_used, max_bc_queue_len_req);
 }
 
 static int macvlan_device_event(struct notifier_block *unused,