Skip to content

Commit 1b26d36

Browse files
vladimirolteandavem330
authored andcommitted
net: dsa: warn about dsa_port and dsa_switch bit fields being non atomic
As discussed during review here: https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/ we should inform developers about pitfalls of concurrent access to the boolean properties of dsa_switch and dsa_port, now that they've been converted to bit fields. No other measure than a comment needs to be taken, since the code paths that update these bit fields are not concurrent with each other. Suggested-by: Florian Fainelli <[email protected]> Signed-off-by: Vladimir Oltean <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 63cfc65 commit 1b26d36

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

include/net/dsa.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,10 @@ struct dsa_port {
265265

266266
u8 stp_state;
267267

268+
/* Warning: the following bit fields are not atomic, and updating them
269+
* can only be done from code paths where concurrency is not possible
270+
* (probe time or under rtnl_lock).
271+
*/
268272
u8 vlan_filtering:1;
269273

270274
/* Managed by DSA on user ports and by drivers on CPU and DSA ports */
@@ -333,6 +337,10 @@ struct dsa_switch {
333337
struct dsa_switch_tree *dst;
334338
unsigned int index;
335339

340+
/* Warning: the following bit fields are not atomic, and updating them
341+
* can only be done from code paths where concurrency is not possible
342+
* (probe time or under rtnl_lock).
343+
*/
336344
u32 setup:1;
337345

338346
/* Disallow bridge core from requesting different VLAN awareness

0 commit comments

Comments
 (0)