From d498917efddb0eb19ed713ef377b95997b457abe Mon Sep 17 00:00:00 2001 From: Igor Ryzhov Date: Thu, 10 Feb 2022 01:43:37 +0300 Subject: [PATCH] bgpd: remove bgp_attr_undup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bgp_attr_undup does the same thing as bgp_attr_flush – frees the temporary data that might be allocated when applying a route-map. There is no need to have two separate functions for that. Signed-off-by: Igor Ryzhov --- bgpd/bgp_attr.c | 37 ------------------------------------- bgpd/bgp_attr.h | 1 - bgpd/bgp_route.c | 8 ++++---- bgpd/bgp_updgrp_adv.c | 2 +- 4 files changed, 5 insertions(+), 43 deletions(-) diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 3c3fd174f6..97ff4caca5 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -1149,43 +1149,6 @@ void bgp_attr_unintern_sub(struct attr *attr) srv6_vpn_unintern(&attr->srv6_vpn); } -/* - * 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) -{ - struct ecommunity *ecomm = bgp_attr_get_ecommunity(new); - - if (new->aspath != old->aspath) - aspath_free(new->aspath); - - if (new->community != old->community) - community_free(&new->community); - - if (ecomm != bgp_attr_get_ecommunity(old)) - ecommunity_free(&ecomm); - - if (new->lcommunity != old->lcommunity) - lcommunity_free(&new->lcommunity); - - if (new->srv6_l3vpn != old->srv6_l3vpn) { - srv6_l3vpn_free(new->srv6_l3vpn); - new->srv6_l3vpn = NULL; - } - - if (new->srv6_vpn != old->srv6_vpn) { - srv6_vpn_free(new->srv6_vpn); - new->srv6_vpn = NULL; - } -} - /* Free bgp attribute and aspath. */ void bgp_attr_unintern(struct attr **pattr) { diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h index 2cf332574b..b38cbf8ef8 100644 --- a/bgpd/bgp_attr.h +++ b/bgpd/bgp_attr.h @@ -394,7 +394,6 @@ extern void bgp_attr_finish(void); 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_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 **); diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 5bc2b8737e..5ca4cee159 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -3386,7 +3386,7 @@ static uint32_t bgp_filtered_routes_count(struct peer *peer, afi_t afi, if (filtered) count++; - bgp_attr_undup(&attr, ain->attr); + bgp_attr_flush(&attr); } } @@ -13590,7 +13590,7 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table, if (type == bgp_show_adj_route_filtered && !route_filtered && ret != RMAP_DENY) { - bgp_attr_undup(&attr, ain->attr); + bgp_attr_flush(&attr); continue; } @@ -13600,7 +13600,7 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table, route_vty_out_tmp(vty, dest, rn_p, &attr, safi, use_json, json_ar, wide); - bgp_attr_undup(&attr, ain->attr); + bgp_attr_flush(&attr); (*output_count)++; } } else if (type == bgp_show_adj_route_advertised) { @@ -13648,7 +13648,7 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table, (*filtered_count)++; } - bgp_attr_undup(&attr, adj->attr); + bgp_attr_flush(&attr); } } else if (type == bgp_show_adj_route_bestpath) { struct bgp_path_info *pi; diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c index 2110dcb8bc..dd140e48af 100644 --- a/bgpd/bgp_updgrp_adv.c +++ b/bgpd/bgp_updgrp_adv.c @@ -859,7 +859,7 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw) bgp_dest_get_prefix(dest), pi, &tmp_pi); if (ret == RMAP_DENYMATCH) { - bgp_attr_undup(&tmp_attr, &attr); + bgp_attr_flush(&tmp_attr); continue; } else { new_attr = bgp_attr_intern(&tmp_attr);