mirror of
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git
synced 2024-11-15 05:55:11 +08:00
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>
This commit is contained in:
parent
bb9e453c14
commit
988c319807
14
bridge/fdb.c
14
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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user