From: Nikolay Aleksandrov <razor@blackwall.org>
To: netdev@vger.kernel.org
Cc: idosch@nvidia.com, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
bridge@lists.linux.dev, Nikolay Aleksandrov <razor@blackwall.org>
Subject: [PATCH net-next 5/9] net: bridge: vlan: annotate lockless use of private flags
Date: Tue, 1 Sep 2026 15:07:17 +0300 [thread overview]
Message-ID: <20260901120721.747908-6-razor@blackwall.org> (raw)
In-Reply-To: <20260901120721.747908-1-razor@blackwall.org>
Annotate vlan private flags data races, they can be read lockless.
Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
---
net/bridge/br_arp_nd_proxy.c | 6 ++++--
net/bridge/br_multicast.c | 16 ++++++++++------
net/bridge/br_private.h | 9 ++++++---
net/bridge/br_vlan.c | 2 +-
net/bridge/br_vlan_options.c | 6 ++++--
5 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/net/bridge/br_arp_nd_proxy.c b/net/bridge/br_arp_nd_proxy.c
index 87a40e2f1c50..b82fa6589ab9 100644
--- a/net/bridge/br_arp_nd_proxy.c
+++ b/net/bridge/br_arp_nd_proxy.c
@@ -521,7 +521,8 @@ bool br_is_neigh_suppress_enabled(const struct net_bridge_port *p, u16 vid)
v = br_vlan_find(vg, vid);
if (!v)
return false;
- return !!(v->priv_flags & BR_VLFLAG_NEIGH_SUPPRESS_ENABLED);
+ return !!(READ_ONCE(v->priv_flags) &
+ BR_VLFLAG_NEIGH_SUPPRESS_ENABLED);
}
return test_bit(BR_NEIGH_SUPPRESS_BIT, &p->flags);
}
@@ -535,7 +536,8 @@ bool br_is_neigh_forward_grat_enabled(const struct net_bridge_port *p, u16 vid)
v = br_vlan_find(vg, vid);
if (!v)
return false;
- return !!(v->priv_flags & BR_VLFLAG_NEIGH_FORWARD_GRAT_ENABLED);
+ return !!(READ_ONCE(v->priv_flags) &
+ BR_VLFLAG_NEIGH_FORWARD_GRAT_ENABLED);
}
return test_bit(BR_NEIGH_FORWARD_GRAT_BIT, &p->flags);
}
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index bbcaedf15ca1..cd984173320f 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -2172,7 +2172,7 @@ static void br_multicast_enable_port_ctx(struct net_bridge_mcast_port *pmctx)
spin_lock_bh(&br->multicast_lock);
if (br_multicast_port_ctx_is_vlan(pmctx) &&
- !(pmctx->vlan->priv_flags & BR_VLFLAG_MCAST_ENABLED)) {
+ !(READ_ONCE(pmctx->vlan->priv_flags) & BR_VLFLAG_MCAST_ENABLED)) {
spin_unlock_bh(&br->multicast_lock);
return;
}
@@ -2209,7 +2209,7 @@ static void br_multicast_disable_port_ctx(struct net_bridge_mcast_port *pmctx)
spin_lock_bh(&br->multicast_lock);
if (br_multicast_port_ctx_is_vlan(pmctx) &&
- !(pmctx->vlan->priv_flags & BR_VLFLAG_MCAST_ENABLED)) {
+ !(READ_ONCE(pmctx->vlan->priv_flags) & BR_VLFLAG_MCAST_ENABLED)) {
spin_unlock_bh(&br->multicast_lock);
return;
}
@@ -4083,7 +4083,8 @@ int br_multicast_rcv(struct net_bridge_mcast **brmctx,
*pmctx = &vlan->port_mcast_ctx;
}
- if (!(masterv->priv_flags & BR_VLFLAG_GLOBAL_MCAST_ENABLED))
+ if (!(READ_ONCE(masterv->priv_flags) &
+ BR_VLFLAG_GLOBAL_MCAST_ENABLED))
return 0;
}
@@ -4383,7 +4384,8 @@ void br_multicast_toggle_one_vlan(struct net_bridge_vlan *vlan, bool on)
return;
spin_lock_bh(&br->multicast_lock);
- vlan->priv_flags ^= BR_VLFLAG_MCAST_ENABLED;
+ WRITE_ONCE(vlan->priv_flags, vlan->priv_flags ^
+ BR_VLFLAG_MCAST_ENABLED);
spin_unlock_bh(&br->multicast_lock);
if (on)
@@ -4399,7 +4401,8 @@ void br_multicast_toggle_one_vlan(struct net_bridge_vlan *vlan, bool on)
br = vlan->port->br;
spin_lock_bh(&br->multicast_lock);
- vlan->priv_flags ^= BR_VLFLAG_MCAST_ENABLED;
+ WRITE_ONCE(vlan->priv_flags, vlan->priv_flags ^
+ BR_VLFLAG_MCAST_ENABLED);
if (on)
__br_multicast_enable_port_ctx(&vlan->port_mcast_ctx);
else
@@ -4477,7 +4480,8 @@ bool br_multicast_toggle_global_vlan(struct net_bridge_vlan *vlan, bool on)
if (on == !!(vlan->priv_flags & BR_VLFLAG_GLOBAL_MCAST_ENABLED))
return false;
- vlan->priv_flags ^= BR_VLFLAG_GLOBAL_MCAST_ENABLED;
+ WRITE_ONCE(vlan->priv_flags, vlan->priv_flags ^
+ BR_VLFLAG_GLOBAL_MCAST_ENABLED);
br_multicast_toggle_vlan(vlan, on);
return true;
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 96554d293d22..c7b64b5da012 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -1273,21 +1273,24 @@ br_multicast_ctx_vlan_global_disabled(const struct net_bridge_mcast *brmctx)
{
return br_multicast_ctx_is_vlan(brmctx) &&
(!br_opt_get(brmctx->br, BROPT_MCAST_VLAN_SNOOPING_ENABLED) ||
- !(brmctx->vlan->priv_flags & BR_VLFLAG_GLOBAL_MCAST_ENABLED));
+ !(READ_ONCE(brmctx->vlan->priv_flags) &
+ BR_VLFLAG_GLOBAL_MCAST_ENABLED));
}
static inline bool
br_multicast_ctx_vlan_disabled(const struct net_bridge_mcast *brmctx)
{
return br_multicast_ctx_is_vlan(brmctx) &&
- !(brmctx->vlan->priv_flags & BR_VLFLAG_MCAST_ENABLED);
+ !(READ_ONCE(brmctx->vlan->priv_flags) &
+ BR_VLFLAG_MCAST_ENABLED);
}
static inline bool
br_multicast_port_ctx_vlan_disabled(const struct net_bridge_mcast_port *pmctx)
{
return br_multicast_port_ctx_is_vlan(pmctx) &&
- !(pmctx->vlan->priv_flags & BR_VLFLAG_MCAST_ENABLED);
+ !(READ_ONCE(pmctx->vlan->priv_flags) &
+ BR_VLFLAG_MCAST_ENABLED);
}
static inline bool
diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index c8b2e3bfd42d..102792f20a5e 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -1497,7 +1497,7 @@ int br_vlan_fill_forward_path_mode(struct net_bridge *br,
if (path->bridge.vlan_mode == DEV_PATH_BR_VLAN_TAG)
path->bridge.vlan_mode = DEV_PATH_BR_VLAN_KEEP;
- else if (v->priv_flags & BR_VLFLAG_TAGGING_BY_SWITCHDEV)
+ else if (READ_ONCE(v->priv_flags) & BR_VLFLAG_TAGGING_BY_SWITCHDEV)
path->bridge.vlan_mode = DEV_PATH_BR_VLAN_UNTAG_HW;
else
path->bridge.vlan_mode = DEV_PATH_BR_VLAN_UNTAG;
diff --git a/net/bridge/br_vlan_options.c b/net/bridge/br_vlan_options.c
index cb0f556ff40d..bd049d268fe7 100644
--- a/net/bridge/br_vlan_options.c
+++ b/net/bridge/br_vlan_options.c
@@ -276,7 +276,8 @@ static int br_vlan_process_one_opts(const struct net_bridge *br,
}
if (val != enabled) {
- v->priv_flags ^= BR_VLFLAG_NEIGH_SUPPRESS_ENABLED;
+ WRITE_ONCE(v->priv_flags, v->priv_flags ^
+ BR_VLFLAG_NEIGH_SUPPRESS_ENABLED);
*changed = true;
}
}
@@ -292,7 +293,8 @@ static int br_vlan_process_one_opts(const struct net_bridge *br,
}
if (val != enabled) {
- v->priv_flags ^= BR_VLFLAG_NEIGH_FORWARD_GRAT_ENABLED;
+ WRITE_ONCE(v->priv_flags, v->priv_flags ^
+ BR_VLFLAG_NEIGH_FORWARD_GRAT_ENABLED);
*changed = true;
}
}
--
2.47.3
next prev parent reply other threads:[~2026-09-01 12:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 12:07 [PATCH net-next 0/9] net: bridge: vlan: minor cleanups and annotations Nikolay Aleksandrov
2026-09-01 12:07 ` [PATCH net-next 1/9] net: bridge: vlan: drop legacy memory barriers Nikolay Aleksandrov
2026-09-01 12:07 ` [PATCH net-next 2/9] net: bridge: vlan: annotate lockless pvid use Nikolay Aleksandrov
2026-09-01 12:07 ` [PATCH net-next 3/9] net: bridge: mst: use br_get_pvid helper Nikolay Aleksandrov
2026-09-01 12:07 ` [PATCH net-next 4/9] net: bridge: vlan: annotate lockless vlan flags use Nikolay Aleksandrov
2026-09-01 12:07 ` Nikolay Aleksandrov [this message]
2026-09-01 12:07 ` [PATCH net-next 6/9] net: bridge: vlan: annotate lockless use of num_vlans Nikolay Aleksandrov
2026-09-01 12:07 ` [PATCH net-next 7/9] net: bridge: vlan: annotate lockless use of msti Nikolay Aleksandrov
2026-09-01 12:07 ` [PATCH net-next 8/9] net: bridge: vlan: add missing tinfo.tunnel_id annotations Nikolay Aleksandrov
2026-09-01 12:07 ` [PATCH net-next 9/9] net: bridge: vlan: use br_vlan_get_state to get vlan state Nikolay Aleksandrov
2026-09-02 17:22 ` [PATCH net-next 0/9] net: bridge: vlan: minor cleanups and annotations Nikolay Aleksandrov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260901120721.747908-6-razor@blackwall.org \
--to=razor@blackwall.org \
--cc=bridge@lists.linux.dev \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox