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 <dslice@cumulusnetworks.com>
Ticket: CM-18309
Reviewed By: CCR-6781
Testing Done:  Manual testing looks good.  mpls tests successful
This commit is contained in:
Don Slice 2017-10-16 09:07:15 -07:00
parent ff2f3a8290
commit 8dc8a4b693

View File

@ -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));