|
|
99be8f |
From b9961cdb54c22fa1b3f1eac5446a008fde7532e6 Mon Sep 17 00:00:00 2001
|
|
|
99be8f |
From: Andrea Claudi <aclaudi@redhat.com>
|
|
|
99be8f |
Date: Wed, 5 Jun 2019 13:13:31 +0200
|
|
|
99be8f |
Subject: [PATCH] gre6: add collect metadata support
|
|
|
99be8f |
|
|
|
99be8f |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1714660
|
|
|
99be8f |
Upstream Status: iproute2.git commit 6231c5bec6d25
|
|
|
99be8f |
Conflicts:
|
|
|
99be8f |
* Context change due to missing commit
|
|
|
99be8f |
ad4b1425c3182 ("iplink: Expose IFLA_*_FWMARK attributes for supported link types")
|
|
|
99be8f |
* Adjusted gre_print_opt() to missing commit 6856fb65484ba
|
|
|
99be8f |
("ip: link_gre6.c: add json output support")
|
|
|
99be8f |
|
|
|
99be8f |
commit 6231c5bec6d256f7861f39d3a578f5259f274cc4
|
|
|
99be8f |
Author: William Tu <u9012063@gmail.com>
|
|
|
99be8f |
Date: Tue Dec 12 18:22:52 2017 -0800
|
|
|
99be8f |
|
|
|
99be8f |
gre6: add collect metadata support
|
|
|
99be8f |
|
|
|
99be8f |
The patch adds 'external' option to support collect metadata
|
|
|
99be8f |
gre6 tunnel. The 'external' keyword is already used to set the
|
|
|
99be8f |
device into collect metadata mode such as vxlan, geneve, ipip,
|
|
|
99be8f |
etc. This patch extends support for ipv6 gre and gretap.
|
|
|
99be8f |
Example of L3 and L2 gre device:
|
|
|
99be8f |
bash:~# ip link add dev ip6gre123 type ip6gre external
|
|
|
99be8f |
bash:~# ip link add dev ip6gretap123 type ip6gretap external
|
|
|
99be8f |
|
|
|
99be8f |
Signed-off-by: William Tu <u9012063@gmail.com>
|
|
|
99be8f |
Cc: Daniel Borkmann <daniel@iogearbox.net>
|
|
|
99be8f |
---
|
|
|
99be8f |
ip/link_gre6.c | 49 ++++++++++++++++++++++++++++---------------
|
|
|
99be8f |
man/man8/ip-link.8.in | 17 +++++++++++++++
|
|
|
99be8f |
2 files changed, 49 insertions(+), 17 deletions(-)
|
|
|
99be8f |
|
|
|
99be8f |
diff --git a/ip/link_gre6.c b/ip/link_gre6.c
|
|
|
99be8f |
index 127e51de4ab73..ea42fb1a9f664 100644
|
|
|
99be8f |
--- a/ip/link_gre6.c
|
|
|
99be8f |
+++ b/ip/link_gre6.c
|
|
|
99be8f |
@@ -102,6 +102,7 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
|
|
|
99be8f |
__u16 encapflags = TUNNEL_ENCAP_FLAG_CSUM6;
|
|
|
99be8f |
__u16 encapsport = 0;
|
|
|
99be8f |
__u16 encapdport = 0;
|
|
|
99be8f |
+ __u8 metadata = 0;
|
|
|
99be8f |
int len;
|
|
|
99be8f |
|
|
|
99be8f |
if (!(n->nlmsg_flags & NLM_F_CREATE)) {
|
|
|
99be8f |
@@ -173,6 +174,9 @@ get_failed:
|
|
|
99be8f |
if (greinfo[IFLA_GRE_ENCAP_SPORT])
|
|
|
99be8f |
encapsport = rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_SPORT]);
|
|
|
99be8f |
|
|
|
99be8f |
+ if (greinfo[IFLA_GRE_COLLECT_METADATA])
|
|
|
99be8f |
+ metadata = 1;
|
|
|
99be8f |
+
|
|
|
99be8f |
if (greinfo[IFLA_GRE_ENCAP_DPORT])
|
|
|
99be8f |
encapdport = rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_DPORT]);
|
|
|
99be8f |
|
|
|
99be8f |
@@ -333,6 +337,8 @@ get_failed:
|
|
|
99be8f |
encapflags |= TUNNEL_ENCAP_FLAG_REMCSUM;
|
|
|
99be8f |
} else if (strcmp(*argv, "noencap-remcsum") == 0) {
|
|
|
99be8f |
encapflags &= ~TUNNEL_ENCAP_FLAG_REMCSUM;
|
|
|
99be8f |
+ } else if (strcmp(*argv, "external") == 0) {
|
|
|
99be8f |
+ metadata = 1;
|
|
|
99be8f |
} else if (strcmp(*argv, "encaplimit") == 0) {
|
|
|
99be8f |
NEXT_ARG();
|
|
|
99be8f |
if (strcmp(*argv, "none") == 0) {
|
|
|
99be8f |
@@ -350,23 +356,27 @@ get_failed:
|
|
|
99be8f |
argc--; argv++;
|
|
|
99be8f |
}
|
|
|
99be8f |
|
|
|
99be8f |
- addattr32(n, 1024, IFLA_GRE_IKEY, ikey);
|
|
|
99be8f |
- addattr32(n, 1024, IFLA_GRE_OKEY, okey);
|
|
|
99be8f |
- addattr_l(n, 1024, IFLA_GRE_IFLAGS, &iflags, 2);
|
|
|
99be8f |
- addattr_l(n, 1024, IFLA_GRE_OFLAGS, &oflags, 2);
|
|
|
99be8f |
- addattr_l(n, 1024, IFLA_GRE_LOCAL, &laddr, sizeof(laddr));
|
|
|
99be8f |
- addattr_l(n, 1024, IFLA_GRE_REMOTE, &raddr, sizeof(raddr));
|
|
|
99be8f |
- if (link)
|
|
|
99be8f |
- addattr32(n, 1024, IFLA_GRE_LINK, link);
|
|
|
99be8f |
- addattr_l(n, 1024, IFLA_GRE_TTL, &hop_limit, 1);
|
|
|
99be8f |
- addattr_l(n, 1024, IFLA_GRE_ENCAP_LIMIT, &encap_limit, 1);
|
|
|
99be8f |
- addattr_l(n, 1024, IFLA_GRE_FLOWINFO, &flowinfo, 4);
|
|
|
99be8f |
- addattr32(n, 1024, IFLA_GRE_FLAGS, flags);
|
|
|
99be8f |
-
|
|
|
99be8f |
- addattr16(n, 1024, IFLA_GRE_ENCAP_TYPE, encaptype);
|
|
|
99be8f |
- addattr16(n, 1024, IFLA_GRE_ENCAP_FLAGS, encapflags);
|
|
|
99be8f |
- addattr16(n, 1024, IFLA_GRE_ENCAP_SPORT, htons(encapsport));
|
|
|
99be8f |
- addattr16(n, 1024, IFLA_GRE_ENCAP_DPORT, htons(encapdport));
|
|
|
99be8f |
+ if (!metadata) {
|
|
|
99be8f |
+ addattr32(n, 1024, IFLA_GRE_IKEY, ikey);
|
|
|
99be8f |
+ addattr32(n, 1024, IFLA_GRE_OKEY, okey);
|
|
|
99be8f |
+ addattr_l(n, 1024, IFLA_GRE_IFLAGS, &iflags, 2);
|
|
|
99be8f |
+ addattr_l(n, 1024, IFLA_GRE_OFLAGS, &oflags, 2);
|
|
|
99be8f |
+ addattr_l(n, 1024, IFLA_GRE_LOCAL, &laddr, sizeof(laddr));
|
|
|
99be8f |
+ addattr_l(n, 1024, IFLA_GRE_REMOTE, &raddr, sizeof(raddr));
|
|
|
99be8f |
+ if (link)
|
|
|
99be8f |
+ addattr32(n, 1024, IFLA_GRE_LINK, link);
|
|
|
99be8f |
+ addattr_l(n, 1024, IFLA_GRE_TTL, &hop_limit, 1);
|
|
|
99be8f |
+ addattr_l(n, 1024, IFLA_GRE_ENCAP_LIMIT, &encap_limit, 1);
|
|
|
99be8f |
+ addattr_l(n, 1024, IFLA_GRE_FLOWINFO, &flowinfo, 4);
|
|
|
99be8f |
+ addattr32(n, 1024, IFLA_GRE_FLAGS, flags);
|
|
|
99be8f |
+
|
|
|
99be8f |
+ addattr16(n, 1024, IFLA_GRE_ENCAP_TYPE, encaptype);
|
|
|
99be8f |
+ addattr16(n, 1024, IFLA_GRE_ENCAP_FLAGS, encapflags);
|
|
|
99be8f |
+ addattr16(n, 1024, IFLA_GRE_ENCAP_SPORT, htons(encapsport));
|
|
|
99be8f |
+ addattr16(n, 1024, IFLA_GRE_ENCAP_DPORT, htons(encapdport));
|
|
|
99be8f |
+ } else {
|
|
|
99be8f |
+ addattr_l(n, 1024, IFLA_GRE_COLLECT_METADATA, NULL, 0);
|
|
|
99be8f |
+ }
|
|
|
99be8f |
|
|
|
99be8f |
return 0;
|
|
|
99be8f |
}
|
|
|
99be8f |
@@ -385,6 +395,11 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
|
|
|
99be8f |
if (!tb)
|
|
|
99be8f |
return;
|
|
|
99be8f |
|
|
|
99be8f |
+ if (tb[IFLA_GRE_COLLECT_METADATA]) {
|
|
|
99be8f |
+ fprintf(f, "external");
|
|
|
99be8f |
+ return;
|
|
|
99be8f |
+ }
|
|
|
99be8f |
+
|
|
|
99be8f |
if (tb[IFLA_GRE_FLAGS])
|
|
|
99be8f |
flags = rta_getattr_u32(tb[IFLA_GRE_FLAGS]);
|
|
|
99be8f |
|
|
|
99be8f |
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
|
|
|
99be8f |
index 8be5d5e1e9fd6..612bd8ce92696 100644
|
|
|
99be8f |
--- a/man/man8/ip-link.8.in
|
|
|
99be8f |
+++ b/man/man8/ip-link.8.in
|
|
|
99be8f |
@@ -877,6 +877,8 @@ the following additional arguments are supported:
|
|
|
99be8f |
.BI "dscp inherit"
|
|
|
99be8f |
] [
|
|
|
99be8f |
.BI dev " PHYS_DEV "
|
|
|
99be8f |
+] [
|
|
|
99be8f |
+.RB external
|
|
|
99be8f |
]
|
|
|
99be8f |
|
|
|
99be8f |
.in +8
|
|
|
99be8f |
@@ -958,6 +960,21 @@ or
|
|
|
99be8f |
.IR 00 ".." ff
|
|
|
99be8f |
when tunneling non-IP packets. The default value is 00.
|
|
|
99be8f |
|
|
|
99be8f |
+.sp
|
|
|
99be8f |
+.RB external
|
|
|
99be8f |
+- make this tunnel externally controlled (or not, which is the default).
|
|
|
99be8f |
+In the kernel, this is referred to as collect metadata mode. This flag is
|
|
|
99be8f |
+mutually exclusive with the
|
|
|
99be8f |
+.BR remote ,
|
|
|
99be8f |
+.BR local ,
|
|
|
99be8f |
+.BR seq ,
|
|
|
99be8f |
+.BR key,
|
|
|
99be8f |
+.BR csum,
|
|
|
99be8f |
+.BR hoplimit,
|
|
|
99be8f |
+.BR encaplimit,
|
|
|
99be8f |
+.BR flowlabel " and " tclass
|
|
|
99be8f |
+options.
|
|
|
99be8f |
+
|
|
|
99be8f |
.in -8
|
|
|
99be8f |
|
|
|
99be8f |
.TP
|
|
|
99be8f |
--
|
|
|
99be8f |
2.20.1
|
|
|
99be8f |
|