]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bridge: provide lockless access to p->priority
authorEric Dumazet <edumazet@google.com>
Thu, 4 Jun 2026 14:13:40 +0000 (14:13 +0000)
committerJakub Kicinski <kuba@kernel.org>
Sat, 6 Jun 2026 00:46:18 +0000 (17:46 -0700)
sysfs show_priority() needs this.

Also br_port_fill_attrs() might in the future run without RTNL.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Link: https://patch.msgid.link/20260604141343.2124500-9-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/bridge/br_netlink.c
net/bridge/br_stp_if.c
net/bridge/br_sysfs_if.c

index a722db89aef6bbb6ecc77c7e0f173dc79418797f..fc25c6b6cc9713080873976f443da1fbd764aafe 100644 (file)
@@ -239,7 +239,7 @@ static int br_port_fill_attrs(struct sk_buff *skb,
        u64 timerval;
 
        if (nla_put_u8(skb, IFLA_BRPORT_STATE, p->state) ||
-           nla_put_u16(skb, IFLA_BRPORT_PRIORITY, p->priority) ||
+           nla_put_u16(skb, IFLA_BRPORT_PRIORITY, READ_ONCE(p->priority)) ||
            nla_put_u32(skb, IFLA_BRPORT_COST, READ_ONCE(p->path_cost)) ||
            nla_put_u8(skb, IFLA_BRPORT_MODE, mode) ||
            nla_put_u8(skb, IFLA_BRPORT_GUARD, !!(p->flags & BR_BPDU_GUARD)) ||
index 7b0d1a334785047905a00694fd65e3212b160e5d..3524bb7e87f0586774a883720be9fa8eb60f0370 100644 (file)
@@ -323,7 +323,7 @@ int br_stp_set_port_priority(struct net_bridge_port *p, unsigned long newprio)
                WRITE_ONCE(p->designated_port, new_port_id);
 
        p->port_id = new_port_id;
-       p->priority = newprio;
+       WRITE_ONCE(p->priority, newprio);
        if (!memcmp(&p->br->bridge_id, &p->designated_bridge, 8) &&
            p->port_id < p->designated_port) {
                br_become_designated_port(p);
index 1023f97b1c9a22a1f79c3c734aef9bd41832ea39..3f666d4fef42324a4751779153ecc48bdb44b85a 100644 (file)
@@ -100,7 +100,7 @@ static BRPORT_ATTR(path_cost, 0644, show_path_cost, store_path_cost);
 
 static ssize_t show_priority(struct net_bridge_port *p, char *buf)
 {
-       return sysfs_emit(buf, "%d\n", p->priority);
+       return sysfs_emit(buf, "%d\n", READ_ONCE(p->priority));
 }
 
 static int store_priority(struct net_bridge_port *p, unsigned long v)