netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2 net-next] gre6: add collect metadata support
@ 2017-12-01 23:03 William Tu
  2017-12-04 17:26 ` Gregory Rose
  0 siblings, 1 reply; 3+ messages in thread
From: William Tu @ 2017-12-01 23:03 UTC (permalink / raw)
  To: netdev

The patch adds 'external' option to support collect metadata
gre6 tunnel. Example of L3 and L2 gre device:
bash:~# ip link add dev ip6gre123 type ip6gre external
bash:~# ip link add dev ip6gretap123 type ip6gretap external

Signed-off-by: William Tu <u9012063@gmail.com>
---
 ip/link_gre6.c        | 55 ++++++++++++++++++++++++++++++++-------------------
 man/man8/ip-link.8.in |  6 ++++++
 2 files changed, 41 insertions(+), 20 deletions(-)

diff --git a/ip/link_gre6.c b/ip/link_gre6.c
index 0a82eaecf2cd..2cb46ca116d0 100644
--- a/ip/link_gre6.c
+++ b/ip/link_gre6.c
@@ -105,6 +105,7 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
 	__u16 encapflags = TUNNEL_ENCAP_FLAG_CSUM6;
 	__u16 encapsport = 0;
 	__u16 encapdport = 0;
+	__u8 metadata = 0;
 	int len;
 	__u32 fwmark = 0;
 	__u32 erspan_idx = 0;
@@ -178,6 +179,9 @@ get_failed:
 		if (greinfo[IFLA_GRE_ENCAP_SPORT])
 			encapsport = rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_SPORT]);
 
+		if (greinfo[IFLA_GRE_COLLECT_METADATA])
+			metadata = 1;
+
 		if (greinfo[IFLA_GRE_ENCAP_DPORT])
 			encapdport = rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_DPORT]);
 
@@ -355,6 +359,8 @@ get_failed:
 			encapflags |= TUNNEL_ENCAP_FLAG_REMCSUM;
 		} else if (strcmp(*argv, "noencap-remcsum") == 0) {
 			encapflags &= ~TUNNEL_ENCAP_FLAG_REMCSUM;
+		} else if (strcmp(*argv, "external") == 0) {
+			metadata = 1;
 		} else if (strcmp(*argv, "fwmark") == 0) {
 			NEXT_ARG();
 			if (strcmp(*argv, "inherit") == 0) {
@@ -388,26 +394,30 @@ get_failed:
 		argc--; argv++;
 	}
 
-	addattr32(n, 1024, IFLA_GRE_IKEY, ikey);
-	addattr32(n, 1024, IFLA_GRE_OKEY, okey);
-	addattr_l(n, 1024, IFLA_GRE_IFLAGS, &iflags, 2);
-	addattr_l(n, 1024, IFLA_GRE_OFLAGS, &oflags, 2);
-	addattr_l(n, 1024, IFLA_GRE_LOCAL, &laddr, sizeof(laddr));
-	addattr_l(n, 1024, IFLA_GRE_REMOTE, &raddr, sizeof(raddr));
-	if (link)
-		addattr32(n, 1024, IFLA_GRE_LINK, link);
-	addattr_l(n, 1024, IFLA_GRE_TTL, &hop_limit, 1);
-	addattr_l(n, 1024, IFLA_GRE_ENCAP_LIMIT, &encap_limit, 1);
-	addattr_l(n, 1024, IFLA_GRE_FLOWINFO, &flowinfo, 4);
-	addattr32(n, 1024, IFLA_GRE_FLAGS, flags);
-	addattr32(n, 1024, IFLA_GRE_FWMARK, fwmark);
-	if (erspan_idx != 0)
-		addattr32(n, 1024, IFLA_GRE_ERSPAN_INDEX, erspan_idx);
-
-	addattr16(n, 1024, IFLA_GRE_ENCAP_TYPE, encaptype);
-	addattr16(n, 1024, IFLA_GRE_ENCAP_FLAGS, encapflags);
-	addattr16(n, 1024, IFLA_GRE_ENCAP_SPORT, htons(encapsport));
-	addattr16(n, 1024, IFLA_GRE_ENCAP_DPORT, htons(encapdport));
+	if (!metadata) {
+		addattr32(n, 1024, IFLA_GRE_IKEY, ikey);
+		addattr32(n, 1024, IFLA_GRE_OKEY, okey);
+		addattr_l(n, 1024, IFLA_GRE_IFLAGS, &iflags, 2);
+		addattr_l(n, 1024, IFLA_GRE_OFLAGS, &oflags, 2);
+		addattr_l(n, 1024, IFLA_GRE_LOCAL, &laddr, sizeof(laddr));
+		addattr_l(n, 1024, IFLA_GRE_REMOTE, &raddr, sizeof(raddr));
+		if (link)
+			addattr32(n, 1024, IFLA_GRE_LINK, link);
+		addattr_l(n, 1024, IFLA_GRE_TTL, &hop_limit, 1);
+		addattr_l(n, 1024, IFLA_GRE_ENCAP_LIMIT, &encap_limit, 1);
+		addattr_l(n, 1024, IFLA_GRE_FLOWINFO, &flowinfo, 4);
+		addattr32(n, 1024, IFLA_GRE_FLAGS, flags);
+		addattr32(n, 1024, IFLA_GRE_FWMARK, fwmark);
+		if (erspan_idx != 0)
+			addattr32(n, 1024, IFLA_GRE_ERSPAN_INDEX, erspan_idx);
+
+		addattr16(n, 1024, IFLA_GRE_ENCAP_TYPE, encaptype);
+		addattr16(n, 1024, IFLA_GRE_ENCAP_FLAGS, encapflags);
+		addattr16(n, 1024, IFLA_GRE_ENCAP_SPORT, htons(encapsport));
+		addattr16(n, 1024, IFLA_GRE_ENCAP_DPORT, htons(encapdport));
+	} else {
+		addattr_l(n, 1024, IFLA_GRE_COLLECT_METADATA, NULL, 0);
+	}
 
 	return 0;
 }
@@ -426,6 +436,11 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 	if (!tb)
 		return;
 
+	if (tb[IFLA_GRE_COLLECT_METADATA]) {
+		print_bool(PRINT_ANY, "collect_metadata", "external", true);
+		return;
+	}
+
 	if (tb[IFLA_GRE_FLAGS])
 		flags = rta_getattr_u32(tb[IFLA_GRE_FLAGS]);
 
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
index a6a10e577b1f..c9b9bb7b2a4e 100644
--- a/man/man8/ip-link.8.in
+++ b/man/man8/ip-link.8.in
@@ -755,6 +755,8 @@ the following additional arguments are supported:
 .BI "dscp inherit"
 ] [
 .BI dev " PHYS_DEV "
+] [
+.RB [ no ] external
 ]
 
 .in +8
@@ -833,6 +835,10 @@ or
 .IR 00 ".." ff
 when tunneling non-IP packets. The default value is 00.
 
+.sp
+.RB [ no ] external
+- make this tunnel externally controlled (or not, which is the default).
+
 .in -8
 
 .TP
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH iproute2 net-next] gre6: add collect metadata support
  2017-12-01 23:03 [PATCH iproute2 net-next] gre6: add collect metadata support William Tu
@ 2017-12-04 17:26 ` Gregory Rose
  2017-12-04 20:40   ` William Tu
  0 siblings, 1 reply; 3+ messages in thread
From: Gregory Rose @ 2017-12-04 17:26 UTC (permalink / raw)
  To: William Tu, netdev

On 12/1/2017 3:03 PM, William Tu wrote:
> The patch adds 'external' option to support collect metadata
> gre6 tunnel. Example of L3 and L2 gre device:
> bash:~# ip link add dev ip6gre123 type ip6gre external
> bash:~# ip link add dev ip6gretap123 type ip6gretap external

Hi William,

one question.  Is there ever actually going to be a situation in which 
an ipv6 gre tunnel will go from
external to not external?  I'm wondering if the "no external" option is 
really needed since default is
no and I'm not sure under what circumstances a tunnel would go from 
external to not external.

Thanks,

- Greg

>
> Signed-off-by: William Tu <u9012063@gmail.com>
> ---
>   ip/link_gre6.c        | 55 ++++++++++++++++++++++++++++++++-------------------
>   man/man8/ip-link.8.in |  6 ++++++
>   2 files changed, 41 insertions(+), 20 deletions(-)
>
> diff --git a/ip/link_gre6.c b/ip/link_gre6.c
> index 0a82eaecf2cd..2cb46ca116d0 100644
> --- a/ip/link_gre6.c
> +++ b/ip/link_gre6.c
> @@ -105,6 +105,7 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
>   	__u16 encapflags = TUNNEL_ENCAP_FLAG_CSUM6;
>   	__u16 encapsport = 0;
>   	__u16 encapdport = 0;
> +	__u8 metadata = 0;
>   	int len;
>   	__u32 fwmark = 0;
>   	__u32 erspan_idx = 0;
> @@ -178,6 +179,9 @@ get_failed:
>   		if (greinfo[IFLA_GRE_ENCAP_SPORT])
>   			encapsport = rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_SPORT]);
>   
> +		if (greinfo[IFLA_GRE_COLLECT_METADATA])
> +			metadata = 1;
> +
>   		if (greinfo[IFLA_GRE_ENCAP_DPORT])
>   			encapdport = rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_DPORT]);
>   
> @@ -355,6 +359,8 @@ get_failed:
>   			encapflags |= TUNNEL_ENCAP_FLAG_REMCSUM;
>   		} else if (strcmp(*argv, "noencap-remcsum") == 0) {
>   			encapflags &= ~TUNNEL_ENCAP_FLAG_REMCSUM;
> +		} else if (strcmp(*argv, "external") == 0) {
> +			metadata = 1;
>   		} else if (strcmp(*argv, "fwmark") == 0) {
>   			NEXT_ARG();
>   			if (strcmp(*argv, "inherit") == 0) {
> @@ -388,26 +394,30 @@ get_failed:
>   		argc--; argv++;
>   	}
>   
> -	addattr32(n, 1024, IFLA_GRE_IKEY, ikey);
> -	addattr32(n, 1024, IFLA_GRE_OKEY, okey);
> -	addattr_l(n, 1024, IFLA_GRE_IFLAGS, &iflags, 2);
> -	addattr_l(n, 1024, IFLA_GRE_OFLAGS, &oflags, 2);
> -	addattr_l(n, 1024, IFLA_GRE_LOCAL, &laddr, sizeof(laddr));
> -	addattr_l(n, 1024, IFLA_GRE_REMOTE, &raddr, sizeof(raddr));
> -	if (link)
> -		addattr32(n, 1024, IFLA_GRE_LINK, link);
> -	addattr_l(n, 1024, IFLA_GRE_TTL, &hop_limit, 1);
> -	addattr_l(n, 1024, IFLA_GRE_ENCAP_LIMIT, &encap_limit, 1);
> -	addattr_l(n, 1024, IFLA_GRE_FLOWINFO, &flowinfo, 4);
> -	addattr32(n, 1024, IFLA_GRE_FLAGS, flags);
> -	addattr32(n, 1024, IFLA_GRE_FWMARK, fwmark);
> -	if (erspan_idx != 0)
> -		addattr32(n, 1024, IFLA_GRE_ERSPAN_INDEX, erspan_idx);
> -
> -	addattr16(n, 1024, IFLA_GRE_ENCAP_TYPE, encaptype);
> -	addattr16(n, 1024, IFLA_GRE_ENCAP_FLAGS, encapflags);
> -	addattr16(n, 1024, IFLA_GRE_ENCAP_SPORT, htons(encapsport));
> -	addattr16(n, 1024, IFLA_GRE_ENCAP_DPORT, htons(encapdport));
> +	if (!metadata) {
> +		addattr32(n, 1024, IFLA_GRE_IKEY, ikey);
> +		addattr32(n, 1024, IFLA_GRE_OKEY, okey);
> +		addattr_l(n, 1024, IFLA_GRE_IFLAGS, &iflags, 2);
> +		addattr_l(n, 1024, IFLA_GRE_OFLAGS, &oflags, 2);
> +		addattr_l(n, 1024, IFLA_GRE_LOCAL, &laddr, sizeof(laddr));
> +		addattr_l(n, 1024, IFLA_GRE_REMOTE, &raddr, sizeof(raddr));
> +		if (link)
> +			addattr32(n, 1024, IFLA_GRE_LINK, link);
> +		addattr_l(n, 1024, IFLA_GRE_TTL, &hop_limit, 1);
> +		addattr_l(n, 1024, IFLA_GRE_ENCAP_LIMIT, &encap_limit, 1);
> +		addattr_l(n, 1024, IFLA_GRE_FLOWINFO, &flowinfo, 4);
> +		addattr32(n, 1024, IFLA_GRE_FLAGS, flags);
> +		addattr32(n, 1024, IFLA_GRE_FWMARK, fwmark);
> +		if (erspan_idx != 0)
> +			addattr32(n, 1024, IFLA_GRE_ERSPAN_INDEX, erspan_idx);
> +
> +		addattr16(n, 1024, IFLA_GRE_ENCAP_TYPE, encaptype);
> +		addattr16(n, 1024, IFLA_GRE_ENCAP_FLAGS, encapflags);
> +		addattr16(n, 1024, IFLA_GRE_ENCAP_SPORT, htons(encapsport));
> +		addattr16(n, 1024, IFLA_GRE_ENCAP_DPORT, htons(encapdport));
> +	} else {
> +		addattr_l(n, 1024, IFLA_GRE_COLLECT_METADATA, NULL, 0);
> +	}
>   
>   	return 0;
>   }
> @@ -426,6 +436,11 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
>   	if (!tb)
>   		return;
>   
> +	if (tb[IFLA_GRE_COLLECT_METADATA]) {
> +		print_bool(PRINT_ANY, "collect_metadata", "external", true);
> +		return;
> +	}
> +
>   	if (tb[IFLA_GRE_FLAGS])
>   		flags = rta_getattr_u32(tb[IFLA_GRE_FLAGS]);
>   
> diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
> index a6a10e577b1f..c9b9bb7b2a4e 100644
> --- a/man/man8/ip-link.8.in
> +++ b/man/man8/ip-link.8.in
> @@ -755,6 +755,8 @@ the following additional arguments are supported:
>   .BI "dscp inherit"
>   ] [
>   .BI dev " PHYS_DEV "
> +] [
> +.RB [ no ] external
>   ]
>   
>   .in +8
> @@ -833,6 +835,10 @@ or
>   .IR 00 ".." ff
>   when tunneling non-IP packets. The default value is 00.
>   
> +.sp
> +.RB [ no ] external
> +- make this tunnel externally controlled (or not, which is the default).
> +
>   .in -8
>   
>   .TP

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH iproute2 net-next] gre6: add collect metadata support
  2017-12-04 17:26 ` Gregory Rose
@ 2017-12-04 20:40   ` William Tu
  0 siblings, 0 replies; 3+ messages in thread
From: William Tu @ 2017-12-04 20:40 UTC (permalink / raw)
  To: Gregory Rose; +Cc: Linux Kernel Network Developers

On Mon, Dec 4, 2017 at 9:26 AM, Gregory Rose <gvrose8192@gmail.com> wrote:
> On 12/1/2017 3:03 PM, William Tu wrote:
>>
>> The patch adds 'external' option to support collect metadata
>> gre6 tunnel. Example of L3 and L2 gre device:
>> bash:~# ip link add dev ip6gre123 type ip6gre external
>> bash:~# ip link add dev ip6gretap123 type ip6gretap external
>
>
> Hi William,
>
> one question.  Is there ever actually going to be a situation in which an
> ipv6 gre tunnel will go from
> external to not external?  I'm wondering if the "no external" option is
> really needed since default is
> no and I'm not sure under what circumstances a tunnel would go from external
> to not external.
>
> Thanks,
>
> - Greg

good point. I don't think we should support setting a tunnel from
external to no external at run-time.
Let me remove the "noexternal" description in man page.
Thanks

William

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-12-04 20:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-01 23:03 [PATCH iproute2 net-next] gre6: add collect metadata support William Tu
2017-12-04 17:26 ` Gregory Rose
2017-12-04 20:40   ` William Tu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).