memset(&req, 0, sizeof req - NL_PKT_BUF_SIZE);
-
/*
* Count # nexthops so we can decide whether to use singlepath
* or multipath case.
}
}
- 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;
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));