From: Robert Shearman Date: Tue, 11 Apr 2017 08:37:20 +0000 (+0100) Subject: iproute: Add support for ttl-propagation attribute X-Git-Tag: v4.12.0~47^2~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c44d18ea96add9309ae72f9ca57dd534585de53b;p=thirdparty%2Fiproute2.git iproute: Add support for ttl-propagation attribute 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 Acked-by: David Ahern --- diff --git a/ip/iproute.c b/ip/iproute.c index 5e23613da..eedcc2f60 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"); @@ -715,6 +716,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; @@ -1185,6 +1193,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 d6e06649a..fbe2711a4 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