* [PATCH iproute2 net-next 1/2] iproute: Add support for ttl-propagation attribute
2017-04-10 14:36 [PATCH iproute2 net-next 0/2] ip: Allow TTL propagation to/from IP packets to be configured Robert Shearman
@ 2017-04-10 14:36 ` Robert Shearman
2017-04-11 3:43 ` David Ahern
2017-04-10 14:36 ` [PATCH iproute2 net-next 2/2] iproute: Add support for MPLS LWT ttl attribute Robert Shearman
` (2 subsequent siblings)
3 siblings, 1 reply; 11+ messages in thread
From: Robert Shearman @ 2017-04-10 14:36 UTC (permalink / raw)
To: netdev; +Cc: stephen, Robert Shearman
Add support for setting and displaying the ttl-propagation attribute
initially used by MPLS to control propagation of MPLS TTL to IPv4/IPv6
TTL/hop-limit on popping final label on a per-route basis.
Signed-off-by: Robert Shearman <rshearma@brocade.com>
---
ip/iproute.c | 22 ++++++++++++++++++++++
man/man8/ip-route.8.in | 10 +++++++++-
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/ip/iproute.c b/ip/iproute.c
index 7cdf0726feb3..c2b681fc9730 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -77,6 +77,7 @@ static void usage(void)
fprintf(stderr, "NODE_SPEC := [ TYPE ] PREFIX [ tos TOS ]\n");
fprintf(stderr, " [ table TABLE_ID ] [ proto RTPROTO ]\n");
fprintf(stderr, " [ scope SCOPE ] [ metric METRIC ]\n");
+ fprintf(stderr, " [ ttl-propagate { enabled | disabled } ]\n");
fprintf(stderr, "INFO_SPEC := NH OPTIONS FLAGS [ nexthop NH ]...\n");
fprintf(stderr, "NH := [ encap ENCAPTYPE ENCAPHDR ] [ via [ FAMILY ] ADDRESS ]\n");
fprintf(stderr, " [ dev STRING ] [ weight NUMBER ] NHFLAGS\n");
@@ -714,6 +715,13 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
fprintf(fp, "%u", pref);
}
}
+ if (tb[RTA_TTL_PROPAGATE]) {
+ fprintf(fp, "ttl-propagate ");
+ if (rta_getattr_u8(tb[RTA_TTL_PROPAGATE]))
+ fprintf(fp, "enabled");
+ else
+ fprintf(fp, "disabled");
+ }
fprintf(fp, "\n");
fflush(fp);
return 0;
@@ -1184,6 +1192,20 @@ static int iproute_modify(int cmd, unsigned int flags, int argc, char **argv)
if (rta->rta_len > RTA_LENGTH(0))
addraw_l(&req.n, 1024, RTA_DATA(rta), RTA_PAYLOAD(rta));
+ } else if (strcmp(*argv, "ttl-propagate") == 0) {
+ __u8 ttl_prop;
+
+ NEXT_ARG();
+ if (strcmp(*argv, "enabled") == 0)
+ ttl_prop = 1;
+ else if (strcmp(*argv, "disabled") == 0)
+ ttl_prop = 0;
+ else
+ invarg("\"ttl-propagate\" value is invalid\n",
+ *argv);
+
+ addattr8(&req.n, sizeof(req), RTA_TTL_PROPAGATE,
+ ttl_prop);
} else {
int type;
inet_prefix dst;
diff --git a/man/man8/ip-route.8.in b/man/man8/ip-route.8.in
index d6e06649a464..fbe2711a4301 100644
--- a/man/man8/ip-route.8.in
+++ b/man/man8/ip-route.8.in
@@ -75,7 +75,9 @@ replace " } "
.B scope
.IR SCOPE " ] [ "
.B metric
-.IR METRIC " ]"
+.IR METRIC " ] [ "
+.B ttl-propagate
+.RB "{ " enabled " | " disabled " } ]"
.ti -8
.IR INFO_SPEC " := " "NH OPTIONS FLAGS" " ["
@@ -710,6 +712,12 @@ is a set of encapsulation attributes specific to the
the route will be deleted after the expires time.
.B Only
support IPv6 at present.
+
+.TP
+.BR ttl-propagate " { " enabled " | " disabled " } "
+Control whether TTL should be propagated from any encap into the
+un-encapsulated packet, overriding any global configuration. Only
+supported for MPLS at present.
.RE
.TP
--
2.1.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH iproute2 net-next 1/2] iproute: Add support for ttl-propagation attribute
2017-04-10 14:36 ` [PATCH iproute2 net-next 1/2] iproute: Add support for ttl-propagation attribute Robert Shearman
@ 2017-04-11 3:43 ` David Ahern
2017-04-11 8:35 ` Robert Shearman
0 siblings, 1 reply; 11+ messages in thread
From: David Ahern @ 2017-04-11 3:43 UTC (permalink / raw)
To: Robert Shearman, netdev; +Cc: stephen
On 4/10/17 8:36 AM, Robert Shearman wrote:
> @@ -1184,6 +1192,20 @@ static int iproute_modify(int cmd, unsigned int flags, int argc, char **argv)
>
> if (rta->rta_len > RTA_LENGTH(0))
> addraw_l(&req.n, 1024, RTA_DATA(rta), RTA_PAYLOAD(rta));
> + } else if (strcmp(*argv, "ttl-propagate") == 0) {
> + __u8 ttl_prop;
> +
> + NEXT_ARG();
> + if (strcmp(*argv, "enabled") == 0)
> + ttl_prop = 1;
> + else if (strcmp(*argv, "disabled") == 0)
> + ttl_prop = 0;
> + else
> + invarg("\"ttl-propagate\" value is invalid\n",
> + *argv);
> +
matches() instead of strcmp() is more user friendly. 'enabled' is a lot
to type. ;-)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH iproute2 net-next 1/2] iproute: Add support for ttl-propagation attribute
2017-04-11 3:43 ` David Ahern
@ 2017-04-11 8:35 ` Robert Shearman
0 siblings, 0 replies; 11+ messages in thread
From: Robert Shearman @ 2017-04-11 8:35 UTC (permalink / raw)
To: David Ahern, netdev; +Cc: stephen
On 11/04/17 04:43, David Ahern wrote:
> On 4/10/17 8:36 AM, Robert Shearman wrote:
>> @@ -1184,6 +1192,20 @@ static int iproute_modify(int cmd, unsigned int flags, int argc, char **argv)
>>
>> if (rta->rta_len > RTA_LENGTH(0))
>> addraw_l(&req.n, 1024, RTA_DATA(rta), RTA_PAYLOAD(rta));
>> + } else if (strcmp(*argv, "ttl-propagate") == 0) {
>> + __u8 ttl_prop;
>> +
>> + NEXT_ARG();
>> + if (strcmp(*argv, "enabled") == 0)
>> + ttl_prop = 1;
>> + else if (strcmp(*argv, "disabled") == 0)
>> + ttl_prop = 0;
>> + else
>> + invarg("\"ttl-propagate\" value is invalid\n",
>> + *argv);
>> +
>
> matches() instead of strcmp() is more user friendly. 'enabled' is a lot
> to type. ;-)
>
Ok, will change as suggested in v2.
Thanks for reviewing,
Rob
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH iproute2 net-next 2/2] iproute: Add support for MPLS LWT ttl attribute
2017-04-10 14:36 [PATCH iproute2 net-next 0/2] ip: Allow TTL propagation to/from IP packets to be configured Robert Shearman
2017-04-10 14:36 ` [PATCH iproute2 net-next 1/2] iproute: Add support for ttl-propagation attribute Robert Shearman
@ 2017-04-10 14:36 ` Robert Shearman
2017-04-11 8:37 ` [PATCH v2 iproute2 net-next 0/2] ip: Allow TTL propagation to/from IP packets to be configured Robert Shearman
2017-04-12 17:00 ` [PATCH iproute2 net-next 0/2] ip: Allow TTL propagation to/from IP packets to be configured Stephen Hemminger
3 siblings, 0 replies; 11+ messages in thread
From: Robert Shearman @ 2017-04-10 14:36 UTC (permalink / raw)
To: netdev; +Cc: stephen, Robert Shearman
Add support for setting and displaying the ttl attribute
for MPLS IP lighweight tunnels.
Signed-off-by: Robert Shearman <rshearma@brocade.com>
---
ip/iproute_lwtunnel.c | 31 +++++++++++++++++++++++++++++--
man/man8/ip-route.8.in | 9 ++++++++-
2 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c
index 0fa1cab0a790..845a115e9e41 100644
--- a/ip/iproute_lwtunnel.c
+++ b/ip/iproute_lwtunnel.c
@@ -84,6 +84,9 @@ static void print_encap_mpls(FILE *fp, struct rtattr *encap)
if (tb[MPLS_IPTUNNEL_DST])
fprintf(fp, " %s ",
format_host_rta(AF_MPLS, tb[MPLS_IPTUNNEL_DST]));
+ if (tb[MPLS_IPTUNNEL_TTL])
+ fprintf(fp, "ttl %u ",
+ rta_getattr_u8(tb[MPLS_IPTUNNEL_TTL]));
}
static void print_encap_ip(FILE *fp, struct rtattr *encap)
@@ -247,6 +250,7 @@ static int parse_encap_mpls(struct rtattr *rta, size_t len,
inet_prefix addr;
int argc = *argcp;
char **argv = *argvp;
+ int ttl_ok = 0;
if (get_addr(&addr, *argv, AF_MPLS)) {
fprintf(stderr,
@@ -258,8 +262,31 @@ static int parse_encap_mpls(struct rtattr *rta, size_t len,
rta_addattr_l(rta, len, MPLS_IPTUNNEL_DST, &addr.data,
addr.bytelen);
- *argcp = argc;
- *argvp = argv;
+ argc--;
+ argv++;
+
+ while (argc > 0) {
+ if (strcmp(*argv, "ttl") == 0) {
+ __u8 ttl;
+
+ NEXT_ARG();
+ if (ttl_ok++)
+ duparg2("ttl", *argv);
+ if (get_u8(&ttl, *argv, 0))
+ invarg("\"ttl\" value is invalid\n", *argv);
+ rta_addattr8(rta, len, MPLS_IPTUNNEL_TTL, ttl);
+ } else {
+ break;
+ }
+ argc--; argv++;
+ }
+
+ /* argv is currently the first unparsed argument,
+ * but the lwt_parse_encap() caller will move to the next,
+ * so step back
+ */
+ *argcp = argc + 1;
+ *argvp = argv - 1;
return 0;
}
diff --git a/man/man8/ip-route.8.in b/man/man8/ip-route.8.in
index fbe2711a4301..d2a44acf2793 100644
--- a/man/man8/ip-route.8.in
+++ b/man/man8/ip-route.8.in
@@ -181,7 +181,9 @@ throw " | " unreachable " | " prohibit " | " blackhole " | " nat " ]"
.ti -8
.IR ENCAP_MPLS " := "
.BR mpls " [ "
-.IR LABEL " ]"
+.IR LABEL " ] ["
+.B ttl
+.IR TTL " ]"
.ti -8
.IR ENCAP_IP " := "
@@ -666,6 +668,11 @@ is a set of encapsulation attributes specific to the
.I MPLSLABEL
- mpls label stack with labels separated by
.I "/"
+.sp
+
+.B ttl
+.I TTL
+- TTL to use for MPLS header or 0 to inherit from IP header
.in -2
.sp
--
2.1.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 iproute2 net-next 0/2] ip: Allow TTL propagation to/from IP packets to be configured
2017-04-10 14:36 [PATCH iproute2 net-next 0/2] ip: Allow TTL propagation to/from IP packets to be configured Robert Shearman
2017-04-10 14:36 ` [PATCH iproute2 net-next 1/2] iproute: Add support for ttl-propagation attribute Robert Shearman
2017-04-10 14:36 ` [PATCH iproute2 net-next 2/2] iproute: Add support for MPLS LWT ttl attribute Robert Shearman
@ 2017-04-11 8:37 ` Robert Shearman
2017-04-11 8:37 ` [PATCH v2 iproute2 net-next 1/2] iproute: Add support for ttl-propagation attribute Robert Shearman
2017-04-11 8:37 ` [PATCH v2 iproute2 net-next 2/2] iproute: Add support for MPLS LWT ttl attribute Robert Shearman
2017-04-12 17:00 ` [PATCH iproute2 net-next 0/2] ip: Allow TTL propagation to/from IP packets to be configured Stephen Hemminger
3 siblings, 2 replies; 11+ messages in thread
From: Robert Shearman @ 2017-04-11 8:37 UTC (permalink / raw)
To: netdev; +Cc: stephen, David Ahern, Robert Shearman
This patch series adds support for per-MPLS-lightweight-tunnel ttl
values and per route ttl-propagation for the purposes of MPLS to be
specified.
Changes in v2:
- use matches instead of strcmp for enabled/disabled keywords to
avoid excessive typing
Robert Shearman (2):
iproute: Add support for ttl-propagation attribute
iproute: Add support for MPLS LWT ttl attribute
ip/iproute.c | 22 ++++++++++++++++++++++
ip/iproute_lwtunnel.c | 31 +++++++++++++++++++++++++++++--
man/man8/ip-route.8.in | 19 +++++++++++++++++--
3 files changed, 68 insertions(+), 4 deletions(-)
--
2.1.4
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 iproute2 net-next 1/2] iproute: Add support for ttl-propagation attribute
2017-04-11 8:37 ` [PATCH v2 iproute2 net-next 0/2] ip: Allow TTL propagation to/from IP packets to be configured Robert Shearman
@ 2017-04-11 8:37 ` Robert Shearman
2017-04-11 22:37 ` David Ahern
2017-04-11 8:37 ` [PATCH v2 iproute2 net-next 2/2] iproute: Add support for MPLS LWT ttl attribute Robert Shearman
1 sibling, 1 reply; 11+ messages in thread
From: Robert Shearman @ 2017-04-11 8:37 UTC (permalink / raw)
To: netdev; +Cc: stephen, David Ahern, Robert Shearman
Add support for setting and displaying the ttl-propagation attribute
initially used by MPLS to control propagation of MPLS TTL to IPv4/IPv6
TTL/hop-limit on popping final label on a per-route basis.
Signed-off-by: Robert Shearman <rshearma@brocade.com>
---
ip/iproute.c | 22 ++++++++++++++++++++++
man/man8/ip-route.8.in | 10 +++++++++-
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/ip/iproute.c b/ip/iproute.c
index 7cdf0726feb3..6f75319c944a 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -77,6 +77,7 @@ static void usage(void)
fprintf(stderr, "NODE_SPEC := [ TYPE ] PREFIX [ tos TOS ]\n");
fprintf(stderr, " [ table TABLE_ID ] [ proto RTPROTO ]\n");
fprintf(stderr, " [ scope SCOPE ] [ metric METRIC ]\n");
+ fprintf(stderr, " [ ttl-propagate { enabled | disabled } ]\n");
fprintf(stderr, "INFO_SPEC := NH OPTIONS FLAGS [ nexthop NH ]...\n");
fprintf(stderr, "NH := [ encap ENCAPTYPE ENCAPHDR ] [ via [ FAMILY ] ADDRESS ]\n");
fprintf(stderr, " [ dev STRING ] [ weight NUMBER ] NHFLAGS\n");
@@ -714,6 +715,13 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
fprintf(fp, "%u", pref);
}
}
+ if (tb[RTA_TTL_PROPAGATE]) {
+ fprintf(fp, "ttl-propagate ");
+ if (rta_getattr_u8(tb[RTA_TTL_PROPAGATE]))
+ fprintf(fp, "enabled");
+ else
+ fprintf(fp, "disabled");
+ }
fprintf(fp, "\n");
fflush(fp);
return 0;
@@ -1184,6 +1192,20 @@ static int iproute_modify(int cmd, unsigned int flags, int argc, char **argv)
if (rta->rta_len > RTA_LENGTH(0))
addraw_l(&req.n, 1024, RTA_DATA(rta), RTA_PAYLOAD(rta));
+ } else if (strcmp(*argv, "ttl-propagate") == 0) {
+ __u8 ttl_prop;
+
+ NEXT_ARG();
+ if (matches(*argv, "enabled") == 0)
+ ttl_prop = 1;
+ else if (matches(*argv, "disabled") == 0)
+ ttl_prop = 0;
+ else
+ invarg("\"ttl-propagate\" value is invalid\n",
+ *argv);
+
+ addattr8(&req.n, sizeof(req), RTA_TTL_PROPAGATE,
+ ttl_prop);
} else {
int type;
inet_prefix dst;
diff --git a/man/man8/ip-route.8.in b/man/man8/ip-route.8.in
index d6e06649a464..fbe2711a4301 100644
--- a/man/man8/ip-route.8.in
+++ b/man/man8/ip-route.8.in
@@ -75,7 +75,9 @@ replace " } "
.B scope
.IR SCOPE " ] [ "
.B metric
-.IR METRIC " ]"
+.IR METRIC " ] [ "
+.B ttl-propagate
+.RB "{ " enabled " | " disabled " } ]"
.ti -8
.IR INFO_SPEC " := " "NH OPTIONS FLAGS" " ["
@@ -710,6 +712,12 @@ is a set of encapsulation attributes specific to the
the route will be deleted after the expires time.
.B Only
support IPv6 at present.
+
+.TP
+.BR ttl-propagate " { " enabled " | " disabled " } "
+Control whether TTL should be propagated from any encap into the
+un-encapsulated packet, overriding any global configuration. Only
+supported for MPLS at present.
.RE
.TP
--
2.1.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 iproute2 net-next 2/2] iproute: Add support for MPLS LWT ttl attribute
2017-04-11 8:37 ` [PATCH v2 iproute2 net-next 0/2] ip: Allow TTL propagation to/from IP packets to be configured Robert Shearman
2017-04-11 8:37 ` [PATCH v2 iproute2 net-next 1/2] iproute: Add support for ttl-propagation attribute Robert Shearman
@ 2017-04-11 8:37 ` Robert Shearman
2017-04-11 22:37 ` David Ahern
1 sibling, 1 reply; 11+ messages in thread
From: Robert Shearman @ 2017-04-11 8:37 UTC (permalink / raw)
To: netdev; +Cc: stephen, David Ahern, Robert Shearman
Add support for setting and displaying the ttl attribute
for MPLS IP lighweight tunnels.
Signed-off-by: Robert Shearman <rshearma@brocade.com>
---
ip/iproute_lwtunnel.c | 31 +++++++++++++++++++++++++++++--
man/man8/ip-route.8.in | 9 ++++++++-
2 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c
index 0fa1cab0a790..845a115e9e41 100644
--- a/ip/iproute_lwtunnel.c
+++ b/ip/iproute_lwtunnel.c
@@ -84,6 +84,9 @@ static void print_encap_mpls(FILE *fp, struct rtattr *encap)
if (tb[MPLS_IPTUNNEL_DST])
fprintf(fp, " %s ",
format_host_rta(AF_MPLS, tb[MPLS_IPTUNNEL_DST]));
+ if (tb[MPLS_IPTUNNEL_TTL])
+ fprintf(fp, "ttl %u ",
+ rta_getattr_u8(tb[MPLS_IPTUNNEL_TTL]));
}
static void print_encap_ip(FILE *fp, struct rtattr *encap)
@@ -247,6 +250,7 @@ static int parse_encap_mpls(struct rtattr *rta, size_t len,
inet_prefix addr;
int argc = *argcp;
char **argv = *argvp;
+ int ttl_ok = 0;
if (get_addr(&addr, *argv, AF_MPLS)) {
fprintf(stderr,
@@ -258,8 +262,31 @@ static int parse_encap_mpls(struct rtattr *rta, size_t len,
rta_addattr_l(rta, len, MPLS_IPTUNNEL_DST, &addr.data,
addr.bytelen);
- *argcp = argc;
- *argvp = argv;
+ argc--;
+ argv++;
+
+ while (argc > 0) {
+ if (strcmp(*argv, "ttl") == 0) {
+ __u8 ttl;
+
+ NEXT_ARG();
+ if (ttl_ok++)
+ duparg2("ttl", *argv);
+ if (get_u8(&ttl, *argv, 0))
+ invarg("\"ttl\" value is invalid\n", *argv);
+ rta_addattr8(rta, len, MPLS_IPTUNNEL_TTL, ttl);
+ } else {
+ break;
+ }
+ argc--; argv++;
+ }
+
+ /* argv is currently the first unparsed argument,
+ * but the lwt_parse_encap() caller will move to the next,
+ * so step back
+ */
+ *argcp = argc + 1;
+ *argvp = argv - 1;
return 0;
}
diff --git a/man/man8/ip-route.8.in b/man/man8/ip-route.8.in
index fbe2711a4301..d2a44acf2793 100644
--- a/man/man8/ip-route.8.in
+++ b/man/man8/ip-route.8.in
@@ -181,7 +181,9 @@ throw " | " unreachable " | " prohibit " | " blackhole " | " nat " ]"
.ti -8
.IR ENCAP_MPLS " := "
.BR mpls " [ "
-.IR LABEL " ]"
+.IR LABEL " ] ["
+.B ttl
+.IR TTL " ]"
.ti -8
.IR ENCAP_IP " := "
@@ -666,6 +668,11 @@ is a set of encapsulation attributes specific to the
.I MPLSLABEL
- mpls label stack with labels separated by
.I "/"
+.sp
+
+.B ttl
+.I TTL
+- TTL to use for MPLS header or 0 to inherit from IP header
.in -2
.sp
--
2.1.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH iproute2 net-next 0/2] ip: Allow TTL propagation to/from IP packets to be configured
2017-04-10 14:36 [PATCH iproute2 net-next 0/2] ip: Allow TTL propagation to/from IP packets to be configured Robert Shearman
` (2 preceding siblings ...)
2017-04-11 8:37 ` [PATCH v2 iproute2 net-next 0/2] ip: Allow TTL propagation to/from IP packets to be configured Robert Shearman
@ 2017-04-12 17:00 ` Stephen Hemminger
3 siblings, 0 replies; 11+ messages in thread
From: Stephen Hemminger @ 2017-04-12 17:00 UTC (permalink / raw)
To: Robert Shearman; +Cc: netdev
On Mon, 10 Apr 2017 15:36:10 +0100
Robert Shearman <rshearma@brocade.com> wrote:
> This patch series adds support for per-MPLS-lightweight-tunnel ttl
> values and per route ttl-propagation for the purposes of MPLS to be
> specified.
>
> Robert Shearman (2):
> iproute: Add support for ttl-propagation attribute
> iproute: Add support for MPLS LWT ttl attribute
>
> ip/iproute.c | 22 ++++++++++++++++++++++
> ip/iproute_lwtunnel.c | 31 +++++++++++++++++++++++++++++--
> man/man8/ip-route.8.in | 19 +++++++++++++++++--
> 3 files changed, 68 insertions(+), 4 deletions(-)
>
Both applied, thanks
^ permalink raw reply [flat|nested] 11+ messages in thread