]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: handle zapi routes with NHG ID set
authorStephen Worley <sworley@cumulusnetworks.com>
Sun, 10 May 2020 21:32:24 +0000 (17:32 -0400)
committerStephen Worley <sworley@cumulusnetworks.com>
Mon, 28 Sep 2020 16:40:59 +0000 (12:40 -0400)
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 <sworley@cumulusnetworks.com>
zebra/zapi_msg.c
zebra/zebra_rib.c

index dfcab080f14a9c74aebe6df01a58fe7ce458926c..1c2a9fb6a7584985122f9935567751b7a915c18d 100644 (file)
@@ -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);
 
index ff30de18a3ff895acd2870262d677696f04e1c36..5a7967d8173d32dfa1bf4a7070c201d75ce0c45d 100644 (file)
@@ -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;
                }