mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
net: bridge: vlan: annotate lockless use of private flags
Annotate vlan private flags data races, they can be read lockless. Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Link: https://patch.msgid.link/20260903143138.1574598-6-razor@blackwall.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
2b1f8fd311
commit
b0bb0a45ce
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2183,7 +2183,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;
|
||||
}
|
||||
|
|
@ -2220,7 +2220,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;
|
||||
}
|
||||
|
|
@ -4094,7 +4094,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;
|
||||
}
|
||||
|
||||
|
|
@ -4394,7 +4395,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)
|
||||
|
|
@ -4410,7 +4412,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
|
||||
|
|
@ -4488,7 +4491,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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user