From: Renato Westphal Date: Sat, 16 Sep 2017 00:25:32 +0000 (-0300) Subject: zebra: install MPLS LSPs with appropriate protocol type X-Git-Tag: frr-4.0-dev~277^2~4 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=805444ce721c814f44d4e7a7fb5cdc95fc11333a;p=matthieu%2Ffrr.git zebra: install MPLS LSPs with appropriate protocol type Signed-off-by: Renato Westphal --- diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 7c43c38f42..344a204fde 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -2349,6 +2349,7 @@ int netlink_mpls_multipath(int cmd, zebra_lsp_t *lsp) unsigned int nexthop_num; const char *routedesc; struct zebra_ns *zns = zebra_ns_lookup(NS_DEFAULT); + int route_type; struct { struct nlmsghdr n; @@ -2382,9 +2383,11 @@ int netlink_mpls_multipath(int cmd, zebra_lsp_t *lsp) } } - if (nexthop_num == 0) // unexpected + if (nexthop_num == 0 || !lsp->best_nhlfe) // unexpected return 0; + route_type = re_type_from_lsp_type(lsp->best_nhlfe->type); + req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); req.n.nlmsg_flags = NLM_F_CREATE | NLM_F_REQUEST; req.n.nlmsg_type = cmd; @@ -2393,7 +2396,7 @@ int netlink_mpls_multipath(int cmd, zebra_lsp_t *lsp) req.r.rtm_family = AF_MPLS; req.r.rtm_table = RT_TABLE_MAIN; req.r.rtm_dst_len = MPLS_LABEL_LEN_BITS; - req.r.rtm_protocol = RTPROT_ZEBRA; + req.r.rtm_protocol = zebra2proto(route_type); req.r.rtm_scope = RT_SCOPE_UNIVERSE; req.r.rtm_type = RTN_UNICAST; diff --git a/zebra/zebra_mpls.h b/zebra/zebra_mpls.h index 51279798a4..22c771c348 100644 --- a/zebra/zebra_mpls.h +++ b/zebra/zebra_mpls.h @@ -436,6 +436,24 @@ static inline enum lsp_types_t lsp_type_from_re_type(int re_type) } } +/* + * Map LSP type to RIB type. + */ +static inline int re_type_from_lsp_type(enum lsp_types_t lsp_type) +{ + switch (lsp_type) { + case ZEBRA_LSP_STATIC: + return ZEBRA_ROUTE_STATIC; + case ZEBRA_LSP_LDP: + return ZEBRA_ROUTE_LDP; + case ZEBRA_LSP_BGP: + return ZEBRA_ROUTE_BGP; + case ZEBRA_LSP_NONE: + default: + return ZEBRA_ROUTE_KERNEL; + } +} + /* NHLFE type as printable string. */ static inline const char *nhlfe_type2str(enum lsp_types_t lsp_type) {