diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-10-25 02:57:00 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-11-27 14:21:56 +0100 |
commit | f46d8e1ed038cead4ab0b86c1e5701afee711be3 (patch) | |
tree | ef6a95e46cfe3ffdbeaf669c756c6a734758c7e0 /bgpd/bgp_attr.c | |
parent | bgpd: Store original route-map type for the peer (diff) | |
download | frr-f46d8e1ed038cead4ab0b86c1e5701afee711be3.tar.xz frr-f46d8e1ed038cead4ab0b86c1e5701afee711be3.zip |
bgpd: Free up changes to attr that the speculative route-map applied
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>
Diffstat (limited to 'bgpd/bgp_attr.c')
-rw-r--r-- | bgpd/bgp_attr.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 76fc8f968..6ddb2ec8a 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -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) { |