From: Stephen Worley Date: Sun, 10 May 2020 21:32:24 +0000 (-0400) Subject: zebra: handle zapi routes with NHG ID set X-Git-Tag: base_7.6~489^2~45 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=50db3f2f1df221d1e3cdf450f672c4d558be66b6;p=mirror%2Ffrr.git zebra: handle zapi routes with NHG ID set Add code to properly handle routes sent with NHG ID rather than a nexthop_group. For now, we separate this from backup nexthop handling since that should probably be added to the nhg_proto_add calls. Signed-off-by: Stephen Worley --- diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index dfcab080f1..1c2a9fb6a7 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -1832,16 +1832,6 @@ stream_failure: return; } -static bool zapi_msg_get_nhg(struct zapi_route *api, struct nexthop_group **ng) -{ - if (!CHECK_FLAG(api->message, ZAPI_MESSAGE_NHG)) - return false; - - /* TODO lookup the ng from api->nhgid */ - *ng = NULL; - return true; -} - static void zread_route_add(ZAPI_HANDLER_ARGS) { struct stream *s; @@ -1908,7 +1898,10 @@ static void zread_route_add(ZAPI_HANDLER_ARGS) zebra_route_string(client->proto), &api.prefix); } - if (zapi_msg_get_nhg(&api, &ng) + if (CHECK_FLAG(api.message, ZAPI_MESSAGE_NHG)) + re->nhe_id = api.nhgid; + + if (!re->nhe_id || !zapi_read_nexthops(client, &api.prefix, api.nexthops, api.flags, api.message, api.nexthop_num, api.backup_nexthop_num, &ng, NULL) @@ -1952,13 +1945,21 @@ static void zread_route_add(ZAPI_HANDLER_ARGS) return; } - /* Include backup info with the route. We use a temporary nhe here; + /* + * If we have an ID, this proto owns the NHG it sent along with the + * route, so we just send the ID into rib code with it. + * + * Havent figured out how to handle backup NHs with this yet, so lets + * keep that separate. + * Include backup info with the route. We use a temporary nhe here; * if this is a new/unknown nhe, a new copy will be allocated * and stored. */ - zebra_nhe_init(&nhe, afi, ng->nexthop); - nhe.nhg.nexthop = ng->nexthop; - nhe.backup_info = bnhg; + if (!re->nhe_id) { + zebra_nhe_init(&nhe, afi, ng->nexthop); + nhe.nhg.nexthop = ng->nexthop; + nhe.backup_info = bnhg; + } ret = rib_add_multipath_nhe(afi, api.safi, &api.prefix, src_p, re, &nhe); diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index ff30de18a3..5a7967d817 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -2906,14 +2906,14 @@ int rib_add_multipath_nhe(afi_t afi, safi_t safi, struct prefix *p, if (!table) return -1; - if (re_nhe->id > 0) { - nhe = zebra_nhg_lookup_id(re_nhe->id); + if (re->nhe_id > 0) { + nhe = zebra_nhg_lookup_id(re->nhe_id); if (!nhe) { flog_err( EC_ZEBRA_TABLE_LOOKUP_FAILED, "Zebra failed to find the nexthop hash entry for id=%u in a route entry", - re_nhe->id); + re->nhe_id); return -1; }