]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospfd: Fixing few valgrind issues 8409/head
authorrgirada <rgirada@vmware.com>
Tue, 6 Apr 2021 12:40:31 +0000 (05:40 -0700)
committerrgirada <rgirada@vmware.com>
Fri, 16 Apr 2021 18:15:53 +0000 (11:15 -0700)
Description:
All matching external routes are added to matching external hash table
        of aggregate route when aggregation is enabled.
        But these external info pointers are not delinked from this hash table
        before freeing the corresponding memory  while disabling redistribution.
        Addressing these memory issues in this change.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
ospfd/ospf_asbr.c

index 0b4e5d77626d04bc3b81d66bd75b60bada252e20..1faf6bfc12be472d319811cf9ded52c9d7b7464f 100644 (file)
@@ -314,20 +314,29 @@ void ospf_redistribute_withdraw(struct ospf *ospf, uint8_t type,
        if (EXTERNAL_INFO(ext))
                for (rn = route_top(EXTERNAL_INFO(ext)); rn;
                     rn = route_next(rn))
-                       if ((ei = rn->info))
-                               if (ospf_external_info_find_lsa(ospf, &ei->p)) {
-                                       if (is_prefix_default(&ei->p)
-                                           && ospf->default_originate
-                                                      != DEFAULT_ORIGINATE_NONE)
-                                               continue;
+                       if ((ei = rn->info)) {
+                               struct ospf_external_aggr_rt *aggr;
+
+                               if (is_prefix_default(&ei->p)
+                                   && ospf->default_originate
+                                              != DEFAULT_ORIGINATE_NONE)
+                                       continue;
+
+                               aggr = ei->aggr_route;
+
+                               if (aggr)
+                                       ospf_unlink_ei_from_aggr(ospf, aggr,
+                                                                ei);
+                               else if (ospf_external_info_find_lsa(ospf,
+                                                                    &ei->p))
                                        ospf_external_lsa_flush(
                                                ospf, type, &ei->p,
                                                ei->ifindex /*, ei->nexthop */);
 
-                                       ospf_external_info_free(ei);
-                                       route_unlock_node(rn);
-                                       rn->info = NULL;
-                               }
+                               ospf_external_info_free(ei);
+                               route_unlock_node(rn);
+                               rn->info = NULL;
+                       }
 }
 
 /* External Route Aggregator Handlers */