Commit 926b39e1 authored by Paolo Abeni's avatar Paolo Abeni Committed by Stephen Hemminger

gre: add support for collect metadata flag

This patch add support for IFLA_GRE_COLLECT_METADATA via the
'external' keyword to the gre link.
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent e79c327e
...@@ -74,6 +74,7 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv, ...@@ -74,6 +74,7 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
__u16 encapflags = 0; __u16 encapflags = 0;
__u16 encapsport = 0; __u16 encapsport = 0;
__u16 encapdport = 0; __u16 encapdport = 0;
__u8 metadata = 0;
if (!(n->nlmsg_flags & NLM_F_CREATE)) { if (!(n->nlmsg_flags & NLM_F_CREATE)) {
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
...@@ -148,6 +149,9 @@ get_failed: ...@@ -148,6 +149,9 @@ get_failed:
encapsport = rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_SPORT]); encapsport = rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_SPORT]);
if (greinfo[IFLA_GRE_ENCAP_DPORT]) if (greinfo[IFLA_GRE_ENCAP_DPORT])
encapdport = rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_DPORT]); encapdport = rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_DPORT]);
if (greinfo[IFLA_GRE_COLLECT_METADATA])
metadata = 1;
} }
while (argc > 0) { while (argc > 0) {
...@@ -291,6 +295,8 @@ get_failed: ...@@ -291,6 +295,8 @@ get_failed:
encapflags |= TUNNEL_ENCAP_FLAG_REMCSUM; encapflags |= TUNNEL_ENCAP_FLAG_REMCSUM;
} else if (strcmp(*argv, "noencap-remcsum") == 0) { } else if (strcmp(*argv, "noencap-remcsum") == 0) {
encapflags |= ~TUNNEL_ENCAP_FLAG_REMCSUM; encapflags |= ~TUNNEL_ENCAP_FLAG_REMCSUM;
} else if (strcmp(*argv, "external") == 0) {
metadata = 1;
} else } else
usage(); usage();
argc--; argv++; argc--; argv++;
...@@ -325,6 +331,8 @@ get_failed: ...@@ -325,6 +331,8 @@ get_failed:
addattr16(n, 1024, IFLA_GRE_ENCAP_FLAGS, encapflags); addattr16(n, 1024, IFLA_GRE_ENCAP_FLAGS, encapflags);
addattr16(n, 1024, IFLA_GRE_ENCAP_SPORT, htons(encapsport)); addattr16(n, 1024, IFLA_GRE_ENCAP_SPORT, htons(encapsport));
addattr16(n, 1024, IFLA_GRE_ENCAP_DPORT, htons(encapdport)); addattr16(n, 1024, IFLA_GRE_ENCAP_DPORT, htons(encapdport));
if (metadata)
addattr_l(n, 1024, IFLA_GRE_COLLECT_METADATA, NULL, 0);
return 0; return 0;
} }
...@@ -413,6 +421,9 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) ...@@ -413,6 +421,9 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
if (oflags & GRE_CSUM) if (oflags & GRE_CSUM)
fputs("ocsum ", f); fputs("ocsum ", f);
if (tb[IFLA_GRE_COLLECT_METADATA])
fputs("external ", f);
if (tb[IFLA_GRE_ENCAP_TYPE] && if (tb[IFLA_GRE_ENCAP_TYPE] &&
*(__u16 *)RTA_DATA(tb[IFLA_GRE_ENCAP_TYPE]) != TUNNEL_ENCAP_NONE) { *(__u16 *)RTA_DATA(tb[IFLA_GRE_ENCAP_TYPE]) != TUNNEL_ENCAP_NONE) {
__u16 type = rta_getattr_u16(tb[IFLA_GRE_ENCAP_TYPE]); __u16 type = rta_getattr_u16(tb[IFLA_GRE_ENCAP_TYPE]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment