]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: Remove tests for ipv[4|6]_prefix_table
authorDonald Sharp <sharpd@nvidia.com>
Tue, 21 Feb 2023 20:41:29 +0000 (15:41 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Thu, 23 Mar 2023 12:03:30 +0000 (08:03 -0400)
During code inspection, it was noticed that the ipv4_prefix_table
as well as the ipv6_prefix_table are always created on map creation.
There are no paths where they are not created, thus testing for
them adds a bit of code that will always be true.  Let's just
remove these extraneous tests.

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

index b8e91708e7d8fa811ed8bc387b4a95773cd9addd..20dcd2a53d4dc73589f666ee4e8509e7c7a69ad2 100644 (file)
@@ -706,6 +706,9 @@ static void route_map_free_map(struct route_map *map)
        else
                list->head = map->next;
 
+       route_table_finish(map->ipv4_prefix_table);
+       route_table_finish(map->ipv6_prefix_table);
+
        hash_release(route_map_master_hash, map);
        XFREE(MTYPE_ROUTE_MAP_NAME, map->name);
        XFREE(MTYPE_ROUTE_MAP, map);
@@ -1811,9 +1814,7 @@ route_map_get_index(struct route_map *map, const struct prefix *prefix,
         * must be AF_INET or AF_INET6 in order for the lookup to succeed. So if
         * the AF doesn't line up with the LPM trees, skip the optimization.
         */
-       if (map->optimization_disabled ||
-           (prefix->family == AF_INET && !map->ipv4_prefix_table) ||
-           (prefix->family == AF_INET6 && !map->ipv6_prefix_table)) {
+       if (map->optimization_disabled) {
                if (unlikely(CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP_DETAIL)))
                        zlog_debug(
                                "Skipping route-map optimization for route-map: %s, pfx: %pFX, family: %d",
@@ -1826,9 +1827,6 @@ route_map_get_index(struct route_map *map, const struct prefix *prefix,
        else
                table = map->ipv6_prefix_table;
 
-       if (!table)
-               return NULL;
-
        do {
                candidate_rmap_list =
                        route_map_get_index_list(&rn, prefix, table);
@@ -1914,19 +1912,10 @@ static void route_map_pfx_table_add_default(afi_t afi,
        p.family = afi2family(afi);
        p.prefixlen = 0;
 
-       if (p.family == AF_INET) {
-               table = index->map->ipv4_prefix_table;
-               if (!table)
-                       index->map->ipv4_prefix_table = route_table_init();
-
+       if (p.family == AF_INET)
                table = index->map->ipv4_prefix_table;
-       } else {
-               table = index->map->ipv6_prefix_table;
-               if (!table)
-                       index->map->ipv6_prefix_table = route_table_init();
-
+       else
                table = index->map->ipv6_prefix_table;
-       }
 
        /* Add default route to table */
        rn = route_node_get(table, &p);
@@ -2317,8 +2306,6 @@ static void route_map_pfx_tbl_update(route_map_event_t event,
                                     struct route_map_index *index, afi_t afi,
                                     const char *plist_name)
 {
-       struct route_map *rmap = NULL;
-
        if (!index)
                return;
 
@@ -2332,19 +2319,6 @@ static void route_map_pfx_tbl_update(route_map_event_t event,
                route_map_pfx_table_del_default(AFI_IP, index);
                route_map_pfx_table_del_default(AFI_IP6, index);
 
-               if ((index->map->head == NULL) && (index->map->tail == NULL)) {
-                       rmap = index->map;
-
-                       if (rmap->ipv4_prefix_table) {
-                               route_table_finish(rmap->ipv4_prefix_table);
-                               rmap->ipv4_prefix_table = NULL;
-                       }
-
-                       if (rmap->ipv6_prefix_table) {
-                               route_table_finish(rmap->ipv6_prefix_table);
-                               rmap->ipv6_prefix_table = NULL;
-                       }
-               }
                return;
        }