From: Donald Sharp Date: Fri, 16 Mar 2018 14:46:28 +0000 (-0400) Subject: zebra: Apply label to all nexthops when needed X-Git-Tag: frr-5.0-dev~144^2~2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=8f77d0ee6c42ab240bd4ef8880dbf7a8b25e5553;p=mirror%2Ffrr.git zebra: Apply label to all nexthops when needed The application of a label to a route entry needs to look at all non-recursive nexthops to be attached to instead of just the first one. Signed-off-by: Donald Sharp --- diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index 1868b4676d..8375d45d2f 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -2254,6 +2254,19 @@ void zebra_mpls_print_fec(struct vty *vty, struct zebra_vrf *zvrf, fec_print(rn->info, vty); } +static bool mpls_ftn_update_nexthop(int add, struct nexthop *nexthop, + enum lsp_types_t type, mpls_label_t label) +{ + if (add && nexthop->nh_label_type == ZEBRA_LSP_NONE) + nexthop_add_labels(nexthop, type, 1, &label); + else if (!add && nexthop->nh_label_type == type) + nexthop_del_labels(nexthop); + else + return false; + + return true; +} + /* * Install/uninstall a FEC-To-NHLFE (FTN) binding. */ @@ -2266,6 +2279,7 @@ int mpls_ftn_update(int add, struct zebra_vrf *zvrf, enum lsp_types_t type, struct route_node *rn; struct route_entry *re; struct nexthop *nexthop; + bool found; /* Lookup table. */ table = zebra_vrf_table(family2afi(prefix->family), SAFI_UNICAST, @@ -2285,6 +2299,7 @@ int mpls_ftn_update(int add, struct zebra_vrf *zvrf, enum lsp_types_t type, if (re == NULL) return -1; + found = false; for (nexthop = re->ng.nexthop; nexthop; nexthop = nexthop->next) { switch (nexthop->type) { case NEXTHOP_TYPE_IPV4: @@ -2297,7 +2312,11 @@ int mpls_ftn_update(int add, struct zebra_vrf *zvrf, enum lsp_types_t type, if (nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX && nexthop->ifindex != ifindex) continue; - goto found; + if (!mpls_ftn_update_nexthop(add, nexthop, type, + out_label)) + return 0; + found = true; + break; case NEXTHOP_TYPE_IPV6: case NEXTHOP_TYPE_IPV6_IFINDEX: if (gtype != NEXTHOP_TYPE_IPV6 @@ -2308,21 +2327,18 @@ int mpls_ftn_update(int add, struct zebra_vrf *zvrf, enum lsp_types_t type, if (nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX && nexthop->ifindex != ifindex) continue; - goto found; + if (!mpls_ftn_update_nexthop(add, nexthop, type, + out_label)) + return 0; + found = true; + break; default: break; } } - /* nexthop not found */ - return -1; -found: - if (add && nexthop->nh_label_type == ZEBRA_LSP_NONE) - nexthop_add_labels(nexthop, type, 1, &out_label); - else if (!add && nexthop->nh_label_type == type) - nexthop_del_labels(nexthop); - else - return 0; + if (!found) + return -1; SET_FLAG(re->status, ROUTE_ENTRY_CHANGED); SET_FLAG(re->status, ROUTE_ENTRY_LABELS_CHANGED);