Skip to content

Commit

Permalink
geneve: add support for IPv6 link partners
Browse files Browse the repository at this point in the history
Signed-off-by: John W. Linville <[email protected]>
  • Loading branch information
linvjw authored and Stephen Hemminger committed Nov 24, 2015
1 parent e149d4e commit 906ac54
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions ip/iplink_geneve.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
fprintf(stderr, "Invalid address \"%s\"\n", *argv);
return -1;
}
if (IN_MULTICAST(ntohl(daddr)))
if (IN6_IS_ADDR_MULTICAST(&daddr6) || IN_MULTICAST(ntohl(daddr)))
invarg("invalid remote address", *argv);
} else if (!matches(*argv, "ttl") ||
!matches(*argv, "hoplimit")) {
Expand Down Expand Up @@ -96,18 +96,16 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
return -1;
}

if (!daddr) {
fprintf(stderr, "geneve: remove link partner not specified\n");
return -1;
}
if (memcmp(&daddr6, &in6addr_any, sizeof(daddr6)) != 0) {
fprintf(stderr, "geneve: remove link over IPv6 not supported\n");
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);
if (daddr)
addattr_l(n, 1024, IFLA_GENEVE_REMOTE, &daddr, 4);
if (memcmp(&daddr6, &in6addr_any, sizeof(daddr6)) != 0)
addattr_l(n, 1024, IFLA_GENEVE_REMOTE6, &daddr6, sizeof(struct in6_addr));
addattr8(n, 1024, IFLA_GENEVE_TTL, ttl);
addattr8(n, 1024, IFLA_GENEVE_TOS, tos);

Expand Down Expand Up @@ -135,6 +133,14 @@ static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
if (addr)
fprintf(f, "remote %s ",
format_host(AF_INET, 4, &addr, s1, sizeof(s1)));
} else if (tb[IFLA_GENEVE_REMOTE6]) {
struct in6_addr addr;
memcpy(&addr, RTA_DATA(tb[IFLA_GENEVE_REMOTE6]), sizeof(struct in6_addr));
if (memcmp(&addr, &in6addr_any, sizeof(addr)) != 0) {
if (IN6_IS_ADDR_MULTICAST(&addr))
fprintf(f, "remote %s ",
format_host(AF_INET6, sizeof(struct in6_addr), &addr, s1, sizeof(s1)));
}
}

if (tb[IFLA_GENEVE_TTL]) {
Expand Down

0 comments on commit 906ac54

Please sign in to comment.