Skip to content

Commit

Permalink
Merge pull request #12890 from pguibert6WIND/attr_cleaning_misc
Browse files Browse the repository at this point in the history
bgp attribute cleaning misc
  • Loading branch information
riw777 authored Mar 7, 2023
2 parents bafc9c5 + 6a38127 commit e1ee742
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 53 deletions.
88 changes: 44 additions & 44 deletions bgpd/bgp_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -810,55 +810,55 @@ bool attrhash_cmp(const void *p1, const void *p2)
&& attr1->med == attr2->med
&& attr1->local_pref == attr2->local_pref
&& attr1->rmap_change_flags == attr2->rmap_change_flags) {
if (attr1->aggregator_as == attr2->aggregator_as
&& attr1->aggregator_addr.s_addr
== attr2->aggregator_addr.s_addr
&& attr1->weight == attr2->weight
&& attr1->tag == attr2->tag
&& attr1->label_index == attr2->label_index
&& attr1->mp_nexthop_len == attr2->mp_nexthop_len
&& bgp_attr_get_ecommunity(attr1)
== bgp_attr_get_ecommunity(attr2)
&& bgp_attr_get_ipv6_ecommunity(attr1)
== bgp_attr_get_ipv6_ecommunity(attr2)
&& bgp_attr_get_lcommunity(attr1)
== bgp_attr_get_lcommunity(attr2)
&& bgp_attr_get_cluster(attr1)
== bgp_attr_get_cluster(attr2)
&& bgp_attr_get_transit(attr1)
== bgp_attr_get_transit(attr2)
&& bgp_attr_get_aigp_metric(attr1)
== bgp_attr_get_aigp_metric(attr2)
&& attr1->rmap_table_id == attr2->rmap_table_id
&& (attr1->encap_tunneltype == attr2->encap_tunneltype)
&& encap_same(attr1->encap_subtlvs, attr2->encap_subtlvs)
if (attr1->aggregator_as == attr2->aggregator_as &&
attr1->aggregator_addr.s_addr ==
attr2->aggregator_addr.s_addr &&
attr1->weight == attr2->weight &&
attr1->tag == attr2->tag &&
attr1->label_index == attr2->label_index &&
attr1->mp_nexthop_len == attr2->mp_nexthop_len &&
bgp_attr_get_ecommunity(attr1) ==
bgp_attr_get_ecommunity(attr2) &&
bgp_attr_get_ipv6_ecommunity(attr1) ==
bgp_attr_get_ipv6_ecommunity(attr2) &&
bgp_attr_get_lcommunity(attr1) ==
bgp_attr_get_lcommunity(attr2) &&
bgp_attr_get_cluster(attr1) ==
bgp_attr_get_cluster(attr2) &&
bgp_attr_get_transit(attr1) ==
bgp_attr_get_transit(attr2) &&
bgp_attr_get_aigp_metric(attr1) ==
bgp_attr_get_aigp_metric(attr2) &&
attr1->rmap_table_id == attr2->rmap_table_id &&
(attr1->encap_tunneltype == attr2->encap_tunneltype) &&
encap_same(attr1->encap_subtlvs, attr2->encap_subtlvs)
#ifdef ENABLE_BGP_VNC
&& encap_same(bgp_attr_get_vnc_subtlvs(attr1),
bgp_attr_get_vnc_subtlvs(attr2))
#endif
&& IPV6_ADDR_SAME(&attr1->mp_nexthop_global,
&attr2->mp_nexthop_global)
&& IPV6_ADDR_SAME(&attr1->mp_nexthop_local,
&attr2->mp_nexthop_local)
&& IPV4_ADDR_SAME(&attr1->mp_nexthop_global_in,
&attr2->mp_nexthop_global_in)
&& IPV4_ADDR_SAME(&attr1->originator_id,
&attr2->originator_id)
&& overlay_index_same(attr1, attr2)
&& !memcmp(&attr1->esi, &attr2->esi, sizeof(esi_t))
&& attr1->es_flags == attr2->es_flags
&& attr1->mm_sync_seqnum == attr2->mm_sync_seqnum
&& attr1->df_pref == attr2->df_pref
&& attr1->df_alg == attr2->df_alg
&& attr1->nh_ifindex == attr2->nh_ifindex
&& attr1->nh_lla_ifindex == attr2->nh_lla_ifindex
&& attr1->distance == attr2->distance
&& srv6_l3vpn_same(attr1->srv6_l3vpn, attr2->srv6_l3vpn)
&& srv6_vpn_same(attr1->srv6_vpn, attr2->srv6_vpn)
&& attr1->srte_color == attr2->srte_color
&& attr1->nh_type == attr2->nh_type
&& attr1->bh_type == attr2->bh_type
&& attr1->otc == attr2->otc)
&attr2->mp_nexthop_global) &&
IPV6_ADDR_SAME(&attr1->mp_nexthop_local,
&attr2->mp_nexthop_local) &&
IPV4_ADDR_SAME(&attr1->mp_nexthop_global_in,
&attr2->mp_nexthop_global_in) &&
IPV4_ADDR_SAME(&attr1->originator_id,
&attr2->originator_id) &&
overlay_index_same(attr1, attr2) &&
!memcmp(&attr1->esi, &attr2->esi, sizeof(esi_t)) &&
attr1->es_flags == attr2->es_flags &&
attr1->mm_sync_seqnum == attr2->mm_sync_seqnum &&
attr1->df_pref == attr2->df_pref &&
attr1->df_alg == attr2->df_alg &&
attr1->nh_ifindex == attr2->nh_ifindex &&
attr1->nh_lla_ifindex == attr2->nh_lla_ifindex &&
attr1->distance == attr2->distance &&
srv6_l3vpn_same(attr1->srv6_l3vpn, attr2->srv6_l3vpn) &&
srv6_vpn_same(attr1->srv6_vpn, attr2->srv6_vpn) &&
attr1->srte_color == attr2->srte_color &&
attr1->nh_type == attr2->nh_type &&
attr1->bh_type == attr2->bh_type &&
attr1->otc == attr2->otc)
return true;
}

Expand Down
23 changes: 14 additions & 9 deletions bgpd/bgp_evpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1837,6 +1837,7 @@ static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
struct bgp_path_info *tmp_pi;
struct bgp_path_info *local_pi;
struct attr *attr_new;
struct attr local_attr;
mpls_label_t label[BGP_MAX_LABELS];
uint32_t num_labels = 1;
int route_change = 1;
Expand Down Expand Up @@ -1870,13 +1871,15 @@ static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
add_mac_mobility_to_attr(seq, attr);

if (!local_pi) {
/* Add (or update) attribute to hash. */
attr_new = bgp_attr_intern(attr);
local_attr = *attr;

/* Extract MAC mobility sequence number, if any. */
attr_new->mm_seqnum =
bgp_attr_mac_mobility_seqnum(attr_new, &sticky);
attr_new->sticky = sticky;
local_attr.mm_seqnum =
bgp_attr_mac_mobility_seqnum(&local_attr, &sticky);
local_attr.sticky = sticky;

/* Add (or update) attribute to hash. */
attr_new = bgp_attr_intern(&local_attr);

/* Create new route with its attribute. */
tmp_pi = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0,
Expand Down Expand Up @@ -1952,14 +1955,16 @@ static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,

/* The attribute has changed. */
/* Add (or update) attribute to hash. */
attr_new = bgp_attr_intern(attr);
local_attr = *attr;
bgp_path_info_set_flag(dest, tmp_pi,
BGP_PATH_ATTR_CHANGED);

/* Extract MAC mobility sequence number, if any. */
attr_new->mm_seqnum =
bgp_attr_mac_mobility_seqnum(attr_new, &sticky);
attr_new->sticky = sticky;
local_attr.mm_seqnum = bgp_attr_mac_mobility_seqnum(
&local_attr, &sticky);
local_attr.sticky = sticky;

attr_new = bgp_attr_intern(&local_attr);

/* Restore route, if needed. */
if (CHECK_FLAG(tmp_pi->flags, BGP_PATH_REMOVED))
Expand Down
4 changes: 4 additions & 0 deletions bgpd/rfapi/vnc_import_bgp.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,8 @@ static void vnc_import_bgp_add_route_mode_plain(struct bgp *bgp,

if (ecom)
ecommunity_free(&ecom);
if (iattr)
bgp_attr_unintern(&iattr);
}

static void vnc_import_bgp_add_route_mode_nvegroup(
Expand Down Expand Up @@ -1030,6 +1032,8 @@ static void vnc_import_bgp_add_route_mode_nvegroup(

if (ecom)
ecommunity_free(&ecom);
if (iattr)
bgp_attr_unintern(&iattr);
}

static void vnc_import_bgp_del_route_mode_plain(struct bgp *bgp,
Expand Down

0 comments on commit e1ee742

Please sign in to comment.