diff options
author | David Ahern <dsahern@gmail.com> | 2017-08-17 22:59:34 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-08-18 13:01:04 (GMT) |
commit | 3500e25fd21a3b4e5fb1657119ee475880e2a192 (patch) | |
tree | 3ba8dc35bdcba6734eba54bc1b98f3e0a7b7418e | |
parent | 63d02c3c581b4edc915af820c364f53e77497ea0 (diff) | |
download | libnl-3500e25fd21a3b4e5fb1657119ee475880e2a192.zip libnl-3500e25fd21a3b4e5fb1657119ee475880e2a192.tar.gz libnl-3500e25fd21a3b4e5fb1657119ee475880e2a192.tar.bz2 |
Add support for label stack in nl-route commands
Add support for MPLS labels in nexthop specification. Specifically, the
'as' keyword specifies the MPLS label stack and if the route address
family is MPLS then the nexthop via is added as a route via instead of
a gateway (subtle differences introduced for MPLS).
Signed-off-by: David Ahern <dsahern@gmail.com>
-rw-r--r-- | src/lib/route.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/lib/route.c b/src/lib/route.c index cd3e897..2eac0a0 100644 --- a/src/lib/route.c +++ b/src/lib/route.c @@ -141,11 +141,13 @@ void nl_cli_route_parse_nexthop(struct rtnl_route *route, char *subopts, NH_DEV, NH_VIA, NH_WEIGHT, + NH_AS, }; static char *const tokens[] = { "dev", "via", "weight", + "as", NULL, }; struct rtnl_nexthop *nh; @@ -175,8 +177,20 @@ void nl_cli_route_parse_nexthop(struct rtnl_route *route, char *subopts, break; case NH_VIA: - addr = nl_cli_addr_parse(arg,rtnl_route_get_family(route)); - rtnl_route_nh_set_gateway(nh, addr); + if (rtnl_route_get_family(route) == AF_MPLS) { + addr = nl_cli_addr_parse(arg, 0); + rtnl_route_nh_set_via(nh, addr); + } else { + addr = nl_cli_addr_parse(arg,rtnl_route_get_family(route)); + rtnl_route_nh_set_gateway(nh, addr); + } + nl_addr_put(addr); + break; + + case NH_AS: + addr = nl_cli_addr_parse(arg, + rtnl_route_get_family(route)); + rtnl_route_nh_set_newdst(nh, addr); nl_addr_put(addr); break; |