diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 0cc2e0217f..c9a6335277 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -2370,7 +2370,6 @@ int netlink_mpls_multipath(int cmd, zebra_lsp_t *lsp) memset(&req, 0, sizeof req - NL_PKT_BUF_SIZE); - /* * Count # nexthops so we can decide whether to use singlepath * or multipath case. @@ -2394,11 +2393,9 @@ int netlink_mpls_multipath(int cmd, zebra_lsp_t *lsp) } } - if (nexthop_num == 0 || !lsp->best_nhlfe) // unexpected + if ((nexthop_num == 0) || (!lsp->best_nhlfe && (cmd != RTM_DELROUTE))) 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; @@ -2407,14 +2404,18 @@ 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 = zebra2proto(route_type); req.r.rtm_scope = RT_SCOPE_UNIVERSE; req.r.rtm_type = RTN_UNICAST; - if (cmd == RTM_NEWROUTE) + if (cmd == RTM_NEWROUTE) { /* We do a replace to handle update. */ req.n.nlmsg_flags |= NLM_F_REPLACE; + /* set the protocol value if installing */ + route_type = re_type_from_lsp_type(lsp->best_nhlfe->type); + req.r.rtm_protocol = zebra2proto(route_type); + } + /* Fill destination */ lse = mpls_lse_encode(lsp->ile.in_label, 0, 0, 1); addattr_l(&req.n, sizeof req, RTA_DST, &lse, sizeof(mpls_lse_t));