[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220501001205.33782-3-roopa@nvidia.com>
Date: Sun, 1 May 2022 00:12:04 +0000
From: Roopa Prabhu <roopa@...dia.com>
To: <dsahern@...il.com>
CC: <netdev@...r.kernel.org>, <stephen@...workplumber.org>,
<razor@...ckwall.org>
Subject: [PATCH iproute2 net-next 2/3] ip: iplink_vxlan: add support to set vnifiltering flag on vxlan device
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@...dia.com>
---
ip/iplink_vxlan.c | 23 ++++++++++++++++++++++-
man/man8/ip-link.8.in | 9 +++++++++
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/ip/iplink_vxlan.c b/ip/iplink_vxlan.c
index 9afa3cca..3dde2150 100644
--- a/ip/iplink_vxlan.c
+++ b/ip/iplink_vxlan.c
@@ -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 (!matches(*argv, "vnifilter")) {
+ check_duparg(&attrs, IFLA_VXLAN_VNIFILTER,
+ *argv, *argv);
+ addattr8(n, 1024, IFLA_VXLAN_VNIFILTER, 1);
+ vnifilter = 1;
+ } else if (!matches(*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]));
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
index fc214a10..6f332645 100644
--- a/man/man8/ip-link.8.in
+++ b/man/man8/ip-link.8.in
@@ -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).
--
2.25.1
Powered by blists - more mailing lists