]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Free up changes to attr that the speculative route-map applied 1360/head
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 25 Oct 2017 00:57:00 +0000 (20:57 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 27 Nov 2017 13:21:56 +0000 (08:21 -0500)
So we have the ability to apply speculative route-maps to
neighbor display to see what the changes would look like
via some show commands.  When we do this we make a
shallow copy of the attr data structure and then pass
it around for applying the routemap.  After we've applied
this route-map and displayed it we really need to clean
up memory that the route-map application applied.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
bgpd/bgp_attr.c
bgpd/bgp_attr.h
bgpd/bgp_route.c

index 76fc8f968e3a50713aa2d1270de225650e976854..6ddb2ec8a7deac4ab8f557f650fbe702322bb6c3 100644 (file)
@@ -822,6 +822,32 @@ void bgp_attr_unintern_sub(struct attr *attr)
 #endif
 }
 
+/*
+ * We have some show commands that let you experimentally
+ * apply a route-map.  When we apply the route-map
+ * we are reseting values but not saving them for
+ * posterity via intern'ing( because route-maps don't
+ * do that) but at this point in time we need
+ * to compare the new attr to the old and if the
+ * routemap has changed it we need to, as Snoop Dog says,
+ * Drop it like it's hot
+ */
+void bgp_attr_undup(struct attr *new, struct attr *old)
+{
+       if (new->aspath != old->aspath)
+               aspath_free(new->aspath);
+
+       if (new->community != old->community)
+               community_free(new->community);
+
+       if (new->ecommunity != old->ecommunity)
+               ecommunity_free(&new->ecommunity);
+
+       if (new->lcommunity != old->lcommunity)
+               lcommunity_free(&new->lcommunity);
+
+}
+
 /* Free bgp attribute and aspath. */
 void bgp_attr_unintern(struct attr **pattr)
 {
index 80ff36b59fdd106164008b9e1bed15bd4c77065f..f694f01adb10be860f746d0d0d3232b3cc288908 100644 (file)
@@ -239,6 +239,7 @@ extern bgp_attr_parse_ret_t bgp_attr_parse(struct peer *, struct attr *,
                                           bgp_size_t, struct bgp_nlri *,
                                           struct bgp_nlri *);
 extern void bgp_attr_dup(struct attr *, struct attr *);
+extern void bgp_attr_undup(struct attr *new, struct attr *old);
 extern struct attr *bgp_attr_intern(struct attr *attr);
 extern void bgp_attr_unintern_sub(struct attr *);
 extern void bgp_attr_unintern(struct attr **);
index 1d267f259f5d9934661f4c1bf64ec471358bd73b..a655bd0b6f4f869662e368e146e4435ef5a9ef1a 100644 (file)
@@ -10247,6 +10247,9 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
                                                        output_count++;
                                                } else
                                                        filtered_count++;
+
+                                               bgp_attr_undup(&attr,
+                                                              adj->attr);
                                        }
                                }
                }