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 5/6] net: bridge: fdb: factor out configured entry destination updates
Date: Mon, 5 Oct 2026 17:39:36 +0300 [thread overview]
Message-ID: <20261005143937.877466-6-razor@blackwall.org> (raw)
In-Reply-To: <20261005143937.877466-1-razor@blackwall.org>
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
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 ` [PATCH net-next 4/6] net: bridge: vlan: inline pvid pointer updates Nikolay Aleksandrov
2026-10-05 14:39 ` Nikolay Aleksandrov [this message]
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-6-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