bgpd: remove bgp_attr_undup

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 <iryzhov@nfware.com>
This commit is contained in:
Igor Ryzhov 2022-02-10 01:43:37 +03:00
parent 8aa03a655e
commit d498917efd
4 changed files with 5 additions and 43 deletions

View File

@ -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)
{

View File

@ -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 **);

View File

@ -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;

View File

@ -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);