From: Don Slice Date: Mon, 16 Oct 2017 16:07:15 +0000 (-0700) Subject: zebra: only pass mpls proto type if doing install X-Git-Tag: frr-4.0-dev~188^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=8dc8a4b693a87ca08b120d175e8fb0932674eaef;p=matthieu%2Ffrr.git zebra: only pass mpls proto type if doing install Problem reported with not deleting LSPs from the zebra kernal mpls table when a delete occurred in bgp. Found that we were exiting the delete process incorrectly due to not being able to derive the route_type from the best_nhlre on the lsp while deleting. Since this info was only needed for route installation, removed this early exit in the case of deleting the lsp. Signed-off-by: Don Slice Ticket: CM-18309 Reviewed By: CCR-6781 Testing Done: Manual testing looks good. mpls tests successful --- 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));