]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: Add a warning for when we are not operating correctly
authorDonald Sharp <sharpd@nvidia.com>
Fri, 18 Dec 2020 19:38:40 +0000 (14:38 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Fri, 18 Dec 2020 19:40:20 +0000 (14:40 -0500)
There exists a possibilty that route map dependencies
have gotten wrong.  Prevent the crash and warn the user
that we may be in trouble.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
lib/routemap.c

index 5082a9fa9a9dda64595c1780224816e3a57f5194..1c2f43d968300eb2e9af6b8ea567076617e5f845 100644 (file)
@@ -2767,12 +2767,19 @@ static int route_map_dep_update(struct hash *dephash, const char *dep_name,
                memset(&tmp_dep_data, 0, sizeof(struct route_map_dep_data));
                tmp_dep_data.rname = rname;
                dep_data = hash_lookup(dep->dep_rmap_hash, &tmp_dep_data);
-
-               if (!dep_data)
+               /*
+                * If dep_data is NULL then something has gone seriously
+                * wrong in route-map handling.  Note it and prevent
+                * the crash.
+                */
+               if (!dep_data) {
+                       zlog_warn(
+                               "route-map dependency for route-map %s: %s is not correct",
+                               rmap_name, dep_name);
                        goto out;
+               }
 
-               if (dep_data->refcnt)
-                       dep_data->refcnt--;
+               dep_data->refcnt--;
 
                if (!dep_data->refcnt) {
                        ret_dep_data = hash_release(dep->dep_rmap_hash,