summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Ahern <dsahern@gmail.com>2017-08-17 15:59:34 -0700
committerThomas Haller <thaller@redhat.com>2017-08-18 15:01:04 +0200
commit3500e25fd21a3b4e5fb1657119ee475880e2a192 (patch)
tree3ba8dc35bdcba6734eba54bc1b98f3e0a7b7418e /src
parent63d02c3c581b4edc915af820c364f53e77497ea0 (diff)
downloadlibnl-3500e25fd21a3b4e5fb1657119ee475880e2a192.tar.gz
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>
Diffstat (limited to 'src')
-rw-r--r--src/lib/route.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/lib/route.c b/src/lib/route.c
index cd3e8978..2eac0a05 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;