Commit 9450c5ec authored by Paolo Abeni's avatar Paolo Abeni Committed by Stephen Hemminger

geneve: add support for lwt tunnel creation and dst port selection

This change add the ability to create lwt/flow based/externally
controlled geneve device and to select the udp destination port used
by a full geneve tunnel.
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 67584e3a
...@@ -19,6 +19,7 @@ static void print_explain(FILE *f) ...@@ -19,6 +19,7 @@ static void print_explain(FILE *f)
{ {
fprintf(f, "Usage: ... geneve id VNI remote ADDR\n"); fprintf(f, "Usage: ... geneve id VNI remote ADDR\n");
fprintf(f, " [ ttl TTL ] [ tos TOS ]\n"); fprintf(f, " [ ttl TTL ] [ tos TOS ]\n");
fprintf(f, " [ dstport PORT ] [ [no]external ]\n");
fprintf(f, "\n"); fprintf(f, "\n");
fprintf(f, "Where: VNI := 0-16777215\n"); fprintf(f, "Where: VNI := 0-16777215\n");
fprintf(f, " ADDR := IP_ADDRESS\n"); fprintf(f, " ADDR := IP_ADDRESS\n");
...@@ -40,6 +41,8 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv, ...@@ -40,6 +41,8 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
struct in6_addr daddr6 = IN6ADDR_ANY_INIT; struct in6_addr daddr6 = IN6ADDR_ANY_INIT;
__u8 ttl = 0; __u8 ttl = 0;
__u8 tos = 0; __u8 tos = 0;
__u16 dstport = 0;
bool metadata = 0;
while (argc > 0) { while (argc > 0) {
if (!matches(*argv, "id") || if (!matches(*argv, "id") ||
...@@ -80,6 +83,14 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv, ...@@ -80,6 +83,14 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
tos = uval; tos = uval;
} else } else
tos = 1; tos = 1;
} else if (!matches(*argv, "dstport")) {
NEXT_ARG();
if (get_u16(&dstport, *argv, 0))
invarg("dstport", *argv);
} else if (!matches(*argv, "external")) {
metadata = true;
} else if (!matches(*argv, "noexternal")) {
metadata = false;
} else if (matches(*argv, "help") == 0) { } else if (matches(*argv, "help") == 0) {
explain(); explain();
return -1; return -1;
...@@ -91,14 +102,22 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv, ...@@ -91,14 +102,22 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
argc--, argv++; argc--, argv++;
} }
if (!vni_set) { if (metadata && vni_set) {
fprintf(stderr, "geneve: missing virtual network identifier\n"); fprintf(stderr, "geneve: both 'external' and vni cannot be specified\n");
return -1; return -1;
} }
if (!daddr && memcmp(&daddr6, &in6addr_any, sizeof(daddr6)) == 0) { if (!metadata) {
fprintf(stderr, "geneve: remote link partner not specified\n"); /* parameter checking make sense only for full geneve tunnels */
return -1; if (!vni_set) {
fprintf(stderr, "geneve: missing virtual network identifier\n");
return -1;
}
if (!daddr && memcmp(&daddr6, &in6addr_any, sizeof(daddr6)) == 0) {
fprintf(stderr, "geneve: remote link partner not specified\n");
return -1;
}
} }
addattr32(n, 1024, IFLA_GENEVE_ID, vni); addattr32(n, 1024, IFLA_GENEVE_ID, vni);
...@@ -108,6 +127,10 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv, ...@@ -108,6 +127,10 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
addattr_l(n, 1024, IFLA_GENEVE_REMOTE6, &daddr6, sizeof(struct in6_addr)); addattr_l(n, 1024, IFLA_GENEVE_REMOTE6, &daddr6, sizeof(struct in6_addr));
addattr8(n, 1024, IFLA_GENEVE_TTL, ttl); addattr8(n, 1024, IFLA_GENEVE_TTL, ttl);
addattr8(n, 1024, IFLA_GENEVE_TOS, tos); addattr8(n, 1024, IFLA_GENEVE_TOS, tos);
if (dstport)
addattr16(n, 1024, IFLA_GENEVE_PORT, htons(dstport));
if (metadata)
addattr(n, 1024, IFLA_GENEVE_COLLECT_METADATA);
return 0; return 0;
} }
...@@ -156,6 +179,14 @@ static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) ...@@ -156,6 +179,14 @@ static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
else else
fprintf(f, "tos %#x ", tos); fprintf(f, "tos %#x ", tos);
} }
if (tb[IFLA_GENEVE_PORT])
fprintf(f, "dstport %u ",
ntohs(rta_getattr_u16(tb[IFLA_GENEVE_PORT])));
if (tb[IFLA_GENEVE_COLLECT_METADATA])
fputs("external ", f);
} }
static void geneve_print_help(struct link_util *lu, int argc, char **argv, static void geneve_print_help(struct link_util *lu, int argc, char **argv,
......
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