bridge: fdb: add extended flush support
Subsystems (2)
cover bridge: fdb: add extended flush support
Hi,
This set adds support for the new bulk delete flag to allow fdb flushing for specific entries which are matched based on the supplied options. The new bridge fdb subcommand is "flush", and as can be seen from the commits it allows to delete entries based on many different criteria:
- matching vlan
- matching port
- matching all sorts of flags (combinations are allowed)
There are also examples for each option in the respective commit messages.
Examples:
$ bridge fdb flush dev swp2 master vlan 100 dynamic [ delete all dynamic entries with port swp2 and vlan 100 ] $ bridge fdb flush dev br0 vlan 1 static [ delete all static entries in br0's fdb table ] $ bridge fdb flush dev swp2 master extern_learn nosticky [ delete all entries with port swp2 which have extern_learn set and don't have the sticky flag set ] $ bridge fdb flush dev br0 brport br0 vlan 100 permanent [ delete all entries pointing to the bridge itself with vlan 100 ] $ bridge fdb flush dev swp2 master nostatic nooffloaded [ delete all entries with port swp2 which are not static and not offloaded ]
If keyword is specified and after that nokeyword is specified obviously the nokeyword would override keyword.
Thanks,
Nik
Nikolay Aleksandrov (10):
bridge: fdb: add new flush command
bridge: fdb: add flush vlan matching
bridge: fdb: add flush port matching
bridge: fdb: add flush [no]permanent entry matching
bridge: fdb: add flush [no]static entry matching
bridge: fdb: add flush [no]dynamic entry matching
bridge: fdb: add flush [no]added_by_user entry matching
bridge: fdb: add flush [no]extern_learn entry matching
bridge: fdb: add flush [no]sticky entry matching
bridge: fdb: add flush [no]offloaded entry matching
bridge/fdb.c | 142 +++++++++++++++++++++++++++++++++++++++++++++- man/man8/bridge.8 | 83 +++++++++++++++++++++++++++ 2 files changed, 224 insertions(+), 1 deletion(-)
Signature · 1 line
2.35.1
PATCH 1/10 bridge: fdb: add new flush command
Add support for fdb bulk delete (aka flush) command. Currently it only supports the self and master flags with the same semantics as fdb add/del. The device is a mandatory argument.
Example:
$ bridge fdb flush dev br0 This will delete *all* fdb entries in br0's fdb table.
$ bridge fdb flush dev swp1 master This will delete all fdb entries pointing to swp1.
--- bridge/fdb.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++- man/man8/bridge.8 | 29 ++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-)
bridge/fdb.c +57 -1
@@ -44,7 +44,8 @@ static void usage(void)" bridge fdb [ show [ br BRDEV ] [ brport DEV ] [ vlan VID ]\n" " [ state STATE ] [ dynamic ] ]\n" " bridge fdb get [ to ] LLADDR [ br BRDEV ] { brport | dev } DEV\n" - " [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n"); +" [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n" + " bridge fdb flush dev DEV [ self ] [ master ]\n");exit (-1 ); }
@@ -666,6 +667,59 @@ static int fdb_get(int argc, char **argv)return 0 ; } +static int fdb_flush (int argc,char **argv) +{ +struct { +struct nlmsghdr n; +struct ndmsg ndm; +char buf[256 ]; + } req = { + .n.nlmsg_len =NLMSG_LENGTH (sizeof (struct ndmsg )), + .n.nlmsg_flags =NLM_F_REQUEST |NLM_F_BULK , + .n.nlmsg_type =RTM_DELNEIGH , + .ndm.ndm_family =PF_BRIDGE , + }; +unsigned short ndm_flags =0 ; +char *d =NULL ; + +while (argc >0 ) { +if (strcmp (*argv,"dev" ) ==0 ) { +NEXT_ARG (); + d = *argv; + }else if (strcmp (*argv,"master" ) ==0 ) { + ndm_flags |=NTF_MASTER ; + }else if (strcmp (*argv,"self" ) ==0 ) { + ndm_flags |=NTF_SELF ; + }else { +if (strcmp (*argv,"help" ) ==0 ) +NEXT_ARG (); + } + argc--; argv++; + } + +if (d ==NULL ) { +fprintf (stderr,"Device is a required argument.\n" ); +return -1 ; + } + + req.ndm.ndm_ifindex =ll_name_to_index (d); +if (req.ndm.ndm_ifindex ==0 ) { +fprintf (stderr,"Cannot find bridge device \"%s\"\n" , d); +return -1 ; + } + +/* if self and master were not specified assume self */ +if (!(ndm_flags & (NTF_SELF |NTF_MASTER ))) + ndm_flags |=NTF_SELF ; + + req.ndm.ndm_flags = ndm_flags; + +if (rtnl_talk (&rth, &req.n,NULL ) <0 ) +return -1 ; + +return 0 ; +} +int do_fdb (int argc,char **argv) {ll_init_map (&rth);
@@ -685,6 +739,8 @@ int do_fdb(int argc, char **argv) matches(*argv, "lst") == 0 || matches(*argv, "list") == 0)return fdb_show (argc-1 , argv+1 ); +if (strcmp (*argv,"flush" ) ==0 ) +return fdb_flush (argc-1 , argv+1 );if (matches (*argv,"help" ) ==0 )usage (); }else
man/man8/bridge.8 +29 -0
@@ -112,6 +112,12 @@ bridge \- show / manipulate bridge addresses and devices .IR VNI " ] [" .BR self " ] [ " master " ] [ " dynamic " ]" +.ti -8 +.BR "bridge fdb flush" +.B dev +.IR DEV " [ " +.BR self " ] [ " master " ]" + .ti -8 .BR "bridge mdb" " { " add " | " del " } " .B dev
@@ -782,6 +788,29 @@ the bridge to which this address is associated. .TP .B master - the address is associated with master devices fdb. Usually software (default). + +.SS bridge fdb flush - flush bridge forwarding table entries. + +flush the matching bridge forwarding table entries. + +.TP +.BI dev " DEV" +the target device for the operation. If the device is a bridge port and "master" +is set then the operation will be fulfilled by its master device's driver and +all entries pointing to that port will be deleted. + +.TP +.B self +the operation is fulfilled directly by the driver for the specified network +device. If the network device belongs to a master like a bridge, then the +bridge is bypassed and not notified of this operation. The "bridge fdb flush" +command can also be used on the bridge device itself. The flag is set by default if +"master" is not specified. + +.TP +.B master +if the specified network device is a port that belongs to a master device +such as a bridge, the operation is fulfilled by the master device's driver. .sp .SH bridge mdb - multicast group database management
Signature · 1 line
2.35.1
PATCH 2/10 bridge: fdb: add flush vlan matching
In reply to Nikolay AleksandrovAdd flush support to match fdb entries in a specific vlan. Example:
$ bridge fdb flush dev swp1 vlan 10 master This will flush all fdb entries with port swp1 and vlan 10.
--- bridge/fdb.c | 15 ++++++++++++++- man/man8/bridge.8 | 7 +++++++ 2 files changed, 21 insertions(+), 1 deletion(-)
bridge/fdb.c +14 -1
@@ -45,7 +45,7 @@ static void usage(void)" [ state STATE ] [ dynamic ] ]\n" " bridge fdb get [ to ] LLADDR [ br BRDEV ] { brport | dev } DEV\n" " [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n" - " bridge fdb flush dev DEV [ self ] [ master ]\n"); + " bridge fdb flush dev DEV [ vlan VID ] [ self ] [ master ]\n");exit (-1 ); }
@@ -681,6 +681,7 @@ static int fdb_flush(int argc, char **argv) };unsigned short ndm_flags =0 ;char *d =NULL ; +short vid =-1 ;while (argc >0 ) {if (strcmp (*argv,"dev" ) ==0 ) {
@@ -690,6 +691,11 @@ static int fdb_flush(int argc, char **argv) ndm_flags |=NTF_MASTER ; }else if (strcmp (*argv,"self" ) ==0 ) { ndm_flags |=NTF_SELF ; + }else if (strcmp (*argv,"vlan" ) ==0 ) { +if (vid >=0 ) +duparg2 ("vlan" , *argv); +NEXT_ARG (); + vid =atoi (*argv); }else {if (strcmp (*argv,"help" ) ==0 )NEXT_ARG ();
@@ -708,11 +714,18 @@ static int fdb_flush(int argc, char **argv)return -1 ; } +if (vid >=4096 ) { +fprintf (stderr,"Invalid VLAN ID \"%hu\"\n" , vid); +return -1 ; + } +/* if self and master were not specified assume self */ if (!(ndm_flags & (NTF_SELF |NTF_MASTER ))) ndm_flags |=NTF_SELF ; req.ndm.ndm_flags = ndm_flags; +if (vid >-1 ) +addattr16 (&req.n,sizeof (req),NDA_VLAN , vid);if (rtnl_talk (&rth, &req.n,NULL ) <0 )return -1 ;
man/man8/bridge.8 +7 -0
@@ -116,6 +116,8 @@ bridge \- show / manipulate bridge addresses and devices .BR "bridge fdb flush" .B dev .IR DEV " [ " +.B vlan +.IR VID " ] [ " .BR self " ] [ " master " ]" .ti -8
@@ -799,6 +801,11 @@ the target device for the operation. If the device is a bridge port and "master" is set then the operation will be fulfilled by its master device's driver and all entries pointing to that port will be deleted. +.TP +.BI vlan " VID" +the target VLAN ID for the operation. Match forwarding table entries only with the +specified VLAN ID. + .TP .B self the operation is fulfilled directly by the driver for the specified network
Signature · 1 line
2.35.1
PATCH 3/10 bridge: fdb: add flush port matching
In reply to Nikolay AleksandrovUsually we match on the device specified after "dev" but there are special cases where we need an additional device attribute for matching such as when matching entries specifically pointing to the bridge device itself. We use NDA_IFINDEX for that purpose.
Example:
$ bridge fdb flush dev br0 brport br0 This will flush only entries pointing to the bridge itself.
$ bridge fdb flush dev swp1 brport swp2 master Note this will flush entries pointing to swp2 only. The NDA_IFINDEX attribute overrides the dev argument. This is documented in the man page.
--- bridge/fdb.c | 23 ++++++++++++++++++++--- man/man8/bridge.8 | 8 ++++++++ 2 files changed, 28 insertions(+), 3 deletions(-)
bridge/fdb.c +20 -3
@@ -45,7 +45,8 @@ static void usage(void)" [ state STATE ] [ dynamic ] ]\n" " bridge fdb get [ to ] LLADDR [ br BRDEV ] { brport | dev } DEV\n" " [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n" - " bridge fdb flush dev DEV [ vlan VID ] [ self ] [ master ]\n"); +" bridge fdb flush dev DEV [ brport DEV ] [ vlan VID ]\n" + " [ self ] [ master ]\n");exit (-1 ); }
@@ -679,9 +680,9 @@ static int fdb_flush(int argc, char **argv) .n.nlmsg_type = RTM_DELNEIGH, .ndm.ndm_family = PF_BRIDGE, }; +short vid =-1 , port_ifidx =-1 ;unsigned short ndm_flags =0 ; -char *d =NULL ; -short vid =-1 ; +char *d =NULL , *port =NULL ;while (argc >0 ) {if (strcmp (*argv,"dev" ) ==0 ) {
@@ -691,6 +692,11 @@ static int fdb_flush(int argc, char **argv) ndm_flags |=NTF_MASTER ; }else if (strcmp (*argv,"self" ) ==0 ) { ndm_flags |=NTF_SELF ; + }else if (strcmp (*argv,"brport" ) ==0 ) { +if (port) +duparg2 ("brport" , *argv); +NEXT_ARG (); + port = *argv; }else if (strcmp (*argv,"vlan" ) ==0 ) {if (vid >=0 )duparg2 ("vlan" , *argv);
@@ -714,6 +720,15 @@ static int fdb_flush(int argc, char **argv)return -1 ; } +if (port) { + port_ifidx =ll_name_to_index (port); +if (port_ifidx ==0 ) { +fprintf (stderr,"Cannot find bridge port device \"%s\"\n" , + port); +return -1 ; + } + } +if (vid >=4096 ) {fprintf (stderr,"Invalid VLAN ID \"%hu\"\n" , vid);return -1 ;
@@ -724,6 +739,8 @@ static int fdb_flush(int argc, char **argv) ndm_flags |=NTF_SELF ; req.ndm.ndm_flags = ndm_flags; +if (port_ifidx >-1 ) +addattr32 (&req.n,sizeof (req),NDA_IFINDEX , port_ifidx);if (vid >-1 )addattr16 (&req.n,sizeof (req),NDA_VLAN , vid);
man/man8/bridge.8 +8 -0
@@ -116,6 +116,8 @@ bridge \- show / manipulate bridge addresses and devices .BR "bridge fdb flush" .B dev .IR DEV " [ " +.B brport +.IR DEV " ] [ " .B vlan .IR VID " ] [ " .BR self " ] [ " master " ]"
@@ -801,6 +803,12 @@ the target device for the operation. If the device is a bridge port and "master" is set then the operation will be fulfilled by its master device's driver and all entries pointing to that port will be deleted. +.TP +.BI brport " DEV" +the target bridge port for the operation. If the bridge device is specified then only +entries pointing to the bridge itself will be deleted. Note that the target device +specified by this option will override the one specified by dev above. + .TP .BI vlan " VID" the target VLAN ID for the operation. Match forwarding table entries only with the
Signature · 1 line
2.35.1
PATCH 4/10 bridge: fdb: add flush [no]permanent entry matching
In reply to Nikolay AleksandrovAdd flush support to match permanent or non-permanent entries if "no" is prepended respectively.
Examples:
$ bridge fdb flush dev br0 permanent This will delete all permanent entries in br0's fdb table.
$ bridge fdb flush dev br0 nopermanent This will delete all entries except the permanent ones in br0's fdb table.
--- bridge/fdb.c | 14 +++++++++++++- man/man8/bridge.8 | 11 +++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-)
bridge/fdb.c +13 -1
@@ -46,7 +46,7 @@ static void usage(void)" bridge fdb get [ to ] LLADDR [ br BRDEV ] { brport | dev } DEV\n" " [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n" " bridge fdb flush dev DEV [ brport DEV ] [ vlan VID ]\n" - " [ self ] [ master ]\n"); + " [ self ] [ master ] [ [no]permanent ]\n");exit (-1 ); }
@@ -680,8 +680,10 @@ static int fdb_flush(int argc, char **argv) .n.nlmsg_type = RTM_DELNEIGH, .ndm.ndm_family = PF_BRIDGE, }; +unsigned short ndm_state_mask =0 ;short vid =-1 , port_ifidx =-1 ;unsigned short ndm_flags =0 ; +unsigned short ndm_state =0 ;char *d =NULL , *port =NULL ;while (argc >0 ) {
@@ -692,6 +694,12 @@ static int fdb_flush(int argc, char **argv) ndm_flags |=NTF_MASTER ; }else if (strcmp (*argv,"self" ) ==0 ) { ndm_flags |=NTF_SELF ; + }else if (strcmp (*argv,"permanent" ) ==0 ) { + ndm_state |=NUD_PERMANENT ; + ndm_state_mask |=NUD_PERMANENT ; + }else if (strcmp (*argv,"nopermanent" ) ==0 ) { + ndm_state &= ~NUD_PERMANENT ; + ndm_state_mask |=NUD_PERMANENT ; }else if (strcmp (*argv,"brport" ) ==0 ) {if (port)duparg2 ("brport" , *argv);
@@ -739,10 +747,14 @@ static int fdb_flush(int argc, char **argv) ndm_flags |=NTF_SELF ; req.ndm.ndm_flags = ndm_flags; + req.ndm.ndm_state = ndm_state;if (port_ifidx >-1 )addattr32 (&req.n,sizeof (req),NDA_IFINDEX , port_ifidx);if (vid >-1 )addattr16 (&req.n,sizeof (req),NDA_VLAN , vid); +if (ndm_state_mask) +addattr16 (&req.n,sizeof (req),NDA_NDM_STATE_MASK , + ndm_state_mask);if (rtnl_talk (&rth, &req.n,NULL ) <0 )return -1 ;
man/man8/bridge.8 +9 -2
@@ -120,7 +120,8 @@ bridge \- show / manipulate bridge addresses and devices .IR DEV " ] [ " .B vlan .IR VID " ] [ " -.BR self " ] [ " master " ]" +.BR self " ] [ " master " ] [ " +.BR [no]permanent " ]" .ti -8 .BR "bridge mdb" " { " add " | " del " } "
@@ -795,7 +796,8 @@ the bridge to which this address is associated. .SS bridge fdb flush - flush bridge forwarding table entries. -flush the matching bridge forwarding table entries. +flush the matching bridge forwarding table entries. Some options below have a negated +form when "no" is prepended to them (e.g. permanent and nopermanent). .TP .BI dev " DEV"
@@ -826,6 +828,11 @@ command can also be used on the bridge device itself. The flag is set by default .B master if the specified network device is a port that belongs to a master device such as a bridge, the operation is fulfilled by the master device's driver. + +.TP +.B [no]permanent +if specified then only permanent entries will be deleted or respectively if "no" +is prepended then only non-permanent entries will be deleted. .sp .SH bridge mdb - multicast group database management
Signature · 1 line
2.35.1
PATCH 5/10 bridge: fdb: add flush [no]static entry matching
In reply to Nikolay AleksandrovAdd flush support to match static or non-static entries if "no" is prepended respectively. Note that static entries are only NUD_NOARP ones without NUD_PERMANENT, also when matching non-static entries exclude permanent entries as well (permanent entries by definition are also static).
Examples:
$ bridge fdb flush dev br0 static This will delete all static entries in br0's fdb table.
$ bridge fdb flush dev br0 nostatic This will delete all entries except the static ones in br0's fdb table.
--- bridge/fdb.c | 8 +++++++- man/man8/bridge.8 | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-)
bridge/fdb.c +7 -1
@@ -46,7 +46,7 @@ static void usage(void)" bridge fdb get [ to ] LLADDR [ br BRDEV ] { brport | dev } DEV\n" " [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n" " bridge fdb flush dev DEV [ brport DEV ] [ vlan VID ]\n" - " [ self ] [ master ] [ [no]permanent ]\n"); + " [ self ] [ master ] [ [no]permanent | [no]static ]\n");exit (-1 ); }
@@ -700,6 +700,12 @@ static int fdb_flush(int argc, char **argv) }else if (strcmp (*argv,"nopermanent" ) ==0 ) { ndm_state &= ~NUD_PERMANENT ; ndm_state_mask |=NUD_PERMANENT ; + }else if (strcmp (*argv,"static" ) ==0 ) { + ndm_state |=NUD_NOARP ; + ndm_state_mask |=NUD_NOARP |NUD_PERMANENT ; + }else if (strcmp (*argv,"nostatic" ) ==0 ) { + ndm_state &= ~NUD_NOARP ; + ndm_state_mask |=NUD_NOARP ; }else if (strcmp (*argv,"brport" ) ==0 ) {if (port)duparg2 ("brport" , *argv);
man/man8/bridge.8 +6 -1
@@ -121,7 +121,7 @@ bridge \- show / manipulate bridge addresses and devices .B vlan .IR VID " ] [ " .BR self " ] [ " master " ] [ " -.BR [no]permanent " ]" +.BR [no]permanent " | " [no]static " ]" .ti -8 .BR "bridge mdb" " { " add " | " del " } "
@@ -833,6 +833,11 @@ such as a bridge, the operation is fulfilled by the master device's driver. .B [no]permanent if specified then only permanent entries will be deleted or respectively if "no" is prepended then only non-permanent entries will be deleted. + +.TP +.B [no]static +if specified then only static entries will be deleted or respectively if "no" +is prepended then only non-static entries will be deleted. .sp .SH bridge mdb - multicast group database management
Signature · 1 line
2.35.1
PATCH 6/10 bridge: fdb: add flush [no]dynamic entry matching
In reply to Nikolay AleksandrovAdd flush support to match dynamic or non-dynamic (static or permanent) entries if "no" is prepended respectively. Note that dynamic entries are defined as fdbs without NUD_NOARP and NUD_PERMANENT set, and non-dynamic entries are fdbs with NUD_NOARP set (that matches both static and permanent entries).
Examples:
$ bridge fdb flush dev br0 dynamic This will delete all dynamic entries in br0's fdb table.
$ bridge fdb flush dev br0 nodynamic This will delete all entries except the dynamic ones in br0's fdb table.
--- bridge/fdb.c | 8 +++++++- man/man8/bridge.8 | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-)
bridge/fdb.c +7 -1
@@ -46,7 +46,7 @@ static void usage(void)" bridge fdb get [ to ] LLADDR [ br BRDEV ] { brport | dev } DEV\n" " [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n" " bridge fdb flush dev DEV [ brport DEV ] [ vlan VID ]\n" - " [ self ] [ master ] [ [no]permanent | [no]static ]\n"); + " [ self ] [ master ] [ [no]permanent | [no]static | [no]dynamic ]\n");exit (-1 ); }
@@ -706,6 +706,12 @@ static int fdb_flush(int argc, char **argv) }else if (strcmp (*argv,"nostatic" ) ==0 ) { ndm_state &= ~NUD_NOARP ; ndm_state_mask |=NUD_NOARP ; + }else if (strcmp (*argv,"dynamic" ) ==0 ) { + ndm_state &= ~NUD_NOARP |NUD_PERMANENT ; + ndm_state_mask |=NUD_NOARP |NUD_PERMANENT ; + }else if (strcmp (*argv,"nodynamic" ) ==0 ) { + ndm_state |=NUD_NOARP ; + ndm_state_mask |=NUD_NOARP ; }else if (strcmp (*argv,"brport" ) ==0 ) {if (port)duparg2 ("brport" , *argv);
man/man8/bridge.8 +6 -1
@@ -121,7 +121,7 @@ bridge \- show / manipulate bridge addresses and devices .B vlan .IR VID " ] [ " .BR self " ] [ " master " ] [ " -.BR [no]permanent " | " [no]static " ]" +.BR [no]permanent " | " [no]static " | " [no]dynamic " ]" .ti -8 .BR "bridge mdb" " { " add " | " del " } "
@@ -838,6 +838,11 @@ is prepended then only non-permanent entries will be deleted. .B [no]static if specified then only static entries will be deleted or respectively if "no" is prepended then only non-static entries will be deleted. + +.TP +.B [no]dynamic +if specified then only dynamic entries will be deleted or respectively if "no" +is prepended then only non-dynamic (static or permanent) entries will be deleted. .sp .SH bridge mdb - multicast group database management
Signature · 1 line
2.35.1
PATCH 7/10 bridge: fdb: add flush [no]added_by_user entry matching
In reply to Nikolay AleksandrovAdd flush support to match entries with or without (if "no" is prepended) added_by_user flag. Note that NTF_USE is used internally because there is no NTF_ flag that describes such entries.
Examples:
$ bridge fdb flush dev br0 added_by_user This will delete all added_by_user entries in br0's fdb table.
$ bridge fdb flush dev br0 noadded_by_user This will delete all entries except the ones with added_by_user flag in br0's fdb table.
--- bridge/fdb.c | 13 ++++++++++++- man/man8/bridge.8 | 8 +++++++- 2 files changed, 19 insertions(+), 2 deletions(-)
bridge/fdb.c +12 -1
@@ -46,7 +46,8 @@ static void usage(void)" bridge fdb get [ to ] LLADDR [ br BRDEV ] { brport | dev } DEV\n" " [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n" " bridge fdb flush dev DEV [ brport DEV ] [ vlan VID ]\n" - " [ self ] [ master ] [ [no]permanent | [no]static | [no]dynamic ]\n"); +" [ self ] [ master ] [ [no]permanent | [no]static | [no]dynamic ]\n" + " [ [no]added_by_user ]\n");exit (-1 ); }
@@ -681,6 +682,7 @@ static int fdb_flush(int argc, char **argv) .ndm.ndm_family = PF_BRIDGE, };unsigned short ndm_state_mask =0 ; +unsigned short ndm_flags_mask =0 ;short vid =-1 , port_ifidx =-1 ;unsigned short ndm_flags =0 ;unsigned short ndm_state =0 ;
@@ -712,6 +714,12 @@ static int fdb_flush(int argc, char **argv) }else if (strcmp (*argv,"nodynamic" ) ==0 ) { ndm_state |=NUD_NOARP ; ndm_state_mask |=NUD_NOARP ; + }else if (strcmp (*argv,"added_by_user" ) ==0 ) { + ndm_flags |=NTF_USE ; + ndm_flags_mask |=NTF_USE ; + }else if (strcmp (*argv,"noadded_by_user" ) ==0 ) { + ndm_flags &= ~NTF_USE ; + ndm_flags_mask |=NTF_USE ; }else if (strcmp (*argv,"brport" ) ==0 ) {if (port)duparg2 ("brport" , *argv);
@@ -764,6 +772,9 @@ static int fdb_flush(int argc, char **argv)addattr32 (&req.n,sizeof (req),NDA_IFINDEX , port_ifidx);if (vid >-1 )addattr16 (&req.n,sizeof (req),NDA_VLAN , vid); +if (ndm_flags_mask) +addattr8 (&req.n,sizeof (req),NDA_NDM_FLAGS_MASK , + ndm_flags_mask);if (ndm_state_mask)addattr16 (&req.n,sizeof (req),NDA_NDM_STATE_MASK , ndm_state_mask);
man/man8/bridge.8 +7 -1
@@ -121,7 +121,8 @@ bridge \- show / manipulate bridge addresses and devices .B vlan .IR VID " ] [ " .BR self " ] [ " master " ] [ " -.BR [no]permanent " | " [no]static " | " [no]dynamic " ]" +.BR [no]permanent " | " [no]static " | " [no]dynamic " ] [ " +.BR [no]added_by_user " ]" .ti -8 .BR "bridge mdb" " { " add " | " del " } "
@@ -843,6 +844,11 @@ is prepended then only non-static entries will be deleted. .B [no]dynamic if specified then only dynamic entries will be deleted or respectively if "no" is prepended then only non-dynamic (static or permanent) entries will be deleted. + +.TP +.B [no]added_by_user +if specified then only entries with added_by_user flag will be deleted or respectively +if "no" is prepended then only entries without added_by_user flag will be deleted. .sp .SH bridge mdb - multicast group database management
Signature · 1 line
2.35.1
PATCH 8/10 bridge: fdb: add flush [no]extern_learn entry matching
In reply to Nikolay AleksandrovAdd flush support to match entries with or without (if "no" is prepended) extern_learn flag.
Examples:
$ bridge fdb flush dev br0 extern_learn This will delete all extern_learn entries in br0's fdb table.
$ bridge fdb flush dev br0 noextern_learn This will delete all entries except the ones with extern_learn flag in br0's fdb table.
--- bridge/fdb.c | 8 +++++++- man/man8/bridge.8 | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-)
bridge/fdb.c +7 -1
@@ -47,7 +47,7 @@ static void usage(void)" [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n" " bridge fdb flush dev DEV [ brport DEV ] [ vlan VID ]\n" " [ self ] [ master ] [ [no]permanent | [no]static | [no]dynamic ]\n" - " [ [no]added_by_user ]\n"); + " [ [no]added_by_user ] [ [no]extern_learn ]\n");exit (-1 ); }
@@ -720,6 +720,12 @@ static int fdb_flush(int argc, char **argv) }else if (strcmp (*argv,"noadded_by_user" ) ==0 ) { ndm_flags &= ~NTF_USE ; ndm_flags_mask |=NTF_USE ; + }else if (strcmp (*argv,"extern_learn" ) ==0 ) { + ndm_flags |=NTF_EXT_LEARNED ; + ndm_flags_mask |=NTF_EXT_LEARNED ; + }else if (strcmp (*argv,"noextern_learn" ) ==0 ) { + ndm_flags &= ~NTF_EXT_LEARNED ; + ndm_flags_mask |=NTF_EXT_LEARNED ; }else if (strcmp (*argv,"brport" ) ==0 ) {if (port)duparg2 ("brport" , *argv);
man/man8/bridge.8 +6 -1
@@ -122,7 +122,7 @@ bridge \- show / manipulate bridge addresses and devices .IR VID " ] [ " .BR self " ] [ " master " ] [ " .BR [no]permanent " | " [no]static " | " [no]dynamic " ] [ " -.BR [no]added_by_user " ]" +.BR [no]added_by_user " ] [ " [no]extern_learn " ]" .ti -8 .BR "bridge mdb" " { " add " | " del " } "
@@ -849,6 +849,11 @@ is prepended then only non-dynamic (static or permanent) entries will be deleted .B [no]added_by_user if specified then only entries with added_by_user flag will be deleted or respectively if "no" is prepended then only entries without added_by_user flag will be deleted. + +.TP +.B [no]extern_learn +if specified then only entries with extern_learn flag will be deleted or respectively +if "no" is prepended then only entries without extern_learn flag will be deleted. .sp .SH bridge mdb - multicast group database management
Signature · 1 line
2.35.1
PATCH 9/10 bridge: fdb: add flush [no]sticky entry matching
In reply to Nikolay AleksandrovAdd flush support to match entries with or without (if "no" is prepended) sticky flag.
Examples:
$ bridge fdb flush dev br0 sticky This will delete all sticky entries in br0's fdb table.
$ bridge fdb flush dev br0 nosticky This will delete all entries except the ones with sticky flag in br0's fdb table.
--- bridge/fdb.c | 8 +++++++- man/man8/bridge.8 | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-)
bridge/fdb.c +7 -1
@@ -47,7 +47,7 @@ static void usage(void)" [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n" " bridge fdb flush dev DEV [ brport DEV ] [ vlan VID ]\n" " [ self ] [ master ] [ [no]permanent | [no]static | [no]dynamic ]\n" - " [ [no]added_by_user ] [ [no]extern_learn ]\n"); + " [ [no]added_by_user ] [ [no]extern_learn ] [ [no]sticky ]\n");exit (-1 ); }
@@ -726,6 +726,12 @@ static int fdb_flush(int argc, char **argv) }else if (strcmp (*argv,"noextern_learn" ) ==0 ) { ndm_flags &= ~NTF_EXT_LEARNED ; ndm_flags_mask |=NTF_EXT_LEARNED ; + }else if (strcmp (*argv,"sticky" ) ==0 ) { + ndm_flags |=NTF_STICKY ; + ndm_flags_mask |=NTF_STICKY ; + }else if (strcmp (*argv,"nosticky" ) ==0 ) { + ndm_flags &= ~NTF_STICKY ; + ndm_flags_mask |=NTF_STICKY ; }else if (strcmp (*argv,"brport" ) ==0 ) {if (port)duparg2 ("brport" , *argv);
man/man8/bridge.8 +7 -1
@@ -122,7 +122,8 @@ bridge \- show / manipulate bridge addresses and devices .IR VID " ] [ " .BR self " ] [ " master " ] [ " .BR [no]permanent " | " [no]static " | " [no]dynamic " ] [ " -.BR [no]added_by_user " ] [ " [no]extern_learn " ]" +.BR [no]added_by_user " ] [ " [no]extern_learn " ] [ " +.BR [no]sticky " ]" .ti -8 .BR "bridge mdb" " { " add " | " del " } "
@@ -854,6 +855,11 @@ if "no" is prepended then only entries without added_by_user flag will be delete .B [no]extern_learn if specified then only entries with extern_learn flag will be deleted or respectively if "no" is prepended then only entries without extern_learn flag will be deleted. + +.TP +.B [no]sticky +if specified then only entries with sticky flag will be deleted or respectively +if "no" is prepended then only entries without sticky flag will be deleted. .sp .SH bridge mdb - multicast group database management
Signature · 1 line
2.35.1
PATCH 10/10 bridge: fdb: add flush [no]offloaded entry matching
In reply to Nikolay AleksandrovAdd flush support to match entries with or without (if "no" is prepended) offloaded flag.
Examples:
$ bridge fdb flush dev br0 offloaded This will delete all offloaded entries in br0's fdb table.
$ bridge fdb flush dev br0 nooffloaded This will delete all entries except the ones with offloaded flag in br0's fdb table.
--- bridge/fdb.c | 9 ++++++++- man/man8/bridge.8 | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-)
bridge/fdb.c +8 -1
@@ -47,7 +47,8 @@ static void usage(void)" [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n" " bridge fdb flush dev DEV [ brport DEV ] [ vlan VID ]\n" " [ self ] [ master ] [ [no]permanent | [no]static | [no]dynamic ]\n" - " [ [no]added_by_user ] [ [no]extern_learn ] [ [no]sticky ]\n"); +" [ [no]added_by_user ] [ [no]extern_learn ] [ [no]sticky ]\n" + " [ [no]offloaded ]\n");exit (-1 ); }
@@ -732,6 +733,12 @@ static int fdb_flush(int argc, char **argv) }else if (strcmp (*argv,"nosticky" ) ==0 ) { ndm_flags &= ~NTF_STICKY ; ndm_flags_mask |=NTF_STICKY ; + }else if (strcmp (*argv,"offloaded" ) ==0 ) { + ndm_flags |=NTF_OFFLOADED ; + ndm_flags_mask |=NTF_OFFLOADED ; + }else if (strcmp (*argv,"nooffloaded" ) ==0 ) { + ndm_flags &= ~NTF_OFFLOADED ; + ndm_flags_mask |=NTF_OFFLOADED ; }else if (strcmp (*argv,"brport" ) ==0 ) {if (port)duparg2 ("brport" , *argv);
man/man8/bridge.8 +6 -1
@@ -123,7 +123,7 @@ bridge \- show / manipulate bridge addresses and devices .BR self " ] [ " master " ] [ " .BR [no]permanent " | " [no]static " | " [no]dynamic " ] [ " .BR [no]added_by_user " ] [ " [no]extern_learn " ] [ " -.BR [no]sticky " ]" +.BR [no]sticky " ] [ " [no]offloaded " ]" .ti -8 .BR "bridge mdb" " { " add " | " del " } "
@@ -860,6 +860,11 @@ if "no" is prepended then only entries without extern_learn flag will be deleted .B [no]sticky if specified then only entries with sticky flag will be deleted or respectively if "no" is prepended then only entries without sticky flag will be deleted. + +.TP +.B [no]offloaded +if specified then only entries with offloaded flag will be deleted or respectively +if "no" is prepended then only entries without offloaded flag will be deleted. .sp .SH bridge mdb - multicast group database management
Signature · 1 line
2.35.1
This series was applied to iproute2/iproute2-next.git (main) by David Ahern <[email protected]>:
Hello:
This series was applied to iproute2/iproute2-next.git (main) by David Ahern <[email protected]>:
Quoted 10 lines · On Wed, 8 Jun 2022 15:29:11 +0300 you wrote:
Hi,
This set adds support for the new bulk delete flag to allow fdb flushing for specific entries which are matched based on the supplied options. The new bridge fdb subcommand is "flush", and as can be seen from the commits it allows to delete entries based on many different criteria:
- matching vlan
- matching port
- matching all sorts of flags (combinations are allowed)[...]
Here is the summary with links:
- [iproute2-next,01/10] bridge: fdb: add new flush command
https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=6e1ca489c5a2 - [iproute2-next,02/10] bridge: fdb: add flush vlan matching https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=d9c15896f1d3 - [iproute2-next,03/10] bridge: fdb: add flush port matching https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=bb9e453c1406 - [iproute2-next,04/10] bridge: fdb: add flush [no]permanent entry matching https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=988c31980750 - [iproute2-next,05/10] bridge: fdb: add flush [no]static entry matching https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=0f6c81a63c50 - [iproute2-next,06/10] bridge: fdb: add flush [no]dynamic entry matching https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=8198f75073ed - [iproute2-next,07/10] bridge: fdb: add flush [no]added_by_user entry matching https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=ef5425739fb8 - [iproute2-next,08/10] bridge: fdb: add flush [no]extern_learn entry matching https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=b78036468886 - [iproute2-next,09/10] bridge: fdb: add flush [no]sticky entry matching https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=259795676e90 - [iproute2-next,10/10] bridge: fdb: add flush [no]offloaded entry matching https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=4a4e32a92b56
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html