|
|
049c96 |
From 9e871fce2cd86c1e7ee7db0b7f658b63c6b70c84 Mon Sep 17 00:00:00 2001
|
|
|
049c96 |
From: Phil Sutter <psutter@redhat.com>
|
|
|
049c96 |
Date: Sat, 2 Jul 2016 12:45:04 +0200
|
|
|
049c96 |
Subject: [PATCH] iplink_geneve: add ttl configuration at link creation
|
|
|
049c96 |
|
|
|
049c96 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1339178
|
|
|
049c96 |
Upstream Status: iproute2.git commit f4c05c2e99538
|
|
|
049c96 |
Conflicts: Context changes due to already updated kernel headers.
|
|
|
049c96 |
|
|
|
049c96 |
commit f4c05c2e9953810c42e37ae21f6970c1f024fa46
|
|
|
049c96 |
Author: John W. Linville <linville@tuxdriver.com>
|
|
|
049c96 |
Date: Mon Jun 15 14:37:15 2015 -0400
|
|
|
049c96 |
|
|
|
049c96 |
iplink_geneve: add ttl configuration at link creation
|
|
|
049c96 |
|
|
|
049c96 |
Signed-off-by: John W. Linville <linville@tuxdriver.com>
|
|
|
049c96 |
---
|
|
|
049c96 |
ip/iplink_geneve.c | 23 ++++++++++++++++++++++-
|
|
|
049c96 |
man/man8/ip-link.8.in | 7 +++++++
|
|
|
049c96 |
2 files changed, 29 insertions(+), 1 deletion(-)
|
|
|
049c96 |
|
|
|
049c96 |
diff --git a/ip/iplink_geneve.c b/ip/iplink_geneve.c
|
|
|
049c96 |
index 74703e1..dff08a6 100644
|
|
|
049c96 |
--- a/ip/iplink_geneve.c
|
|
|
049c96 |
+++ b/ip/iplink_geneve.c
|
|
|
049c96 |
@@ -17,9 +17,11 @@
|
|
|
049c96 |
static void print_explain(FILE *f)
|
|
|
049c96 |
{
|
|
|
049c96 |
fprintf(f, "Usage: ... geneve id VNI remote ADDR\n");
|
|
|
049c96 |
+ fprintf(f, " [ ttl TTL ]\n");
|
|
|
049c96 |
fprintf(f, "\n");
|
|
|
049c96 |
fprintf(f, "Where: VNI := 0-16777215\n");
|
|
|
049c96 |
fprintf(f, " ADDR := IP_ADDRESS\n");
|
|
|
049c96 |
+ fprintf(f, " TTL := { 1..255 | inherit }\n");
|
|
|
049c96 |
}
|
|
|
049c96 |
|
|
|
049c96 |
static void explain(void)
|
|
|
049c96 |
@@ -34,7 +36,7 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
|
|
|
049c96 |
int vni_set = 0;
|
|
|
049c96 |
__u32 daddr = 0;
|
|
|
049c96 |
struct in6_addr daddr6 = IN6ADDR_ANY_INIT;
|
|
|
049c96 |
-
|
|
|
049c96 |
+ __u8 ttl = 0;
|
|
|
049c96 |
|
|
|
049c96 |
while (argc > 0) {
|
|
|
049c96 |
if (!matches(*argv, "id") ||
|
|
|
049c96 |
@@ -52,6 +54,18 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
|
|
|
049c96 |
}
|
|
|
049c96 |
if (IN_MULTICAST(ntohl(daddr)))
|
|
|
049c96 |
invarg("invalid remote address", *argv);
|
|
|
049c96 |
+ } else if (!matches(*argv, "ttl") ||
|
|
|
049c96 |
+ !matches(*argv, "hoplimit")) {
|
|
|
049c96 |
+ unsigned uval;
|
|
|
049c96 |
+
|
|
|
049c96 |
+ NEXT_ARG();
|
|
|
049c96 |
+ if (strcmp(*argv, "inherit") != 0) {
|
|
|
049c96 |
+ if (get_unsigned(&uval, *argv, 0))
|
|
|
049c96 |
+ invarg("invalid TTL", *argv);
|
|
|
049c96 |
+ if (uval > 255)
|
|
|
049c96 |
+ invarg("TTL must be <= 255", *argv);
|
|
|
049c96 |
+ ttl = uval;
|
|
|
049c96 |
+ }
|
|
|
049c96 |
} else if (matches(*argv, "help") == 0) {
|
|
|
049c96 |
explain();
|
|
|
049c96 |
return -1;
|
|
|
049c96 |
@@ -80,6 +94,7 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
|
|
|
049c96 |
addattr32(n, 1024, IFLA_GENEVE_ID, vni);
|
|
|
049c96 |
if (daddr)
|
|
|
049c96 |
addattr_l(n, 1024, IFLA_GENEVE_REMOTE, &daddr, 4);
|
|
|
049c96 |
+ addattr8(n, 1024, IFLA_GENEVE_TTL, ttl);
|
|
|
049c96 |
|
|
|
049c96 |
return 0;
|
|
|
049c96 |
}
|
|
|
049c96 |
@@ -105,6 +120,12 @@ static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
|
|
|
049c96 |
fprintf(f, "remote %s ",
|
|
|
049c96 |
format_host(AF_INET, 4, &addr, s1, sizeof(s1)));
|
|
|
049c96 |
}
|
|
|
049c96 |
+
|
|
|
049c96 |
+ if (tb[IFLA_GENEVE_TTL]) {
|
|
|
049c96 |
+ __u8 ttl = rta_getattr_u8(tb[IFLA_GENEVE_TTL]);
|
|
|
049c96 |
+ if (ttl)
|
|
|
049c96 |
+ fprintf(f, "ttl %d ", ttl);
|
|
|
049c96 |
+ }
|
|
|
049c96 |
}
|
|
|
049c96 |
|
|
|
049c96 |
static void geneve_print_help(struct link_util *lu, int argc, char **argv,
|
|
|
049c96 |
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
|
|
|
049c96 |
index 21503ff..284ee13 100644
|
|
|
049c96 |
--- a/man/man8/ip-link.8.in
|
|
|
049c96 |
+++ b/man/man8/ip-link.8.in
|
|
|
049c96 |
@@ -670,6 +670,9 @@ the following additional arguments are supported:
|
|
|
049c96 |
|
|
|
049c96 |
.BI "ip link add " DEVICE
|
|
|
049c96 |
.BI type " geneve " id " ID " remote " IPADDR"
|
|
|
049c96 |
+.R " [ "
|
|
|
049c96 |
+.BI ttl " TTL "
|
|
|
049c96 |
+.R " ]"
|
|
|
049c96 |
|
|
|
049c96 |
.in +8
|
|
|
049c96 |
.sp
|
|
|
049c96 |
@@ -680,6 +683,10 @@ the following additional arguments are supported:
|
|
|
049c96 |
.BI remote " IPADDR"
|
|
|
049c96 |
- specifies the unicast destination IP address to use in outgoing packets.
|
|
|
049c96 |
|
|
|
049c96 |
+.sp
|
|
|
049c96 |
+.BI ttl " TTL"
|
|
|
049c96 |
+- specifies the TTL value to use in outgoing packets.
|
|
|
049c96 |
+
|
|
|
049c96 |
.in -8
|
|
|
049c96 |
|
|
|
049c96 |
.TP
|
|
|
049c96 |
--
|
|
|
049c96 |
1.8.3.1
|
|
|
049c96 |
|