summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Worley <sworley@cumulusnetworks.com>2020-09-15 13:42:49 -0400
committerStephen Worley <sworley@cumulusnetworks.com>2020-09-28 12:41:00 -0400
commitaaa42e056fe2e52c74c8e9241948cc76b61e2ee2 (patch)
tree11c1033219b8c4c1ef8629f19d8f721bad96dd9b
parent54a701e4c1d61a7bc72161d501c5e4ee5204c929 (diff)
zebra: add type to nhg_prot_del API for sanity check
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>
-rw-r--r--zebra/zapi_msg.c2
-rw-r--r--zebra/zebra_nhg.c11
-rw-r--r--zebra/zebra_nhg.h2
3 files changed, 12 insertions, 3 deletions
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index 6a897166cf..7ed3a41ae1 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -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);
diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c
index ac8f4745d6..1ed7ff00e5 100644
--- a/zebra/zebra_nhg.c
+++ b/zebra/zebra_nhg.c
@@ -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);
diff --git a/zebra/zebra_nhg.h b/zebra/zebra_nhg.h
index d8aafbf2ca..052fa65d06 100644
--- a/zebra/zebra_nhg.h
+++ b/zebra/zebra_nhg.h
@@ -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.