Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] net: bridge: optimize vlan multicast forwarding
@ 2026-11-23 10:28 Nikolay Aleksandrov
  2026-11-23 10:28 ` [PATCH net-next 1/3] net: bridge: avoid VLAN lookups for multicast router forwarding Nikolay Aleksandrov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Nikolay Aleksandrov @ 2026-11-23 10:28 UTC (permalink / raw)
  To: netdev
  Cc: Nikolay Aleksandrov, Ido Schimmel, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, bridge

Hi,
This is the last part of the patch-sets that optimize forwarding by caching
VLANs. It adds the forwarding optimizations to the bridge multicast code
and also optimizes vlan range add (see tables below).

Patch 01 - use the vlan already stored in the in per-VLAN router context
Patch 02 - use a small hash (64 entries) to find the port vlan groups
           without walking all
Patch 03 - cache the port-VLAN destination in mdbs to avoid egress VLAN
           lookups

VLAN Add improvement (patch 02):
Operation  VLANs   Global ms before/after   Change %   Per-VLAN ms before/after   Change %
  ------------------------------------------------------------------------------------------
  add            1      0.0519 /   0.0900      +73.52       0.0481 /   0.0895      +86.16
  add           64      2.2500 /   0.7190      -68.04       2.2726 /   0.7441      -67.26
  add         1024     32.7464 /   5.7028      -82.58      32.9841 /   6.3116      -80.86
  add         4094    149.6750 /  34.3223      -77.07     151.5808 /  35.4586      -76.61

Single vlan add is slower, but vlan group add is 67-80% faster. Vlan del is
pretty much the same.

VLAN forwarding improvement (patch 03):
  VLANs  Listeners  Mpps before  Mpps after  Gain %  Cycles before  Cycles after  Saved %
  ---------------------------------------------------------------------------------------
    8          4     0.785571    0.865156  +10.13         3771.2        3381.2    10.34
    8          8     0.454257    0.511490  +12.60         6900.5        6091.0    11.73
    8         16     0.249896    0.288575  +15.48        13144.0       11362.9    13.55
   64          4     0.765468    0.841916   +9.99         3881.6        3462.1    10.81
   64          8     0.437448    0.501744  +14.70         7153.6        6215.6    13.11
   64         16     0.238901    0.279188  +16.86        13690.2       11674.2    14.73
 4094          4     0.583447    0.695246  +19.16         5271.6        4339.3    17.68
 4094          8     0.293712    0.373710  +27.24        11001.0        8492.8    22.80
 4094         16     0.140026    0.191269  +36.60        23509.6       17213.7    26.78

Medians of 6 runs, 64-byte frames, one group per VLAN, and packet VIDs
chosen at random. Cycles are PMU cycles / input packet on the fwding CPU.

CC: Ido Schimmel <idosch@nvidia.com>
CC: David S. Miller <davem@davemloft.net>
CC: Eric Dumazet <edumazet@kernel.org>
CC: Jakub Kicinski <kuba@kernel.org>
CC: Paolo Abeni <pabeni@redhat.com>
CC: Simon Horman <horms@kernel.org>
CC: bridge@lists.linux.dev

Thanks,
 Nik

Nikolay Aleksandrov (3):
  net: bridge: avoid VLAN lookups for multicast router forwarding
  net: bridge: mdb: index port groups by VLAN
  net: bridge: mdb: avoid VLAN lookups in listener forwarding

 net/bridge/br_forward.c   | 21 +++++++++++++--------
 net/bridge/br_multicast.c | 31 ++++++++++++++++++++++++++++++-
 net/bridge/br_private.h   | 30 ++++++++++++++++--------------
 net/bridge/br_vlan.c      |  2 ++
 4 files changed, 61 insertions(+), 23 deletions(-)

-- 
2.47.3


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net-next 1/3] net: bridge: avoid VLAN lookups for multicast router forwarding
  2026-11-23 10:28 [PATCH net-next 0/3] net: bridge: optimize vlan multicast forwarding Nikolay Aleksandrov
@ 2026-11-23 10:28 ` Nikolay Aleksandrov
  2026-11-23 10:28 ` [PATCH net-next 2/3] net: bridge: mdb: index port groups by VLAN Nikolay Aleksandrov
  2026-11-23 10:28 ` [PATCH net-next 3/3] net: bridge: mdb: avoid VLAN lookups in listener forwarding Nikolay Aleksandrov
  2 siblings, 0 replies; 4+ messages in thread
From: Nikolay Aleksandrov @ 2026-11-23 10:28 UTC (permalink / raw)
  To: netdev
  Cc: Nikolay Aleksandrov, Ido Schimmel, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, bridge

Return the multicast port context when decoding a router-list node and
pass its VLAN entry to the forwarding destination. With per-VLAN snooping,
the context already identifies the egress port VLAN, so validation and
tagging can use it directly.

A per-VLAN router context is selected through the resolved ingress VLAN.
Global router contexts have no VLAN pointer and resolve their VLAN during
egress validation.

During port VLAN deletion, a per-VLAN router context can remain on the
router list after the VLAN has been unpublished. Forwarding can therefore
still use its cached VLAN until router-list removal, whereas a fresh VLAN
lookup would reject it. This is transient forwarding during teardown,
consistent with the existing cached FDB destination behavior. RCU protects
the VLAN's lifetime, and context cleanup removes it from the router lists.

Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
---
local Sashiko review says:
 [Severity: Medium]
 Can this forward multicast through a port VLAN after it is unpublished?

 CPU0                              CPU1
 nbp_vlan_delete()
   __vlan_unpublish(vg, v)
                                   br_multicast_flood()
                                     fwd.vlan = rpmctx->vlan
                                     should_deliver_vlan()
                                     br_handle_vlan()
                                       <-- forwards on removed VLAN
   br_multicast_port_ctx_deinit(...)

 Nik: this is already documented, it can forward for a short-while until
      ctx_deinit is called which is fine

CC: Ido Schimmel <idosch@nvidia.com>
CC: David S. Miller <davem@davemloft.net>
CC: Eric Dumazet <edumazet@kernel.org>
CC: Jakub Kicinski <kuba@kernel.org>
CC: Paolo Abeni <pabeni@redhat.com>
CC: Simon Horman <horms@kernel.org>
CC: bridge@lists.linux.dev

 net/bridge/br_forward.c |  5 ++++-
 net/bridge/br_private.h | 19 +++++--------------
 2 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index 54365c6104b5..b725e8f1b29a 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -412,10 +412,12 @@ void br_multicast_flood(struct net_bridge_mdb_entry *mdst,
 
 	while (p || rp) {
 		struct net_bridge_port *port, *lport, *rport;
+		struct net_bridge_mcast_port *rpmctx;
 		struct br_fwd_dst fwd = {};
 
 		lport = p ? p->key.port : NULL;
-		rport = br_multicast_rport_from_node_skb(rp, skb);
+		rpmctx = br_multicast_rport_ctx_from_node_skb(rp, skb);
+		rport = rpmctx ? rpmctx->port : NULL;
 
 		if ((unsigned long)lport > (unsigned long)rport) {
 			port = lport;
@@ -432,6 +434,7 @@ void br_multicast_flood(struct net_bridge_mdb_entry *mdst,
 				goto delivered;
 		} else {
 			port = rport;
+			fwd.vlan = rpmctx->vlan;
 		}
 
 		fwd.port = port;
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 014d0b8db8c7..20e423e22132 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -1244,24 +1244,15 @@ br_multicast_get_first_rport_node(struct net_bridge_mcast *brmctx,
 	return rcu_dereference(hlist_first_rcu(&brmctx->ip4_mc_router_list));
 }
 
-static inline struct net_bridge_port *
-br_multicast_rport_from_node_skb(struct hlist_node *rp, struct sk_buff *skb)
+static inline struct net_bridge_mcast_port *
+br_multicast_rport_ctx_from_node_skb(struct hlist_node *rp, struct sk_buff *skb)
 {
-	struct net_bridge_mcast_port *mctx;
-
 #if IS_ENABLED(CONFIG_IPV6)
 	if (skb->protocol == htons(ETH_P_IPV6))
-		mctx = hlist_entry_safe(rp, struct net_bridge_mcast_port,
-					ip6_rlist);
-	else
+		return hlist_entry_safe(rp, struct net_bridge_mcast_port,
+				       ip6_rlist);
 #endif
-		mctx = hlist_entry_safe(rp, struct net_bridge_mcast_port,
-					ip4_rlist);
-
-	if (mctx)
-		return mctx->port;
-	else
-		return NULL;
+	return hlist_entry_safe(rp, struct net_bridge_mcast_port, ip4_rlist);
 }
 
 static inline bool br_ip4_multicast_is_router(struct net_bridge_mcast *brmctx)
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net-next 2/3] net: bridge: mdb: index port groups by VLAN
  2026-11-23 10:28 [PATCH net-next 0/3] net: bridge: optimize vlan multicast forwarding Nikolay Aleksandrov
  2026-11-23 10:28 ` [PATCH net-next 1/3] net: bridge: avoid VLAN lookups for multicast router forwarding Nikolay Aleksandrov
@ 2026-11-23 10:28 ` Nikolay Aleksandrov
  2026-11-23 10:28 ` [PATCH net-next 3/3] net: bridge: mdb: avoid VLAN lookups in listener forwarding Nikolay Aleksandrov
  2 siblings, 0 replies; 4+ messages in thread
From: Nikolay Aleksandrov @ 2026-11-23 10:28 UTC (permalink / raw)
  To: netdev
  Cc: Nikolay Aleksandrov, Ido Schimmel, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, bridge

Index each port's multicast groups by VID in a fixed 64-bucket hash
table. Maintain the index under multicast_lock alongside mglist,
including groups retained without port VLAN membership, and remove
entries on both port-group deletion paths.

Use the index when counting groups for a newly created port VLAN
context, avoiding a scan of all groups on the port for every added VLAN.
Keep mglist for its existing RCU readers and teardown walks. The index
also lets VLAN publication and unpublication update cached destinations
without repeatedly walking the full group list.

Operation  VLANs   Global ms before/after   Change %   Per-VLAN ms before/after   Change %
  ------------------------------------------------------------------------------------------
  add            1      0.0519 /   0.0900      +73.52       0.0481 /   0.0895      +86.16
  add           64      2.2500 /   0.7190      -68.04       2.2726 /   0.7441      -67.26
  add         1024     32.7464 /   5.7028      -82.58      32.9841 /   6.3116      -80.86
  add         4094    149.6750 /  34.3223      -77.07     151.5808 /  35.4586      -76.61

Note that the struct net_bridge_port_group increase pushes the allocations
above 256 bytes and into kmalloc-512, this can be kept compact by
introducing a kmalloc cache for these. It can be done separately.

Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
---
CC: Ido Schimmel <idosch@nvidia.com>
CC: David S. Miller <davem@davemloft.net>
CC: Eric Dumazet <edumazet@kernel.org>
CC: Jakub Kicinski <kuba@kernel.org>
CC: Paolo Abeni <pabeni@redhat.com>
CC: Simon Horman <horms@kernel.org>
CC: bridge@lists.linux.dev

 net/bridge/br_multicast.c | 7 ++++++-
 net/bridge/br_private.h   | 4 ++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index ae4fa050be97..7285229ca6d7 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -826,6 +826,7 @@ static void __br_multicast_del_pg(struct net_bridge_mdb_entry *mp,
 	 * and deleting other groups of the same port must not truncate it.
 	 */
 	hlist_del_init_rcu(&pg->mglist);
+	hash_del(&pg->vlan_node);
 	br_multicast_eht_clean_sets(pg);
 	hlist_for_each_entry_safe(ent, tmp, &pg->src_list, node)
 		br_multicast_del_group_src(ent, false);
@@ -1472,6 +1473,7 @@ struct net_bridge_port_group *br_multicast_new_port_group(
 
 	RCU_INIT_POINTER(p->next, next);
 	hlist_add_head_rcu(&p->mglist, &port->mglist);
+	hash_add(port->mdb_vlan_hash, &p->vlan_node, group->vid);
 
 	return p;
 
@@ -1488,6 +1490,7 @@ void br_multicast_del_port_group(struct net_bridge_port_group *p)
 	__u16 vid = p->key.addr.vid;
 
 	hlist_del_init_rcu(&p->mglist);
+	hash_del(&p->vlan_node);
 	if (!br_multicast_is_star_g(&p->key.addr))
 		rhashtable_remove_fast(&port->br->sg_port_tbl, &p->rhnode,
 				       br_sg_port_rht_params);
@@ -2105,7 +2108,8 @@ void br_multicast_port_ctx_init(struct net_bridge_port *port,
 		u32 n = 0;
 
 		spin_lock_bh(&port->br->multicast_lock);
-		hlist_for_each_entry(pg, &port->mglist, mglist)
+		hash_for_each_possible(port->mdb_vlan_hash, pg, vlan_node,
+				       vlan->vid)
 			if (pg->key.addr.vid == vlan->vid)
 				n++;
 		WRITE_ONCE(pmctx->mdb_n_entries, n);
@@ -2138,6 +2142,7 @@ int br_multicast_add_port(struct net_bridge_port *port)
 {
 	int err;
 
+	hash_init(port->mdb_vlan_hash);
 	port->multicast_eht_hosts_limit = BR_MCAST_DEFAULT_EHT_HOSTS_LIMIT;
 	br_multicast_port_ctx_init(port, NULL, &port->multicast_ctx);
 
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 20e423e22132..04430dc32d02 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -18,6 +18,7 @@
 #include <net/pkt_cls.h>
 #include <linux/if_vlan.h>
 #include <linux/rhashtable.h>
+#include <linux/hashtable.h>
 #include <linux/refcount.h>
 
 #define BR_HASH_BITS 8
@@ -29,6 +30,7 @@
 #define BR_MAX_PORTS	(1<<BR_PORT_BITS)
 
 #define BR_MULTICAST_DEFAULT_HASH_MAX 4096
+#define BR_MDB_VLAN_HASH_BITS 6
 #define BR_MULTICAST_QUERY_INTVL_MIN msecs_to_jiffies(1000)
 #define BR_MULTICAST_STARTUP_QUERY_INTVL_MIN BR_MULTICAST_QUERY_INTVL_MIN
 #define BR_MULTICAST_QUERY_INTVL_MAX msecs_to_jiffies(86400000) /* 24 hours */
@@ -386,6 +388,7 @@ struct net_bridge_port_group {
 	struct timer_list		timer;
 	struct timer_list		rexmit_timer;
 	struct hlist_node		mglist;
+	struct hlist_node		vlan_node;
 	struct rb_root			eht_set_tree;
 	struct rb_root			eht_host_tree;
 
@@ -449,6 +452,7 @@ struct net_bridge_port {
 	u32				multicast_eht_hosts_limit;
 	u32				multicast_eht_hosts_cnt;
 	struct hlist_head		mglist;
+	DECLARE_HASHTABLE(mdb_vlan_hash, BR_MDB_VLAN_HASH_BITS);
 #endif
 
 #ifdef CONFIG_SYSFS
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net-next 3/3] net: bridge: mdb: avoid VLAN lookups in listener forwarding
  2026-11-23 10:28 [PATCH net-next 0/3] net: bridge: optimize vlan multicast forwarding Nikolay Aleksandrov
  2026-11-23 10:28 ` [PATCH net-next 1/3] net: bridge: avoid VLAN lookups for multicast router forwarding Nikolay Aleksandrov
  2026-11-23 10:28 ` [PATCH net-next 2/3] net: bridge: mdb: index port groups by VLAN Nikolay Aleksandrov
@ 2026-11-23 10:28 ` Nikolay Aleksandrov
  2 siblings, 0 replies; 4+ messages in thread
From: Nikolay Aleksandrov @ 2026-11-23 10:28 UTC (permalink / raw)
  To: netdev
  Cc: Nikolay Aleksandrov, Ido Schimmel, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, bridge

Cache a port or port-VLAN destination in each mdb port group and pass
its resolved VLAN to listener and multicast-to-unicast forwarding.
Groups with port VLAN membership can validate egress and handle tagging
without VLAN lookups.

Adding or deleting a port VLAN rewrites the cached destination of every
group in that VLAN so its cost grows linearly with the VLAN's groups.

When a listener is also a global multicast router, use its cached
destination while retaining router delivery semantics.

VLAN forwarding improvement:
  VLANs  Listeners  Mpps before  Mpps after  Gain %  Cycles before  Cycles after  Saved %
  ---------------------------------------------------------------------------------------
    8          4     0.785571    0.865156  +10.13         3771.2        3381.2    10.34
    8          8     0.454257    0.511490  +12.60         6900.5        6091.0    11.73
    8         16     0.249896    0.288575  +15.48        13144.0       11362.9    13.55
   64          4     0.765468    0.841916   +9.99         3881.6        3462.1    10.81
   64          8     0.437448    0.501744  +14.70         7153.6        6215.6    13.11
   64         16     0.238901    0.279188  +16.86        13690.2       11674.2    14.73
 4094          4     0.583447    0.695246  +19.16         5271.6        4339.3    17.68
 4094          8     0.293712    0.373710  +27.24        11001.0        8492.8    22.80
 4094         16     0.140026    0.191269  +36.60        23509.6       17213.7    26.78

Medians of 6 runs, 64b frames, one group per VLAN and packet VIDs
chosen at random. Cycles are PMU cycles / input packet on the fwding CPU.

Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
---
CC: Ido Schimmel <idosch@nvidia.com>
CC: David S. Miller <davem@davemloft.net>
CC: Eric Dumazet <edumazet@kernel.org>
CC: Jakub Kicinski <kuba@kernel.org>
CC: Paolo Abeni <pabeni@redhat.com>
CC: Simon Horman <horms@kernel.org>
CC: bridge@lists.linux.dev

 net/bridge/br_forward.c   | 16 +++++++++-------
 net/bridge/br_multicast.c | 24 ++++++++++++++++++++++++
 net/bridge/br_private.h   |  7 +++++++
 net/bridge/br_vlan.c      |  2 ++
 4 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index b725e8f1b29a..321e63495548 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -353,17 +353,15 @@ void br_flood(struct net_bridge *br, struct net_bridge_vlan *v,
 }
 
 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
-static void maybe_deliver_addr(struct net_bridge_port *p, struct sk_buff *skb,
+static void maybe_deliver_addr(struct br_fwd_dst *fwd, struct sk_buff *skb,
 			       const unsigned char *addr, bool local_orig)
 {
 	struct net_device *dev = BR_INPUT_SKB_CB(skb)->brdev;
 	const unsigned char *src = eth_hdr(skb)->h_source;
-	struct br_fwd_dst fwd = {
-		.port = p,
-	};
+	struct net_bridge_port *p = fwd->port;
 	struct sk_buff *nskb;
 
-	if (!should_deliver(&fwd, skb))
+	if (!should_deliver(fwd, skb))
 		return;
 
 	/* Even with hairpin, no soliloquies - prevent breaking IPv6 DAD */
@@ -383,7 +381,7 @@ static void maybe_deliver_addr(struct net_bridge_port *p, struct sk_buff *skb,
 	if (!is_broadcast_ether_addr(addr))
 		memcpy(eth_hdr(skb)->h_dest, addr, ETH_ALEN);
 
-	__br_forward(&fwd, skb, local_orig);
+	__br_forward(fwd, skb, local_orig);
 }
 
 /* called with rcu_read_lock */
@@ -421,10 +419,11 @@ void br_multicast_flood(struct net_bridge_mdb_entry *mdst,
 
 		if ((unsigned long)lport > (unsigned long)rport) {
 			port = lport;
+			br_dst_decode(br_dst_read(&p->dst), &fwd.port, &fwd.vlan);
 
 			if (test_bit(BR_MULTICAST_TO_UNICAST_BIT,
 				     &port->flags)) {
-				maybe_deliver_addr(lport, skb, p->eth_addr,
+				maybe_deliver_addr(&fwd, skb, p->eth_addr,
 						   local_orig);
 				goto delivered;
 			}
@@ -435,6 +434,9 @@ void br_multicast_flood(struct net_bridge_mdb_entry *mdst,
 		} else {
 			port = rport;
 			fwd.vlan = rpmctx->vlan;
+			if (!fwd.vlan && lport == rport)
+				br_dst_decode(br_dst_read(&p->dst),
+					      &fwd.port, &fwd.vlan);
 		}
 
 		fwd.port = port;
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index 7285229ca6d7..907918b31251 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -1423,6 +1423,22 @@ br_multicast_new_group_src(struct net_bridge_port_group *pg, struct br_ip *src_i
 	return grp_src;
 }
 
+void br_multicast_update_vlan_dst(struct net_bridge_vlan *vlan, bool add)
+{
+	struct net_bridge_port *port = vlan->port;
+	struct net_bridge_port_group *pg;
+	struct net_bridge_dst dst;
+
+	ASSERT_RTNL();
+
+	dst = add ? br_vlan_to_dst(vlan) : br_port_to_dst(port);
+	spin_lock_bh(&port->br->multicast_lock);
+	hash_for_each_possible(port->mdb_vlan_hash, pg, vlan_node, vlan->vid)
+		if (pg->key.addr.vid == vlan->vid)
+			br_dst_write(&pg->dst, dst);
+	spin_unlock_bh(&port->br->multicast_lock);
+}
+
 struct net_bridge_port_group *br_multicast_new_port_group(
 			struct net_bridge_port *port,
 			const struct br_ip *group,
@@ -1433,9 +1449,12 @@ struct net_bridge_port_group *br_multicast_new_port_group(
 			u8 rt_protocol,
 			struct netlink_ext_ack *extack)
 {
+	struct net_bridge_vlan *vlan = NULL;
 	struct net_bridge_port_group *p;
 	int err;
 
+	lockdep_assert_held_once(&port->br->multicast_lock);
+
 	err = br_multicast_port_ngroups_inc(port, group, extack);
 	if (err)
 		return NULL;
@@ -1448,6 +1467,11 @@ struct net_bridge_port_group *br_multicast_new_port_group(
 
 	p->key.addr = *group;
 	p->key.port = port;
+	rcu_read_lock();
+	if (group->vid)
+		vlan = br_vlan_find(nbp_vlan_group_rcu(port), group->vid);
+	br_dst_write(&p->dst, vlan ? br_vlan_to_dst(vlan) : br_port_to_dst(port));
+	rcu_read_unlock();
 	p->flags = flags;
 	p->filter_mode = filter_mode;
 	p->rt_protocol = rt_protocol;
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 04430dc32d02..b4a35bd05879 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -377,6 +377,7 @@ struct net_bridge_port_group_sg_key {
 struct net_bridge_port_group {
 	struct net_bridge_port_group __rcu *next;
 	struct net_bridge_port_group_sg_key key;
+	struct net_bridge_dst		dst;
 	unsigned char			eth_addr[ETH_ALEN] __aligned(2);
 	unsigned char			flags;
 	unsigned char			filter_mode;
@@ -1211,6 +1212,7 @@ void br_multicast_port_ctx_init(struct net_bridge_port *port,
 				struct net_bridge_vlan *vlan,
 				struct net_bridge_mcast_port *pmctx);
 void br_multicast_port_ctx_deinit(struct net_bridge_mcast_port *pmctx);
+void br_multicast_update_vlan_dst(struct net_bridge_vlan *vlan, bool add);
 void br_multicast_update_vlan_mcast_ctx(struct net_bridge_vlan *v, u8 state);
 void br_multicast_toggle_one_vlan(struct net_bridge_vlan *vlan, bool on);
 int br_multicast_toggle_vlan_snooping(struct net_bridge *br, bool on,
@@ -1682,6 +1684,11 @@ static inline void br_multicast_port_ctx_deinit(struct net_bridge_mcast_port *pm
 {
 }
 
+static inline void br_multicast_update_vlan_dst(struct net_bridge_vlan *vlan,
+						bool add)
+{
+}
+
 static inline void br_multicast_update_vlan_mcast_ctx(struct net_bridge_vlan *v,
 						      u8 state)
 {
diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index 6f6b574a359d..43ca46a5b926 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -383,6 +383,7 @@ static int __vlan_add(struct net_bridge_vlan *v, u16 flags,
 	br_multicast_toggle_one_vlan(v, true);
 
 	if (p) {
+		br_multicast_update_vlan_dst(v, true);
 		br_vlan_rebuild_port_array(masterv, br_vlan_num_ports(masterv));
 		nbp_vlan_set_vlan_dev_state(p, v->vid);
 	}
@@ -424,6 +425,7 @@ static void __vlan_unpublish(struct net_bridge_vlan_group *vg,
 		rhashtable_remove_fast(&vg->vlan_hash, &v->vnode,
 				       br_vlan_rht_params);
 		__vlan_del_list(v);
+		br_multicast_update_vlan_dst(v, false);
 		/* -1 because br_vlan_put_master() is called later */
 		br_vlan_rebuild_port_array(masterv,
 					   br_vlan_num_ports(masterv) - 1);
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-23 10:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 10:28 [PATCH net-next 0/3] net: bridge: optimize vlan multicast forwarding Nikolay Aleksandrov
2026-11-23 10:28 ` [PATCH net-next 1/3] net: bridge: avoid VLAN lookups for multicast router forwarding Nikolay Aleksandrov
2026-11-23 10:28 ` [PATCH net-next 2/3] net: bridge: mdb: index port groups by VLAN Nikolay Aleksandrov
2026-11-23 10:28 ` [PATCH net-next 3/3] net: bridge: mdb: avoid VLAN lookups in listener forwarding Nikolay Aleksandrov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox