]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ip: iplink_vxlan: add support to set vnifiltering flag on vxlan device
authorRoopa Prabhu <roopa@nvidia.com>
Sun, 8 May 2022 04:53:39 +0000 (04:53 +0000)
committerDavid Ahern <dsahern@kernel.org>
Sun, 8 May 2022 15:50:33 +0000 (09:50 -0600)
This patch adds option to set vnifilter flag on a vxlan device. vnifilter is
only supported on a collect metadata device.

example: set vnifilter flag
$ ip link add vxlan0 type vxlan external vnifilter local 172.16.0.1

Signed-off-by: Roopa Prabhu <roopa@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
ip/iplink_vxlan.c
man/man8/ip-link.8.in

index 9afa3ccad11527a4a04408f596c6b59ab7f046ae..01522d6ebd02b37d9d7d7f075325e74c950722a3 100644 (file)
@@ -48,6 +48,7 @@ static void print_explain(FILE *f)
                "               [ [no]udp6zerocsumrx ]\n"
                "               [ [no]remcsumtx ] [ [no]remcsumrx ]\n"
                "               [ [no]external ] [ gbp ] [ gpe ]\n"
+               "               [ [no]vnifilter ]\n"
                "\n"
                "Where: VNI     := 0-16777215\n"
                "       ADDR    := { IP_ADDRESS | any }\n"
@@ -81,6 +82,7 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
        __u8 learning = 1;
        __u16 dstport = 0;
        __u8 metadata = 0;
+       __u8 vnifilter = 0;
        __u64 attrs = 0;
        bool set_op = (n->nlmsg_type == RTM_NEWLINK &&
                       !(n->nlmsg_flags & NLM_F_CREATE));
@@ -330,6 +332,15 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
                } else if (!matches(*argv, "gpe")) {
                        check_duparg(&attrs, IFLA_VXLAN_GPE, *argv, *argv);
                        addattr_l(n, 1024, IFLA_VXLAN_GPE, NULL, 0);
+               } else if (!strcmp(*argv, "vnifilter")) {
+                       check_duparg(&attrs, IFLA_VXLAN_VNIFILTER,
+                                    *argv, *argv);
+                       addattr8(n, 1024, IFLA_VXLAN_VNIFILTER, 1);
+                       vnifilter = 1;
+               } else if (!strcmp(*argv, "novnifilter")) {
+                       check_duparg(&attrs, IFLA_VXLAN_VNIFILTER,
+                                    *argv, *argv);
+                       addattr8(n, 1024, IFLA_VXLAN_VNIFILTER, 0);
                } else if (matches(*argv, "help") == 0) {
                        explain();
                        return -1;
@@ -341,12 +352,17 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
                argc--, argv++;
        }
 
+       if (!metadata && vnifilter) {
+               fprintf(stderr, "vxlan: vnifilter is valid only when 'external' is set\n");
+               return -1;
+       }
+
        if (metadata && VXLAN_ATTRSET(attrs, IFLA_VXLAN_ID)) {
                fprintf(stderr, "vxlan: both 'external' and vni cannot be specified\n");
                return -1;
        }
 
-       if (!metadata && !VXLAN_ATTRSET(attrs, IFLA_VXLAN_ID) && !set_op) {
+       if (!metadata && !vnifilter && !VXLAN_ATTRSET(attrs, IFLA_VXLAN_ID) && !set_op) {
                fprintf(stderr, "vxlan: missing virtual network identifier\n");
                return -1;
        }
@@ -420,6 +436,11 @@ static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
                print_bool(PRINT_ANY, "external", "external ", true);
        }
 
+       if (tb[IFLA_VXLAN_VNIFILTER] &&
+           rta_getattr_u8(tb[IFLA_VXLAN_VNIFILTER])) {
+               print_bool(PRINT_ANY, "vnifilter", "vnifilter", true);
+       }
+
        if (tb[IFLA_VXLAN_ID] &&
            RTA_PAYLOAD(tb[IFLA_VXLAN_ID]) >= sizeof(__u32)) {
                print_uint(PRINT_ANY, "id", "id %u ", rta_getattr_u32(tb[IFLA_VXLAN_ID]));
index fc214a10c4e733681b78e8419e5e666b54d82131..6f332645058486f05c2366d093bfc4afaf695cd5 100644 (file)
@@ -601,6 +601,8 @@ the following additional arguments are supported:
 .B gbp
 ] [
 .B gpe
+] [
+.RB [ no ] vnifilter
 ]
 
 .in +8
@@ -712,6 +714,13 @@ are entered into the VXLAN device forwarding database.
 .RB "(e.g. " "ip route encap" )
 or the internal FDB should be used.
 
+.sp
+.RB [ no ] vnifilter
+- specifies whether the vxlan device is capable of vni filtering. Only works with a vxlan
+device with external flag set. once enabled, bridge vni command is used to manage the
+vni filtering table on the device. The device can only receive packets with vni's configured
+in the vni filtering table.
+
 .sp
 .B gbp
 - enables the Group Policy extension (VXLAN-GBP).