diff mbox series

[net] bridge: Fix flushing of dynamic FDB entries

Message ID 20221101185753.2120691-1-idosch@nvidia.com (mailing list archive)
State Accepted
Commit 628ac04a75ed5ff13647e725f40192da22ef2be8
Delegated to: Netdev Maintainers
Headers show
Series [net] bridge: Fix flushing of dynamic FDB entries | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Ido Schimmel Nov. 1, 2022, 6:57 p.m. UTC
The following commands should result in all the dynamic FDB entries
being flushed, but instead all the non-local (non-permanent) entries are
flushed:

 # bridge fdb add 00:aa:bb:cc:dd:ee dev dummy1 master static
 # bridge fdb add 00:11:22:33:44:55 dev dummy1 master dynamic
 # ip link set dev br0 type bridge fdb_flush
 # bridge fdb show brport dummy1
 00:00:00:00:00:01 master br0 permanent
 33:33:00:00:00:01 self permanent
 01:00:5e:00:00:01 self permanent

This is because br_fdb_flush() works with FDB flags and not the
corresponding enumerator values. Fix by passing the FDB flag instead.

After the fix:

 # bridge fdb add 00:aa:bb:cc:dd:ee dev dummy1 master static
 # bridge fdb add 00:11:22:33:44:55 dev dummy1 master dynamic
 # ip link set dev br0 type bridge fdb_flush
 # bridge fdb show brport dummy1
 00:aa:bb:cc:dd:ee master br0 static
 00:00:00:00:00:01 master br0 permanent
 33:33:00:00:00:01 self permanent
 01:00:5e:00:00:01 self permanent

Fixes: 1f78ee14eeac ("net: bridge: fdb: add support for fine-grained flushing")
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
 net/bridge/br_netlink.c  | 2 +-
 net/bridge/br_sysfs_br.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Nikolay Aleksandrov Nov. 1, 2022, 7:04 p.m. UTC | #1
On 1 November 2022 20:57:53 EET, Ido Schimmel <idosch@nvidia.com> wrote:
>The following commands should result in all the dynamic FDB entries
>being flushed, but instead all the non-local (non-permanent) entries are
>flushed:
>
> # bridge fdb add 00:aa:bb:cc:dd:ee dev dummy1 master static
> # bridge fdb add 00:11:22:33:44:55 dev dummy1 master dynamic
> # ip link set dev br0 type bridge fdb_flush
> # bridge fdb show brport dummy1
> 00:00:00:00:00:01 master br0 permanent
> 33:33:00:00:00:01 self permanent
> 01:00:5e:00:00:01 self permanent
>
>This is because br_fdb_flush() works with FDB flags and not the
>corresponding enumerator values. Fix by passing the FDB flag instead.
>
>After the fix:
>
> # bridge fdb add 00:aa:bb:cc:dd:ee dev dummy1 master static
> # bridge fdb add 00:11:22:33:44:55 dev dummy1 master dynamic
> # ip link set dev br0 type bridge fdb_flush
> # bridge fdb show brport dummy1
> 00:aa:bb:cc:dd:ee master br0 static
> 00:00:00:00:00:01 master br0 permanent
> 33:33:00:00:00:01 self permanent
> 01:00:5e:00:00:01 self permanent
>
>Fixes: 1f78ee14eeac ("net: bridge: fdb: add support for fine-grained flushing")
>Signed-off-by: Ido Schimmel <idosch@nvidia.com>
>---
> net/bridge/br_netlink.c  | 2 +-
> net/bridge/br_sysfs_br.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
>index 5aeb3646e74c..d087fd4c784a 100644
>--- a/net/bridge/br_netlink.c
>+++ b/net/bridge/br_netlink.c
>@@ -1332,7 +1332,7 @@ static int br_changelink(struct net_device *brdev, struct nlattr *tb[],
> 
> 	if (data[IFLA_BR_FDB_FLUSH]) {
> 		struct net_bridge_fdb_flush_desc desc = {
>-			.flags_mask = BR_FDB_STATIC
>+			.flags_mask = BIT(BR_FDB_STATIC)
> 		};
> 
> 		br_fdb_flush(br, &desc);
>diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c
>index 612e367fff20..ea733542244c 100644
>--- a/net/bridge/br_sysfs_br.c
>+++ b/net/bridge/br_sysfs_br.c
>@@ -345,7 +345,7 @@ static int set_flush(struct net_bridge *br, unsigned long val,
> 		     struct netlink_ext_ack *extack)
> {
> 	struct net_bridge_fdb_flush_desc desc = {
>-		.flags_mask = BR_FDB_STATIC
>+		.flags_mask = BIT(BR_FDB_STATIC)
> 	};
> 
> 	br_fdb_flush(br, &desc);

Oops. :)
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
patchwork-bot+netdevbpf@kernel.org Nov. 3, 2022, 4 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Tue,  1 Nov 2022 20:57:53 +0200 you wrote:
> The following commands should result in all the dynamic FDB entries
> being flushed, but instead all the non-local (non-permanent) entries are
> flushed:
> 
>  # bridge fdb add 00:aa:bb:cc:dd:ee dev dummy1 master static
>  # bridge fdb add 00:11:22:33:44:55 dev dummy1 master dynamic
>  # ip link set dev br0 type bridge fdb_flush
>  # bridge fdb show brport dummy1
>  00:00:00:00:00:01 master br0 permanent
>  33:33:00:00:00:01 self permanent
>  01:00:5e:00:00:01 self permanent
> 
> [...]

Here is the summary with links:
  - [net] bridge: Fix flushing of dynamic FDB entries
    https://git.kernel.org/netdev/net/c/628ac04a75ed

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 5aeb3646e74c..d087fd4c784a 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -1332,7 +1332,7 @@  static int br_changelink(struct net_device *brdev, struct nlattr *tb[],
 
 	if (data[IFLA_BR_FDB_FLUSH]) {
 		struct net_bridge_fdb_flush_desc desc = {
-			.flags_mask = BR_FDB_STATIC
+			.flags_mask = BIT(BR_FDB_STATIC)
 		};
 
 		br_fdb_flush(br, &desc);
diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c
index 612e367fff20..ea733542244c 100644
--- a/net/bridge/br_sysfs_br.c
+++ b/net/bridge/br_sysfs_br.c
@@ -345,7 +345,7 @@  static int set_flush(struct net_bridge *br, unsigned long val,
 		     struct netlink_ext_ack *extack)
 {
 	struct net_bridge_fdb_flush_desc desc = {
-		.flags_mask = BR_FDB_STATIC
+		.flags_mask = BIT(BR_FDB_STATIC)
 	};
 
 	br_fdb_flush(br, &desc);