* [PATCH net-next 1/6] net: bridge: rename dst to fwd in br_flood_vlan
2026-10-05 14:39 [PATCH net-next 0/6] net: bridge: fwd optimization cleanups Nikolay Aleksandrov
@ 2026-10-05 14:39 ` 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
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Nikolay Aleksandrov @ 2026-10-05 14:39 UTC (permalink / raw)
To: netdev
Cc: idosch, davem, edumazet, kuba, pabeni, horms, bridge,
Nikolay Aleksandrov
Rename dst to fwd to be consistent and avoid confusion (dst is used for
fdbs).
Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
---
net/bridge/br_forward.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index 82645db32efb..54365c6104b5 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -291,7 +291,7 @@ static int br_flood_vlan(struct br_fwd_dst *prev,
{
struct net_bridge_vlan_port_array *array;
struct net_bridge_vlan *masterv, *pv;
- struct br_fwd_dst dst;
+ struct br_fwd_dst fwd;
int err;
masterv = br_vlan_is_master(v) ? v : v->brvlan;
@@ -301,18 +301,18 @@ static int br_flood_vlan(struct br_fwd_dst *prev,
for (i = 0; i < array->count; i++) {
pv = array->vlans[i];
- dst.port = pv->port;
- dst.vlan = pv;
- err = br_flood_port(prev, &dst, skb, pkt_type,
+ fwd.port = pv->port;
+ fwd.vlan = pv;
+ err = br_flood_port(prev, &fwd, skb, pkt_type,
local_orig);
if (err)
return err;
}
} else {
list_for_each_entry_rcu(pv, &masterv->port_vlist, port_vlist) {
- dst.port = pv->port;
- dst.vlan = pv;
- err = br_flood_port(prev, &dst, skb, pkt_type,
+ fwd.port = pv->port;
+ fwd.vlan = pv;
+ err = br_flood_port(prev, &fwd, skb, pkt_type,
local_orig);
if (err)
return err;
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH net-next 2/6] net: bridge: fdb: update the comment for br_fdb_cleanup_by_dst
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 ` Nikolay Aleksandrov
2026-10-05 14:39 ` [PATCH net-next 3/6] net: bridge: vlan: share VLAN validation in br_should_learn Nikolay Aleksandrov
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Nikolay Aleksandrov @ 2026-10-05 14:39 UTC (permalink / raw)
To: netdev
Cc: idosch, davem, edumazet, kuba, pabeni, horms, bridge,
Nikolay Aleksandrov
Update the comment for br_fdb_cleanup_by_dst to better reflect what it is
doing after the recent changes.
Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
---
net/bridge/br_fdb.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index 730b178cf6c4..ce09e3fbc58b 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -868,9 +868,11 @@ int br_fdb_delete_bulk(struct nlmsghdr *nlh, struct net_device *dev,
return 0;
}
-/* Clean up all entries referring to a specific destination.
- * if do_all is set also flush static entries
- * if vid is set delete all entries that match the vlan_id
+/* Clean up entries referring to cleanup_dst's port.
+ * If do_all is set ignore vid and entry flags. Otherwise vid selects
+ * the VLAN (0 means all), keeping static and non-offloaded ext learned entries.
+ * For a port-VLAN dst, vid must match its VLAN ID. Always clean up its local
+ * entry unless user-added and fall back to the port dst for retained entries.
*/
void br_fdb_cleanup_by_dst(struct net_bridge *br,
struct net_bridge_dst cleanup_dst, u16 vid,
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH net-next 3/6] net: bridge: vlan: share VLAN validation in br_should_learn
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 ` Nikolay Aleksandrov
2026-10-05 14:39 ` [PATCH net-next 4/6] net: bridge: vlan: inline pvid pointer updates Nikolay Aleksandrov
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Nikolay Aleksandrov @ 2026-10-05 14:39 UTC (permalink / raw)
To: netdev
Cc: idosch, davem, edumazet, kuba, pabeni, horms, bridge,
Nikolay Aleksandrov
Both the pvid and tagged paths now resolve a VLAN entry. Select the entry
first and share the state check and output assignment.
Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
---
net/bridge/br_vlan.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index 0675f74cf1b9..dcf783e1a440 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -742,21 +742,16 @@ bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb,
if (!br_vlan_get_tag(skb, &vid) && skb->vlan_proto != br->vlan_proto)
vid = 0;
- if (!vid) {
+ if (vid)
+ v = br_vlan_find(vg, vid);
+ else
v = rcu_dereference(vg->pvid);
- if (!v || !br_vlan_state_allowed(br_vlan_get_state(v), true))
- return false;
- *vlan = v;
- return true;
- }
- v = br_vlan_find(vg, vid);
- if (v && br_vlan_state_allowed(br_vlan_get_state(v), true)) {
- *vlan = v;
- return true;
- }
+ if (!v || !br_vlan_state_allowed(br_vlan_get_state(v), true))
+ return false;
- return false;
+ *vlan = v;
+ return true;
}
static int br_vlan_add_existing(struct net_bridge *br,
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH net-next 4/6] net: bridge: vlan: inline pvid pointer updates
2026-10-05 14:39 [PATCH net-next 0/6] net: bridge: fwd optimization cleanups Nikolay Aleksandrov
` (2 preceding siblings ...)
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
2026-10-05 14:39 ` [PATCH net-next 5/6] net: bridge: fdb: factor out configured entry destination updates Nikolay Aleksandrov
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Nikolay Aleksandrov @ 2026-10-05 14:39 UTC (permalink / raw)
To: netdev
Cc: idosch, davem, edumazet, kuba, pabeni, horms, bridge,
Nikolay Aleksandrov
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
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH net-next 5/6] net: bridge: fdb: factor out configured entry destination updates
2026-10-05 14:39 [PATCH net-next 0/6] net: bridge: fwd optimization cleanups Nikolay Aleksandrov
` (3 preceding siblings ...)
2026-10-05 14:39 ` [PATCH net-next 4/6] net: bridge: vlan: inline pvid pointer updates Nikolay Aleksandrov
@ 2026-10-05 14:39 ` Nikolay Aleksandrov
2026-10-05 14:39 ` [PATCH net-next 6/6] net: bridge: fdb: use the entry key in __fdb_update Nikolay Aleksandrov
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Nikolay Aleksandrov @ 2026-10-05 14:39 UTC (permalink / raw)
To: netdev
Cc: idosch, davem, edumazet, kuba, pabeni, horms, bridge,
Nikolay Aleksandrov
Share the destination update logic used by user configured and ext learned
entries. Report a modification only when the port changes.
Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
---
net/bridge/br_fdb.c | 34 ++++++++++++++++++----------------
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index ce09e3fbc58b..927e5f23df5b 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -1193,6 +1193,22 @@ static bool fdb_handle_notify(struct net_bridge_fdb_entry *fdb, u8 notify)
return modified;
}
+static bool fdb_update_dst(struct net_bridge_fdb_entry *fdb,
+ struct net_bridge_dst old_dst,
+ struct net_bridge_dst dst)
+{
+ if (br_dst_equal(old_dst, dst))
+ return false;
+
+ if (br_dst_port(old_dst) == br_dst_port(dst)) {
+ br_fdb_dst_replace(fdb, old_dst, dst);
+ return false;
+ }
+
+ br_fdb_dst_write(fdb, dst);
+ return true;
+}
+
/* Update (create or replace) forwarding database entry */
static int fdb_add_entry(struct net_bridge *br, struct net_bridge_dst dst,
const u8 *addr, struct ndmsg *ndm, u16 flags, u16 vid,
@@ -1246,14 +1262,7 @@ static int fdb_add_entry(struct net_bridge *br, struct net_bridge_dst dst,
return -EEXIST;
old_dst = br_fdb_dst_read(fdb);
- if (!br_dst_equal(old_dst, dst)) {
- if (br_dst_port(old_dst) != source) {
- modified = true;
- br_fdb_dst_write(fdb, dst);
- } else {
- br_fdb_dst_replace(fdb, old_dst, dst);
- }
- }
+ modified = fdb_update_dst(fdb, old_dst, dst);
set_bit(BR_FDB_ADDED_BY_USER, &fdb->flags);
if (test_and_clear_bit(BR_FDB_DYNAMIC_LEARNED, &fdb->flags))
@@ -1634,14 +1643,7 @@ int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p,
WRITE_ONCE(fdb->updated, jiffies);
- if (!br_dst_equal(old_dst, dst)) {
- if (br_dst_port(old_dst) != p) {
- modified = true;
- br_fdb_dst_write(fdb, dst);
- } else {
- br_fdb_dst_replace(fdb, old_dst, dst);
- }
- }
+ modified = fdb_update_dst(fdb, old_dst, dst);
if (test_and_set_bit(BR_FDB_ADDED_BY_EXT_LEARN, &fdb->flags)) {
/* Refresh entry */
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH net-next 6/6] net: bridge: fdb: use the entry key in __fdb_update
2026-10-05 14:39 [PATCH net-next 0/6] net: bridge: fwd optimization cleanups Nikolay Aleksandrov
` (4 preceding siblings ...)
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 ` 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
7 siblings, 0 replies; 9+ messages in thread
From: Nikolay Aleksandrov @ 2026-10-05 14:39 UTC (permalink / raw)
To: netdev
Cc: idosch, davem, edumazet, kuba, pabeni, horms, bridge,
Nikolay Aleksandrov
The address and VLAN ID passed to __fdb_update() match the key of the entry
just found, so we can just use it.
Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
---
net/bridge/br_fdb.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index 927e5f23df5b..b601245ad923 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -1000,7 +1000,6 @@ static void __fdb_update(struct net_bridge *br,
struct net_bridge_fdb_entry *fdb,
struct net_bridge_port *source,
struct net_bridge_dst dst,
- const unsigned char *addr, u16 vid,
unsigned long flags)
{
struct net_bridge_port *old_port;
@@ -1012,7 +1011,8 @@ static void __fdb_update(struct net_bridge *br,
if (unlikely(test_bit(BR_FDB_LOCAL, &fdb->flags))) {
if (net_ratelimit())
br_warn(br, "received packet on %s with own address as source address (addr:%pM, vlan:%u)\n",
- source->dev->name, addr, vid);
+ source->dev->name, fdb->key.addr.addr,
+ fdb->key.vlan_id);
return;
}
@@ -1055,7 +1055,8 @@ static void __fdb_update(struct net_bridge *br,
}
if (unlikely(fdb_modified)) {
- trace_br_fdb_update(br, source, addr, vid, flags);
+ trace_br_fdb_update(br, source, fdb->key.addr.addr,
+ fdb->key.vlan_id, flags);
fdb_notify(br, fdb, RTM_NEWNEIGH, true);
}
}
@@ -1075,7 +1076,7 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
fdb = fdb_find_rcu(&br->fdb_hash_tbl, addr, vid);
if (likely(fdb)) {
- __fdb_update(br, fdb, source, dst, addr, vid, flags);
+ __fdb_update(br, fdb, source, dst, flags);
} else {
spin_lock(&br->hash_lock);
fdb = fdb_create(br, dst, addr, vid, flags);
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH net-next 0/6] net: bridge: fwd optimization cleanups
2026-10-05 14:39 [PATCH net-next 0/6] net: bridge: fwd optimization cleanups Nikolay Aleksandrov
` (5 preceding siblings ...)
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 ` Ido Schimmel
2026-10-07 1:30 ` patchwork-bot+netdevbpf
7 siblings, 0 replies; 9+ messages in thread
From: Ido Schimmel @ 2026-10-06 12:39 UTC (permalink / raw)
To: Nikolay Aleksandrov; +Cc: netdev, davem, edumazet, kuba, pabeni, horms, bridge
On Mon, Oct 05, 2026 at 05:39:31PM +0300, Nikolay Aleksandrov wrote:
> Hi,
> This patch-set takes care of the review comments and also does some
> additional cleanups after the recent forwarding optimizations. The first
> patch and the fourth take care of Ido's comments[1]. I have folded his
> suggestion with inlining the pvid helpers which aren't necessary anymore.
> The second patch takes care of Sashiko's comment[2]. The rest are
> additional cleanups. No functional changes intended by any of these.
> For more information please check their commit messages.
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH net-next 0/6] net: bridge: fwd optimization cleanups
2026-10-05 14:39 [PATCH net-next 0/6] net: bridge: fwd optimization cleanups Nikolay Aleksandrov
` (6 preceding siblings ...)
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
7 siblings, 0 replies; 9+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-10-07 1:30 UTC (permalink / raw)
To: Nikolay Aleksandrov
Cc: netdev, idosch, davem, edumazet, kuba, pabeni, horms, bridge
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 5 Oct 2026 17:39:31 +0300 you wrote:
> Hi,
> This patch-set takes care of the review comments and also does some
> additional cleanups after the recent forwarding optimizations. The first
> patch and the fourth take care of Ido's comments[1]. I have folded his
> suggestion with inlining the pvid helpers which aren't necessary anymore.
> The second patch takes care of Sashiko's comment[2]. The rest are
> additional cleanups. No functional changes intended by any of these.
> For more information please check their commit messages.
>
> [...]
Here is the summary with links:
- [net-next,1/6] net: bridge: rename dst to fwd in br_flood_vlan
https://git.kernel.org/netdev/net-next/c/46d20a256be5
- [net-next,2/6] net: bridge: fdb: update the comment for br_fdb_cleanup_by_dst
https://git.kernel.org/netdev/net-next/c/6317ffc9bdd0
- [net-next,3/6] net: bridge: vlan: share VLAN validation in br_should_learn
https://git.kernel.org/netdev/net-next/c/33c73892eaab
- [net-next,4/6] net: bridge: vlan: inline pvid pointer updates
https://git.kernel.org/netdev/net-next/c/1fbe2d9d37ad
- [net-next,5/6] net: bridge: fdb: factor out configured entry destination updates
https://git.kernel.org/netdev/net-next/c/d65082c8bfb8
- [net-next,6/6] net: bridge: fdb: use the entry key in __fdb_update
https://git.kernel.org/netdev/net-next/c/8f8a20dc7bf0
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 9+ messages in thread