aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikolay Aleksandrov <razor@blackwall.org>2022-06-08 15:29:15 +0300
committerDavid Ahern <dsahern@kernel.org>2022-06-10 09:01:33 -0600
commit988c319807508ba6de79f22e859edc50aaaad171 (patch)
tree8ee1ecd66484ec0463198abedb1cf2b1f0328882
parentbb9e453c14068c308f000cdcff98a4dd468358d5 (diff)
downloadiproute2-988c319807508ba6de79f22e859edc50aaaad171.tar.gz
bridge: fdb: add flush [no]permanent entry matching
Add 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. Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org> Signed-off-by: David Ahern <dsahern@kernel.org>
-rw-r--r--bridge/fdb.c14
-rw-r--r--man/man8/bridge.811
2 files changed, 22 insertions, 3 deletions
diff --git a/bridge/fdb.c b/bridge/fdb.c
index 4af13eb20..b1c516141 100644
--- a/bridge/fdb.c
+++ b/bridge/fdb.c
@@ -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;
diff --git a/man/man8/bridge.8 b/man/man8/bridge.8
index 32b81b4bd..9dcd1f0a6 100644
--- a/man/man8/bridge.8
+++ b/man/man8/bridge.8
@@ -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