]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: add type to nhg_prot_del API for sanity check
authorStephen Worley <sworley@cumulusnetworks.com>
Tue, 15 Sep 2020 17:42:49 +0000 (13:42 -0400)
committerStephen Worley <sworley@cumulusnetworks.com>
Mon, 28 Sep 2020 16:41:00 +0000 (12:41 -0400)
Add type to the nhg_proto_del API params for sanity checking
that the types of the route sent by the proto matches the type
found with the ID.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
zebra/zapi_msg.c
zebra/zebra_nhg.c
zebra/zebra_nhg.h

index 6a897166cfb9d204f4e70c502ddb248589f33a3c..7ed3a41ae1f09826ec38881a6fb3619a6a96d80f 100644 (file)
@@ -1746,7 +1746,7 @@ static void zread_nhg_del(ZAPI_HANDLER_ARGS)
         * Delete the received nhg id
         */
 
-       nhe = zebra_nhg_proto_del(id);
+       nhe = zebra_nhg_proto_del(id, proto);
 
        if (nhe) {
                zebra_nhg_decrement_ref(nhe);
index ac8f4745d65e1c023245ae4a43d70478af37a80f..1ed7ff00e5fe042f8f2811a508d50953493986cf 100644 (file)
@@ -2853,7 +2853,7 @@ struct nhg_hash_entry *zebra_nhg_proto_add(uint32_t id, int type,
 }
 
 /* Delete NHE from upper level proto, caller must decrement ref */
-struct nhg_hash_entry *zebra_nhg_proto_del(uint32_t id)
+struct nhg_hash_entry *zebra_nhg_proto_del(uint32_t id, int type)
 {
        struct nhg_hash_entry *nhe;
 
@@ -2866,6 +2866,15 @@ struct nhg_hash_entry *zebra_nhg_proto_del(uint32_t id)
                return NULL;
        }
 
+       if (type != nhe->type) {
+               if (IS_ZEBRA_DEBUG_NHG)
+                       zlog_debug(
+                               "%s: id %u, type %s mismatch, sent by %s, ignoring",
+                               __func__, id, zebra_route_string(nhe->type),
+                               zebra_route_string(type));
+               return NULL;
+       }
+
        if (CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_PROTO_RELEASED)) {
                if (IS_ZEBRA_DEBUG_NHG)
                        zlog_debug("%s: id %u, already released", __func__, id);
index d8aafbf2caee7c6c3f95637b47f235bc4f4f7494..052fa65d064014ffb1a3d32a230ae9d5ccb44cea 100644 (file)
@@ -294,7 +294,7 @@ struct nhg_hash_entry *zebra_nhg_proto_add(uint32_t id, int type,
  *
  * Caller must decrement ref with zebra_nhg_decrement_ref() when done.
  */
-struct nhg_hash_entry *zebra_nhg_proto_del(uint32_t id);
+struct nhg_hash_entry *zebra_nhg_proto_del(uint32_t id, int type);
 
 /*
  * Remove specific by proto NHGs.