]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: add PROTO_OWNED macro for NHE id bounds checking
authorStephen Worley <sworley@nvidia.com>
Thu, 22 Apr 2021 21:16:57 +0000 (17:16 -0400)
committerStephen Worley <sworley@nvidia.com>
Thu, 22 Apr 2021 21:25:15 +0000 (17:25 -0400)
Add a PROTO_OWNED macro for code readability when checking
ID bounds for whether a NHG is proto owned.

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

index 7edf022892839a8e0afde5e88286be16a60f9001..0f3c0a147e0da0d4cbd0dc5d6453f285768bc857 100644 (file)
@@ -2559,7 +2559,7 @@ int nexthop_active_update(struct route_node *rn, struct route_entry *re)
        struct nhg_hash_entry *curr_nhe;
        uint32_t curr_active = 0, backup_active = 0;
 
-       if (re->nhe->id >= ZEBRA_NHG_PROTO_LOWER)
+       if (PROTO_OWNED(re->nhe))
                return proto_nhg_nexthop_active_update(&re->nhe->nhg);
 
        afi_t rt_afi = family2afi(rn->p.family);
@@ -2861,13 +2861,13 @@ void zebra_nhg_dplane_result(struct zebra_dplane_ctx *ctx)
                        zebra_nhg_handle_install(nhe);
 
                        /* If daemon nhg, send it an update */
-                       if (nhe->id >= ZEBRA_NHG_PROTO_LOWER)
+                       if (PROTO_OWNED(nhe))
                                zsend_nhg_notify(nhe->type, nhe->zapi_instance,
                                                 nhe->zapi_session, nhe->id,
                                                 ZAPI_NHG_INSTALLED);
                } else {
                        /* If daemon nhg, send it an update */
-                       if (nhe->id >= ZEBRA_NHG_PROTO_LOWER)
+                       if (PROTO_OWNED(nhe))
                                zsend_nhg_notify(nhe->type, nhe->zapi_instance,
                                                 nhe->zapi_session, nhe->id,
                                                 ZAPI_NHG_FAIL_INSTALL);
@@ -3201,7 +3201,7 @@ static void zebra_nhg_score_proto_entry(struct hash_bucket *bucket, void *arg)
        iter = arg;
 
        /* Needs to match type and outside zebra ID space */
-       if (nhe->type == iter->type && nhe->id >= ZEBRA_NHG_PROTO_LOWER) {
+       if (nhe->type == iter->type && PROTO_OWNED(nhe)) {
                if (IS_ZEBRA_DEBUG_NHG_DETAIL)
                        zlog_debug(
                                "%s: found nhe %p (%u), vrf %d, type %s after client disconnect",
index 38015bf557d3fede57ae50bf70c20de94d8ebabf..0489f059be20563c48edfbe6fd40e16a68512e19 100644 (file)
@@ -147,6 +147,8 @@ enum nhg_type {
 /* Is this an NHE owned by zebra and not an upper level protocol? */
 #define ZEBRA_OWNED(NHE) (NHE->type == ZEBRA_ROUTE_NHG)
 
+#define PROTO_OWNED(NHE) (NHE->id >= ZEBRA_NHG_PROTO_LOWER)
+
 /*
  * Backup nexthops: this is a group object itself, so
  * that the backup nexthops can use the same code as a normal object.