bgpd: remove bgp_attr_dup

yeah

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
Quentin Young 2019-12-03 16:01:19 -05:00
parent 04c8f2eb83
commit 6f4f49b237
10 changed files with 29 additions and 34 deletions

View File

@ -464,15 +464,6 @@ static void transit_finish(void)
/* Attribute hash routines. */
static struct hash *attrhash;
/* Shallow copy of an attribute
* Though, not so shallow that it doesn't copy the contents
* of the attr_extra pointed to by 'extra'
*/
void bgp_attr_dup(struct attr *new, struct attr *orig)
{
*new = *orig;
}
unsigned long int attr_count(void)
{
return attrhash->count;

View File

@ -272,7 +272,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_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 *);

View File

@ -1571,7 +1571,7 @@ static int update_evpn_type5_route(struct bgp *bgp_vrf, struct prefix_evpn *evp,
* present, else treat as locally originated.
*/
if (src_attr)
bgp_attr_dup(&attr, src_attr);
attr = *src_attr;
else {
memset(&attr, 0, sizeof(struct attr));
bgp_attr_default_set(&attr, BGP_ORIGIN_IGP);
@ -2661,7 +2661,7 @@ static int install_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
* address for the rest of the code to flow through. In the case of IPv4,
* make sure to set the flag for next hop attribute.
*/
bgp_attr_dup(&attr, parent_pi->attr);
attr = *parent_pi->attr;
if (afi == AFI_IP6)
evpn_convert_nexthop_to_ipv6(&attr);
else

View File

@ -720,7 +720,7 @@ void bgp_path_info_mpath_aggregate_update(struct bgp_path_info *new_best,
return;
}
bgp_attr_dup(&attr, new_best->attr);
attr = *new_best->attr;
if (new_best->peer && bgp_flag_check(new_best->peer->bgp,
BGP_FLAG_MULTIPATH_RELAX_AS_SET)) {

View File

@ -699,7 +699,8 @@ void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, /* to */
return;
}
bgp_attr_dup(&static_attr, path_vrf->attr); /* shallow copy */
/* shallow copy */
static_attr = *path_vrf->attr;
/*
* route map handling
@ -1082,7 +1083,8 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf, /* to */
buf_prefix, bgp_vrf->name_pretty);
}
bgp_attr_dup(&static_attr, path_vpn->attr); /* shallow copy */
/* shallow copy */
static_attr = *path_vpn->attr;
/*
* Nexthop: stash and clear

View File

@ -1695,7 +1695,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
}
/* For modify attribute, copy it to temporary structure. */
bgp_attr_dup(attr, piattr);
*attr = *piattr;
/* If local-preference is not set. */
if ((peer->sort == BGP_PEER_IBGP || peer->sort == BGP_PEER_CONFED)
@ -1815,7 +1815,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
if ((from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP)
&& !bgp_flag_check(bgp,
BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) {
bgp_attr_dup(&dummy_attr, attr);
dummy_attr = *attr;
rmap_path.attr = &dummy_attr;
}
@ -3178,7 +3178,7 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id,
goto filtered;
}
bgp_attr_dup(&new_attr, attr);
new_attr = *attr;
/* Apply incoming route-map.
* NB: new_attr may now contain newly allocated values from route-map
@ -6829,7 +6829,7 @@ void bgp_redistribute_add(struct bgp *bgp, struct prefix *p,
struct attr attr_new;
/* Copy attribute for modification. */
bgp_attr_dup(&attr_new, &attr);
attr_new = attr;
if (red->redist_metric_flag)
attr_new.med = red->redist_metric;
@ -9218,7 +9218,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
struct attr dummy_attr;
route_map_result_t ret;
bgp_attr_dup(&dummy_attr, pi->attr);
dummy_attr = *pi->attr;
path.peer = pi->peer;
path.attr = &dummy_attr;
@ -11361,7 +11361,7 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
header2 = 0;
}
bgp_attr_dup(&attr, ain->attr);
attr = *ain->attr;
route_filtered = false;
/* Filter prefix using distribute list,
@ -11463,7 +11463,7 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
header2 = 0;
}
bgp_attr_dup(&attr, adj->attr);
attr = *adj->attr;
ret = bgp_output_modifier(
peer, &rn->p, &attr, afi, safi,
rmap_name);

View File

@ -764,7 +764,7 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
/* Provide dummy so the route-map can't modify
* the attributes */
bgp_attr_dup(&dummy_attr, ri->attr);
dummy_attr = *ri->attr;
tmp_info.peer = ri->peer;
tmp_info.attr = &dummy_attr;

View File

@ -1693,7 +1693,7 @@ int bgp_redistribute_metric_set(struct bgp *bgp, struct bgp_redist *red,
struct attr *old_attr;
struct attr new_attr;
bgp_attr_dup(&new_attr, pi->attr);
new_attr = *pi->attr;
new_attr.med = red->redist_metric;
old_attr = pi->attr;
pi->attr = bgp_attr_intern(&new_attr);

View File

@ -78,7 +78,7 @@ static void encap_attr_export_ce(struct attr *new, struct attr *orig,
* Make "new" a ghost attr copy of "orig"
*/
memset(new, 0, sizeof(struct attr));
bgp_attr_dup(new, orig);
*new = *orig;
/*
* Set nexthop
@ -616,7 +616,7 @@ encap_attr_export(struct attr *new, struct attr *orig,
* Make "new" a ghost attr copy of "orig"
*/
memset(new, 0, sizeof(struct attr));
bgp_attr_dup(new, orig);
*new = *orig;
/*
* Set nexthop

View File

@ -356,7 +356,8 @@ static int process_unicast_route(struct bgp *bgp, /* in */
* all of the possible returns above.
*/
memset(&hattr, 0, sizeof(struct attr));
bgp_attr_dup(&hattr, attr); /* hattr becomes a ghost attr */
/* hattr becomes a ghost attr */
hattr = *attr;
if (rmap) {
struct bgp_path_info info;
@ -798,7 +799,8 @@ static void vnc_import_bgp_add_route_mode_plain(struct bgp *bgp,
* all of the possible returns above.
*/
memset(&hattr, 0, sizeof(struct attr));
bgp_attr_dup(&hattr, attr); /* hattr becomes a ghost attr */
/* hattr becomes a ghost attr */
hattr = *attr;
if (rmap) {
struct bgp_path_info info;
@ -1000,7 +1002,8 @@ vnc_import_bgp_add_route_mode_nvegroup(struct bgp *bgp, struct prefix *prefix,
* all of the possible returns above.
*/
memset(&hattr, 0, sizeof(struct attr));
bgp_attr_dup(&hattr, attr); /* hattr becomes a ghost attr */
/* hattr becomes a ghost attr */
hattr = *attr;
if (rmap) {
struct bgp_path_info path;
@ -1779,7 +1782,7 @@ static void vnc_import_bgp_exterior_add_route_it(
/* use local_pref from unicast route */
memset(&new_attr, 0, sizeof(struct attr));
bgp_attr_dup(&new_attr, bpi_interior->attr);
new_attr = *bpi_interior->attr;
if (info->attr->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) {
new_attr.local_pref =
@ -2104,7 +2107,7 @@ void vnc_import_bgp_exterior_add_route_interior(
/* use local_pref from unicast route */
memset(&new_attr, 0, sizeof(struct attr));
bgp_attr_dup(&new_attr, bpi_interior->attr);
new_attr = *bpi_interior->attr;
if (bpi_exterior
&& (bpi_exterior->attr->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))) {
@ -2240,7 +2243,7 @@ void vnc_import_bgp_exterior_add_route_interior(
/* use local_pref from unicast route */
memset(&new_attr, 0, sizeof(struct attr));
bgp_attr_dup(&new_attr, bpi_interior->attr);
new_attr = *bpi_interior->attr;
if (bpi_exterior
&& (bpi_exterior->attr->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))) {
@ -2360,7 +2363,7 @@ void vnc_import_bgp_exterior_add_route_interior(
/* use local_pref from unicast route */
memset(&new_attr, 0, sizeof(struct attr));
bgp_attr_dup(&new_attr, bpi_interior->attr);
new_attr = *bpi_interior->attr;
if (bpi_exterior
&& (bpi_exterior->attr->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))) {
@ -2550,7 +2553,7 @@ void vnc_import_bgp_exterior_del_route_interior(
/* use local_pref from unicast route */
memset(&new_attr, 0, sizeof(struct attr));
bgp_attr_dup(&new_attr, bpi->attr);
new_attr = *bpi->attr;
if (bpi_exterior
&& (bpi_exterior->attr->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))) {