From: Nikolay Aleksandrov <razor@blackwall.org>
To: netdev@vger.kernel.org
Cc: idosch@nvidia.com, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
bridge@lists.linux.dev, Nikolay Aleksandrov <razor@blackwall.org>
Subject: [PATCH net-next 4/6] net: bridge: vlan: inline pvid pointer updates
Date: Mon, 5 Oct 2026 17:39:35 +0300 [thread overview]
Message-ID: <20261005143937.877466-5-razor@blackwall.org> (raw)
In-Reply-To: <20261005143937.877466-1-razor@blackwall.org>
After caching the pvid VLAN entry directly, the add and delete helpers
only check and update the pointer. So inline them both and clear pvid
directly in __vlan_flush before walking the VLAN entries.
Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
---
net/bridge/br_vlan.c | 33 +++++++++------------------------
1 file changed, 9 insertions(+), 24 deletions(-)
diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index dcf783e1a440..c4e7e03e0969 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -34,24 +34,6 @@ static struct net_bridge_vlan *br_vlan_lookup(struct rhashtable *tbl, u16 vid)
return rhashtable_lookup_fast(tbl, &vid, br_vlan_rht_params);
}
-static void __vlan_add_pvid(struct net_bridge_vlan_group *vg,
- struct net_bridge_vlan *v)
-{
- if (rcu_access_pointer(vg->pvid) == v)
- return;
-
- RCU_INIT_POINTER(vg->pvid, v);
-}
-
-static void __vlan_delete_pvid(struct net_bridge_vlan_group *vg,
- struct net_bridge_vlan *v)
-{
- if (rcu_access_pointer(vg->pvid) != v)
- return;
-
- RCU_INIT_POINTER(vg->pvid, NULL);
-}
-
/* Update the BRIDGE_VLAN_INFO_PVID and BRIDGE_VLAN_INFO_UNTAGGED flags of @v.
* If @commit is false, return just whether the BRIDGE_VLAN_INFO_PVID and
* BRIDGE_VLAN_INFO_UNTAGGED bits of @flags would produce any change onto @v.
@@ -78,10 +60,12 @@ static bool __vlan_flags_update(struct net_bridge_vlan *v, u16 flags,
if (!commit)
goto out;
- if (flags & BRIDGE_VLAN_INFO_PVID)
- __vlan_add_pvid(vg, v);
- else
- __vlan_delete_pvid(vg, v);
+ if (flags & BRIDGE_VLAN_INFO_PVID) {
+ if (pvid != v)
+ RCU_INIT_POINTER(vg->pvid, v);
+ } else if (pvid == v) {
+ RCU_INIT_POINTER(vg->pvid, NULL);
+ }
if (flags & BRIDGE_VLAN_INFO_UNTAGGED)
vlan_flags |= BRIDGE_VLAN_INFO_UNTAGGED;
@@ -432,7 +416,8 @@ static int __vlan_add(struct net_bridge_vlan *v, u16 flags,
static void __vlan_unpublish(struct net_bridge_vlan_group *vg,
struct net_bridge_vlan *v)
{
- __vlan_delete_pvid(vg, v);
+ if (rcu_access_pointer(vg->pvid) == v)
+ RCU_INIT_POINTER(vg->pvid, NULL);
if (!br_vlan_is_master(v)) {
struct net_bridge_vlan *masterv = v->brvlan;
@@ -503,7 +488,7 @@ static void __vlan_flush(const struct net_bridge *br,
struct net_bridge_vlan *vlan, *tmp;
u16 v_start = 0, v_end = 0;
- __vlan_delete_pvid(vg, rtnl_dereference(vg->pvid));
+ RCU_INIT_POINTER(vg->pvid, NULL);
list_for_each_entry_safe(vlan, tmp, &vg->vlan_list, vlist) {
/* take care of disjoint ranges */
if (!v_start) {
--
2.47.3
next prev parent reply other threads:[~2026-10-05 14:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-05 14:39 [PATCH net-next 0/6] net: bridge: fwd optimization cleanups Nikolay Aleksandrov
2026-10-05 14:39 ` [PATCH net-next 1/6] net: bridge: rename dst to fwd in br_flood_vlan Nikolay Aleksandrov
2026-10-05 14:39 ` [PATCH net-next 2/6] net: bridge: fdb: update the comment for br_fdb_cleanup_by_dst Nikolay Aleksandrov
2026-10-05 14:39 ` [PATCH net-next 3/6] net: bridge: vlan: share VLAN validation in br_should_learn Nikolay Aleksandrov
2026-10-05 14:39 ` Nikolay Aleksandrov [this message]
2026-10-05 14:39 ` [PATCH net-next 5/6] net: bridge: fdb: factor out configured entry destination updates Nikolay Aleksandrov
2026-10-05 14:39 ` [PATCH net-next 6/6] net: bridge: fdb: use the entry key in __fdb_update Nikolay Aleksandrov
2026-10-06 12:39 ` [PATCH net-next 0/6] net: bridge: fwd optimization cleanups Ido Schimmel
2026-10-07 1:30 ` patchwork-bot+netdevbpf
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=20261005143937.877466-5-razor@blackwall.org \
--to=razor@blackwall.org \
--cc=bridge@lists.linux.dev \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--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