]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
bridge: fdb: support match on destination IP in flush command
authorAmit Cohen <amcohen@nvidia.com>
Tue, 17 Oct 2023 10:55:30 +0000 (13:55 +0300)
committerDavid Ahern <dsahern@kernel.org>
Fri, 20 Oct 2023 15:43:02 +0000 (09:43 -0600)
Extend "fdb flush" command to match fdb entries with a specific destination
IP.

Example:
$ bridge fdb flush dev vx10 dst 192.1.1.1
This will flush all fdb entries pointing to vx10 with destination IP
192.1.1.1

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Signed-off-by: David Ahern <dsahern@kernel.org>
bridge/fdb.c
man/man8/bridge.8

index f2d882ed6225460438ca51dc9656db8bbb961666..8311fa08c6668d5496466b447dd26d085ba41298 100644 (file)
@@ -46,8 +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 ] [ src_vni VNI ]\n"
-               "              [ nhid NHID ] [ vni VNI ] [ port PORT ] [ self ] [ master ]\n"
-               "              [ [no]permanent | [no]static | [no]dynamic ]\n"
+               "              [ nhid NHID ] [ vni VNI ] [ port PORT ] [ dst IPADDR ] [ self ]\n"
+               "              [ master ] [ [no]permanent | [no]static | [no]dynamic ]\n"
                "              [ [no]added_by_user ] [ [no]extern_learn ] [ [no]sticky ]\n"
                "              [ [no]offloaded ]\n");
        exit(-1);
@@ -704,6 +704,8 @@ static int fdb_flush(int argc, char **argv)
        unsigned long src_vni = ~0;
        unsigned long vni = ~0;
        unsigned long port = 0;
+       inet_prefix dst;
+       int dst_ok = 0;
        __u32 nhid = 0;
        char *endptr;
 
@@ -795,6 +797,12 @@ static int fdb_flush(int argc, char **argv)
                                port = ntohs(pse->s_port);
                        } else if (port > 0xffff)
                                invarg("invalid port\n", *argv);
+               } else if (strcmp(*argv, "dst") == 0) {
+                       NEXT_ARG();
+                       if (dst_ok)
+                               duparg2("dst", *argv);
+                       get_addr(&dst, *argv, preferred_family);
+                       dst_ok = 1;
                } else if (strcmp(*argv, "help") == 0) {
                        NEXT_ARG();
                } else {
@@ -853,6 +861,8 @@ static int fdb_flush(int argc, char **argv)
                dport = htons((unsigned short)port);
                addattr16(&req.n, sizeof(req), NDA_PORT, dport);
        }
+       if (dst_ok)
+               addattr_l(&req.n, sizeof(req), NDA_DST, &dst.data, dst.bytelen);
        if (ndm_flags_mask)
                addattr8(&req.n, sizeof(req), NDA_NDM_FLAGS_MASK,
                         ndm_flags_mask);
index cf23094c8bbbae21118b381468768ad34ff11c4a..e3051f890b1f5082fb25c3bcd643598ad9c804d6 100644 (file)
@@ -136,6 +136,8 @@ bridge \- show / manipulate bridge addresses and devices
 .IR VNI " ] [ "
 .B port
 .IR PORT " ] ["
+.B dst
+.IR IPADDR " ] [ "
 .BR self " ] [ " master " ] [ "
 .BR [no]permanent " | " [no]static " | " [no]dynamic " ] [ "
 .BR [no]added_by_user " ] [ " [no]extern_learn " ] [ "
@@ -923,6 +925,12 @@ the UDP destination PORT number for the operation. Match forwarding table
 entries only with the specified PORT. Valid if the referenced device is a VXLAN
 type device.
 
+.TP
+.BI dst " IPADDR"
+the IP address of the destination VXLAN tunnel endpoint for the operation. Match
+forwarding table entries only with the specified IPADDR. Valid if the referenced
+device is a VXLAN type device.
+
 .TP
 .B self
 the operation is fulfilled directly by the driver for the specified network