From: Eric Dumazet <edumazet@google.com>
To: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>,
Nikolay Aleksandrov <razor@blackwall.org>,
Ido Schimmel <idosch@nvidia.com>,
netdev@vger.kernel.org, eric.dumazet@gmail.com,
Eric Dumazet <edumazet@google.com>
Subject: [PATCH v3 net-next 07/11] bridge: provide lockless access to p->designated_port
Date: Thu, 4 Jun 2026 14:13:39 +0000 [thread overview]
Message-ID: <20260604141343.2124500-8-edumazet@google.com> (raw)
In-Reply-To: <20260604141343.2124500-1-edumazet@google.com>
Add READ_ONCE()/WRITE_ONCE() annotations around p->designated_port
This is needed at least for sysfs show_designated_port(), BRCTL_GET_PORT_INFO
and upcoming RTNL avoidance in "ip link" dumps (cf br_port_fill_attrs()).
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
---
net/bridge/br_ioctl.c | 2 +-
net/bridge/br_netlink.c | 3 ++-
net/bridge/br_stp.c | 4 ++--
net/bridge/br_stp_if.c | 2 +-
net/bridge/br_sysfs_if.c | 2 +-
5 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/net/bridge/br_ioctl.c b/net/bridge/br_ioctl.c
index a507c7b369ac49803019cdca7836c7fb9ef4459e..2be802991f70ab3ce48ade5da6d1488e072dbec6 100644
--- a/net/bridge/br_ioctl.c
+++ b/net/bridge/br_ioctl.c
@@ -258,7 +258,7 @@ int br_dev_siocdevprivate(struct net_device *dev, struct ifreq *rq,
memcpy(&p.designated_root, &pt->designated_root, 8);
memcpy(&p.designated_bridge, &pt->designated_bridge, 8);
p.port_id = pt->port_id;
- p.designated_port = pt->designated_port;
+ p.designated_port = READ_ONCE(pt->designated_port);
p.path_cost = READ_ONCE(pt->path_cost);
p.designated_cost = READ_ONCE(pt->designated_cost);
p.state = pt->state;
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 296f62ebdd4a6f3d404b5902fe661995bd1ca0f5..a722db89aef6bbb6ecc77c7e0f173dc79418797f 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -263,7 +263,8 @@ static int br_port_fill_attrs(struct sk_buff *skb,
&p->designated_root) ||
nla_put(skb, IFLA_BRPORT_BRIDGE_ID, sizeof(struct ifla_bridge_id),
&p->designated_bridge) ||
- nla_put_u16(skb, IFLA_BRPORT_DESIGNATED_PORT, p->designated_port) ||
+ nla_put_u16(skb, IFLA_BRPORT_DESIGNATED_PORT,
+ READ_ONCE(p->designated_port)) ||
nla_put_u16(skb, IFLA_BRPORT_DESIGNATED_COST,
READ_ONCE(p->designated_cost)) ||
nla_put_u16(skb, IFLA_BRPORT_ID, p->port_id) ||
diff --git a/net/bridge/br_stp.c b/net/bridge/br_stp.c
index ced8d23f05d1ee262d1760c768e5c88868f13178..cbc48197c3db5e225ead7425b2cee46acc9768f3 100644
--- a/net/bridge/br_stp.c
+++ b/net/bridge/br_stp.c
@@ -261,7 +261,7 @@ static void br_record_config_information(struct net_bridge_port *p,
p->designated_root = bpdu->root;
WRITE_ONCE(p->designated_cost, bpdu->root_path_cost);
p->designated_bridge = bpdu->bridge_id;
- p->designated_port = bpdu->port_id;
+ WRITE_ONCE(p->designated_port, bpdu->port_id);
p->designated_age = jiffies - bpdu->message_age;
mod_timer(&p->message_age_timer, jiffies
@@ -434,7 +434,7 @@ void br_become_designated_port(struct net_bridge_port *p)
p->designated_root = br->designated_root;
WRITE_ONCE(p->designated_cost, br->root_path_cost);
p->designated_bridge = br->bridge_id;
- p->designated_port = p->port_id;
+ WRITE_ONCE(p->designated_port, p->port_id);
}
diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
index e5d43492d2dcf0615ee984bc190d7ce2264aaab0..7b0d1a334785047905a00694fd65e3212b160e5d 100644
--- a/net/bridge/br_stp_if.c
+++ b/net/bridge/br_stp_if.c
@@ -320,7 +320,7 @@ int br_stp_set_port_priority(struct net_bridge_port *p, unsigned long newprio)
new_port_id = br_make_port_id(newprio, p->port_no);
if (br_is_designated_port(p))
- p->designated_port = new_port_id;
+ WRITE_ONCE(p->designated_port, new_port_id);
p->port_id = new_port_id;
p->priority = newprio;
diff --git a/net/bridge/br_sysfs_if.c b/net/bridge/br_sysfs_if.c
index 36b832902d33a492e91d53a4248778b3ee2322ca..1023f97b1c9a22a1f79c3c734aef9bd41832ea39 100644
--- a/net/bridge/br_sysfs_if.c
+++ b/net/bridge/br_sysfs_if.c
@@ -129,7 +129,7 @@ static BRPORT_ATTR(designated_bridge, 0444, show_designated_bridge, NULL);
static ssize_t show_designated_port(struct net_bridge_port *p, char *buf)
{
- return sysfs_emit(buf, "%d\n", p->designated_port);
+ return sysfs_emit(buf, "%d\n", READ_ONCE(p->designated_port));
}
static BRPORT_ATTR(designated_port, 0444, show_designated_port, NULL);
--
2.54.0.1032.g2f8565e1d1-goog
next prev parent reply other threads:[~2026-06-04 14:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 14:13 [PATCH v3 net-next 00/11] bridge: prepare lockless br_port_fill_attrs() (I) Eric Dumazet
2026-06-04 14:13 ` [PATCH v3 net-next 01/11] bridge: add a READ_ONCE() in br_timer_value() Eric Dumazet
2026-06-04 14:13 ` [PATCH v3 net-next 02/11] bridge: add bridge_flags_bit enum Eric Dumazet
2026-06-04 14:13 ` [PATCH v3 net-next 03/11] bridge: use BR_PROMISC_BIT Eric Dumazet
2026-06-04 14:13 ` [PATCH v3 net-next 04/11] bridge: use BR_ADMIN_COST_BIT Eric Dumazet
2026-06-04 14:13 ` [PATCH v3 net-next 05/11] bridge: provide lockless access to p->path_cost Eric Dumazet
2026-06-04 14:13 ` [PATCH v3 net-next 06/11] bridge: provide lockless access to p->designated_cost Eric Dumazet
2026-06-04 18:43 ` Ido Schimmel
2026-06-04 14:13 ` Eric Dumazet [this message]
2026-06-04 14:13 ` [PATCH v3 net-next 08/11] bridge: provide lockless access to p->priority Eric Dumazet
2026-06-04 14:13 ` [PATCH v3 net-next 09/11] bridge: provide lockless access to p->port_id Eric Dumazet
2026-06-04 14:13 ` [PATCH v3 net-next 10/11] bridge: provide lockless access to p->config_pending Eric Dumazet
2026-06-04 14:13 ` [PATCH v3 net-next 11/11] bridge: read p->flags once in br_port_fill_attrs() Eric Dumazet
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=20260604141343.2124500-8-edumazet@google.com \
--to=edumazet@google.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=razor@blackwall.org \
/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