forked from Mirror/frr
bgpd: Use bgp_attr_[sg]et_ecommunity for struct ecommunity
This is an extra work before moving attr->ecommunity to attra_extra struct. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
This commit is contained in:
parent
a89a78236c
commit
b53e67a389
|
@ -684,8 +684,8 @@ unsigned int attrhash_key_make(const void *p)
|
||||||
|
|
||||||
if (attr->lcommunity)
|
if (attr->lcommunity)
|
||||||
MIX(lcommunity_hash_make(attr->lcommunity));
|
MIX(lcommunity_hash_make(attr->lcommunity));
|
||||||
if (attr->ecommunity)
|
if (bgp_attr_get_ecommunity(attr))
|
||||||
MIX(ecommunity_hash_make(attr->ecommunity));
|
MIX(ecommunity_hash_make(bgp_attr_get_ecommunity(attr)));
|
||||||
if (bgp_attr_get_ipv6_ecommunity(attr))
|
if (bgp_attr_get_ipv6_ecommunity(attr))
|
||||||
MIX(ecommunity_hash_make(bgp_attr_get_ipv6_ecommunity(attr)));
|
MIX(ecommunity_hash_make(bgp_attr_get_ipv6_ecommunity(attr)));
|
||||||
if (bgp_attr_get_cluster(attr))
|
if (bgp_attr_get_cluster(attr))
|
||||||
|
@ -733,7 +733,8 @@ bool attrhash_cmp(const void *p1, const void *p2)
|
||||||
&& attr1->tag == attr2->tag
|
&& attr1->tag == attr2->tag
|
||||||
&& attr1->label_index == attr2->label_index
|
&& attr1->label_index == attr2->label_index
|
||||||
&& attr1->mp_nexthop_len == attr2->mp_nexthop_len
|
&& attr1->mp_nexthop_len == attr2->mp_nexthop_len
|
||||||
&& attr1->ecommunity == attr2->ecommunity
|
&& bgp_attr_get_ecommunity(attr1)
|
||||||
|
== bgp_attr_get_ecommunity(attr2)
|
||||||
&& bgp_attr_get_ipv6_ecommunity(attr1)
|
&& bgp_attr_get_ipv6_ecommunity(attr1)
|
||||||
== bgp_attr_get_ipv6_ecommunity(attr2)
|
== bgp_attr_get_ipv6_ecommunity(attr2)
|
||||||
&& attr1->lcommunity == attr2->lcommunity
|
&& attr1->lcommunity == attr2->lcommunity
|
||||||
|
@ -850,7 +851,8 @@ static void *bgp_attr_hash_alloc(void *p)
|
||||||
struct attr *bgp_attr_intern(struct attr *attr)
|
struct attr *bgp_attr_intern(struct attr *attr)
|
||||||
{
|
{
|
||||||
struct attr *find;
|
struct attr *find;
|
||||||
struct ecommunity *ecomm;
|
struct ecommunity *ecomm = NULL;
|
||||||
|
struct ecommunity *ipv6_ecomm = NULL;
|
||||||
|
|
||||||
/* Intern referenced strucutre. */
|
/* Intern referenced strucutre. */
|
||||||
if (attr->aspath) {
|
if (attr->aspath) {
|
||||||
|
@ -866,22 +868,23 @@ struct attr *bgp_attr_intern(struct attr *attr)
|
||||||
attr->community->refcnt++;
|
attr->community->refcnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attr->ecommunity) {
|
ecomm = bgp_attr_get_ecommunity(attr);
|
||||||
if (!attr->ecommunity->refcnt)
|
|
||||||
attr->ecommunity = ecommunity_intern(attr->ecommunity);
|
|
||||||
else
|
|
||||||
attr->ecommunity->refcnt++;
|
|
||||||
}
|
|
||||||
|
|
||||||
ecomm = bgp_attr_get_ipv6_ecommunity(attr);
|
|
||||||
if (ecomm) {
|
if (ecomm) {
|
||||||
if (!ecomm->refcnt)
|
if (!ecomm->refcnt)
|
||||||
bgp_attr_set_ipv6_ecommunity(attr,
|
bgp_attr_set_ecommunity(attr, ecommunity_intern(ecomm));
|
||||||
ecommunity_intern(ecomm));
|
|
||||||
else
|
else
|
||||||
ecomm->refcnt++;
|
ecomm->refcnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ipv6_ecomm = bgp_attr_get_ipv6_ecommunity(attr);
|
||||||
|
if (ipv6_ecomm) {
|
||||||
|
if (!ipv6_ecomm->refcnt)
|
||||||
|
bgp_attr_set_ipv6_ecommunity(
|
||||||
|
attr, ecommunity_intern(ipv6_ecomm));
|
||||||
|
else
|
||||||
|
ipv6_ecomm->refcnt++;
|
||||||
|
}
|
||||||
|
|
||||||
if (attr->lcommunity) {
|
if (attr->lcommunity) {
|
||||||
if (!attr->lcommunity->refcnt)
|
if (!attr->lcommunity->refcnt)
|
||||||
attr->lcommunity = lcommunity_intern(attr->lcommunity);
|
attr->lcommunity = lcommunity_intern(attr->lcommunity);
|
||||||
|
@ -1013,7 +1016,7 @@ struct attr *bgp_attr_aggregate_intern(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ecommunity) {
|
if (ecommunity) {
|
||||||
attr.ecommunity = ecommunity;
|
bgp_attr_set_ecommunity(&attr, ecommunity);
|
||||||
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1085,7 +1088,8 @@ struct attr *bgp_attr_aggregate_intern(
|
||||||
/* Unintern just the sub-components of the attr, but not the attr */
|
/* Unintern just the sub-components of the attr, but not the attr */
|
||||||
void bgp_attr_unintern_sub(struct attr *attr)
|
void bgp_attr_unintern_sub(struct attr *attr)
|
||||||
{
|
{
|
||||||
struct ecommunity *ecomm;
|
struct ecommunity *ecomm = NULL;
|
||||||
|
struct ecommunity *ipv6_ecomm = NULL;
|
||||||
struct cluster_list *cluster;
|
struct cluster_list *cluster;
|
||||||
|
|
||||||
/* aspath refcount shoud be decrement. */
|
/* aspath refcount shoud be decrement. */
|
||||||
|
@ -1097,11 +1101,13 @@ void bgp_attr_unintern_sub(struct attr *attr)
|
||||||
community_unintern(&attr->community);
|
community_unintern(&attr->community);
|
||||||
UNSET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES));
|
UNSET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES));
|
||||||
|
|
||||||
ecommunity_unintern(&attr->ecommunity);
|
ecomm = bgp_attr_get_ecommunity(attr);
|
||||||
UNSET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES));
|
|
||||||
|
|
||||||
ecomm = bgp_attr_get_ipv6_ecommunity(attr);
|
|
||||||
ecommunity_unintern(&ecomm);
|
ecommunity_unintern(&ecomm);
|
||||||
|
UNSET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES));
|
||||||
|
bgp_attr_set_ecommunity(attr, NULL);
|
||||||
|
|
||||||
|
ipv6_ecomm = bgp_attr_get_ipv6_ecommunity(attr);
|
||||||
|
ecommunity_unintern(&ipv6_ecomm);
|
||||||
UNSET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_IPV6_EXT_COMMUNITIES));
|
UNSET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_IPV6_EXT_COMMUNITIES));
|
||||||
bgp_attr_set_ipv6_ecommunity(attr, NULL);
|
bgp_attr_set_ipv6_ecommunity(attr, NULL);
|
||||||
|
|
||||||
|
@ -1155,14 +1161,16 @@ void bgp_attr_unintern_sub(struct attr *attr)
|
||||||
*/
|
*/
|
||||||
void bgp_attr_undup(struct attr *new, struct attr *old)
|
void bgp_attr_undup(struct attr *new, struct attr *old)
|
||||||
{
|
{
|
||||||
|
struct ecommunity *ecomm = bgp_attr_get_ecommunity(new);
|
||||||
|
|
||||||
if (new->aspath != old->aspath)
|
if (new->aspath != old->aspath)
|
||||||
aspath_free(new->aspath);
|
aspath_free(new->aspath);
|
||||||
|
|
||||||
if (new->community != old->community)
|
if (new->community != old->community)
|
||||||
community_free(&new->community);
|
community_free(&new->community);
|
||||||
|
|
||||||
if (new->ecommunity != old->ecommunity)
|
if (ecomm != bgp_attr_get_ecommunity(old))
|
||||||
ecommunity_free(&new->ecommunity);
|
ecommunity_free(&ecomm);
|
||||||
|
|
||||||
if (new->lcommunity != old->lcommunity)
|
if (new->lcommunity != old->lcommunity)
|
||||||
lcommunity_free(&new->lcommunity);
|
lcommunity_free(&new->lcommunity);
|
||||||
|
@ -1205,6 +1213,7 @@ void bgp_attr_unintern(struct attr **pattr)
|
||||||
void bgp_attr_flush(struct attr *attr)
|
void bgp_attr_flush(struct attr *attr)
|
||||||
{
|
{
|
||||||
struct ecommunity *ecomm;
|
struct ecommunity *ecomm;
|
||||||
|
struct ecommunity *ipv6_ecomm;
|
||||||
struct cluster_list *cluster;
|
struct cluster_list *cluster;
|
||||||
|
|
||||||
if (attr->aspath && !attr->aspath->refcnt) {
|
if (attr->aspath && !attr->aspath->refcnt) {
|
||||||
|
@ -1213,11 +1222,13 @@ void bgp_attr_flush(struct attr *attr)
|
||||||
}
|
}
|
||||||
if (attr->community && !attr->community->refcnt)
|
if (attr->community && !attr->community->refcnt)
|
||||||
community_free(&attr->community);
|
community_free(&attr->community);
|
||||||
if (attr->ecommunity && !attr->ecommunity->refcnt)
|
ecomm = bgp_attr_get_ecommunity(attr);
|
||||||
ecommunity_free(&attr->ecommunity);
|
|
||||||
ecomm = bgp_attr_get_ipv6_ecommunity(attr);
|
|
||||||
if (ecomm && !ecomm->refcnt)
|
if (ecomm && !ecomm->refcnt)
|
||||||
ecommunity_free(&ecomm);
|
ecommunity_free(&ecomm);
|
||||||
|
bgp_attr_set_ecommunity(attr, NULL);
|
||||||
|
ipv6_ecomm = bgp_attr_get_ipv6_ecommunity(attr);
|
||||||
|
if (ipv6_ecomm && !ipv6_ecomm->refcnt)
|
||||||
|
ecommunity_free(&ipv6_ecomm);
|
||||||
bgp_attr_set_ipv6_ecommunity(attr, NULL);
|
bgp_attr_set_ipv6_ecommunity(attr, NULL);
|
||||||
if (attr->lcommunity && !attr->lcommunity->refcnt)
|
if (attr->lcommunity && !attr->lcommunity->refcnt)
|
||||||
lcommunity_free(&attr->lcommunity);
|
lcommunity_free(&attr->lcommunity);
|
||||||
|
@ -2325,25 +2336,27 @@ bgp_attr_ext_communities(struct bgp_attr_parser_args *args)
|
||||||
const bgp_size_t length = args->length;
|
const bgp_size_t length = args->length;
|
||||||
uint8_t sticky = 0;
|
uint8_t sticky = 0;
|
||||||
bool proxy = false;
|
bool proxy = false;
|
||||||
|
struct ecommunity *ecomm;
|
||||||
|
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
attr->ecommunity = NULL;
|
bgp_attr_set_ecommunity(attr, NULL);
|
||||||
/* Empty extcomm doesn't seem to be invalid per se */
|
/* Empty extcomm doesn't seem to be invalid per se */
|
||||||
return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_OPT_ATTR_ERR,
|
return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_OPT_ATTR_ERR,
|
||||||
args->total);
|
args->total);
|
||||||
}
|
}
|
||||||
|
|
||||||
attr->ecommunity = ecommunity_parse(
|
ecomm = ecommunity_parse(
|
||||||
stream_pnt(peer->curr), length,
|
stream_pnt(peer->curr), length,
|
||||||
CHECK_FLAG(peer->flags,
|
CHECK_FLAG(peer->flags,
|
||||||
PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE));
|
PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE));
|
||||||
|
bgp_attr_set_ecommunity(attr, ecomm);
|
||||||
/* XXX: fix ecommunity_parse to use stream API */
|
/* XXX: fix ecommunity_parse to use stream API */
|
||||||
stream_forward_getp(peer->curr, length);
|
stream_forward_getp(peer->curr, length);
|
||||||
|
|
||||||
/* The Extended Community attribute SHALL be considered malformed if
|
/* The Extended Community attribute SHALL be considered malformed if
|
||||||
* its length is not a non-zero multiple of 8.
|
* its length is not a non-zero multiple of 8.
|
||||||
*/
|
*/
|
||||||
if (!attr->ecommunity)
|
if (!bgp_attr_get_ecommunity(attr))
|
||||||
return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_OPT_ATTR_ERR,
|
return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_OPT_ATTR_ERR,
|
||||||
args->total);
|
args->total);
|
||||||
|
|
||||||
|
@ -2384,7 +2397,8 @@ bgp_attr_ext_communities(struct bgp_attr_parser_args *args)
|
||||||
(bgp_encap_types *)&attr->encap_tunneltype);
|
(bgp_encap_types *)&attr->encap_tunneltype);
|
||||||
|
|
||||||
/* Extract link bandwidth, if any. */
|
/* Extract link bandwidth, if any. */
|
||||||
(void)ecommunity_linkbw_present(attr->ecommunity, &attr->link_bw);
|
(void)ecommunity_linkbw_present(bgp_attr_get_ecommunity(attr),
|
||||||
|
&attr->link_bw);
|
||||||
|
|
||||||
return BGP_ATTR_PARSE_PROCEED;
|
return BGP_ATTR_PARSE_PROCEED;
|
||||||
}
|
}
|
||||||
|
@ -3584,7 +3598,7 @@ void bgp_attr_extcom_tunnel_type(struct attr *attr,
|
||||||
if (!attr)
|
if (!attr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ecom = attr->ecommunity;
|
ecom = bgp_attr_get_ecommunity(attr);
|
||||||
if (!ecom || !ecom->size)
|
if (!ecom || !ecom->size)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -4185,32 +4199,33 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
|
||||||
/* Extended Communities attribute. */
|
/* Extended Communities attribute. */
|
||||||
if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)
|
if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)
|
||||||
&& (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))) {
|
&& (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))) {
|
||||||
|
struct ecommunity *ecomm = bgp_attr_get_ecommunity(attr);
|
||||||
|
|
||||||
if (peer->sort == BGP_PEER_IBGP
|
if (peer->sort == BGP_PEER_IBGP
|
||||||
|| peer->sort == BGP_PEER_CONFED) {
|
|| peer->sort == BGP_PEER_CONFED) {
|
||||||
if (attr->ecommunity->size * 8 > 255) {
|
if (ecomm->size * 8 > 255) {
|
||||||
stream_putc(s,
|
stream_putc(s,
|
||||||
BGP_ATTR_FLAG_OPTIONAL
|
BGP_ATTR_FLAG_OPTIONAL
|
||||||
| BGP_ATTR_FLAG_TRANS
|
| BGP_ATTR_FLAG_TRANS
|
||||||
| BGP_ATTR_FLAG_EXTLEN);
|
| BGP_ATTR_FLAG_EXTLEN);
|
||||||
stream_putc(s, BGP_ATTR_EXT_COMMUNITIES);
|
stream_putc(s, BGP_ATTR_EXT_COMMUNITIES);
|
||||||
stream_putw(s, attr->ecommunity->size * 8);
|
stream_putw(s, ecomm->size * 8);
|
||||||
} else {
|
} else {
|
||||||
stream_putc(s,
|
stream_putc(s,
|
||||||
BGP_ATTR_FLAG_OPTIONAL
|
BGP_ATTR_FLAG_OPTIONAL
|
||||||
| BGP_ATTR_FLAG_TRANS);
|
| BGP_ATTR_FLAG_TRANS);
|
||||||
stream_putc(s, BGP_ATTR_EXT_COMMUNITIES);
|
stream_putc(s, BGP_ATTR_EXT_COMMUNITIES);
|
||||||
stream_putc(s, attr->ecommunity->size * 8);
|
stream_putc(s, ecomm->size * 8);
|
||||||
}
|
}
|
||||||
stream_put(s, attr->ecommunity->val,
|
stream_put(s, ecomm->val, ecomm->size * 8);
|
||||||
attr->ecommunity->size * 8);
|
|
||||||
} else {
|
} else {
|
||||||
uint8_t *pnt;
|
uint8_t *pnt;
|
||||||
int tbit;
|
int tbit;
|
||||||
int ecom_tr_size = 0;
|
int ecom_tr_size = 0;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
for (i = 0; i < attr->ecommunity->size; i++) {
|
for (i = 0; i < ecomm->size; i++) {
|
||||||
pnt = attr->ecommunity->val + (i * 8);
|
pnt = ecomm->val + (i * 8);
|
||||||
tbit = *pnt;
|
tbit = *pnt;
|
||||||
|
|
||||||
if (CHECK_FLAG(tbit,
|
if (CHECK_FLAG(tbit,
|
||||||
|
@ -4240,8 +4255,8 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
|
||||||
stream_putc(s, ecom_tr_size * 8);
|
stream_putc(s, ecom_tr_size * 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < attr->ecommunity->size; i++) {
|
for (i = 0; i < ecomm->size; i++) {
|
||||||
pnt = attr->ecommunity->val + (i * 8);
|
pnt = ecomm->val + (i * 8);
|
||||||
tbit = *pnt;
|
tbit = *pnt;
|
||||||
|
|
||||||
if (CHECK_FLAG(
|
if (CHECK_FLAG(
|
||||||
|
|
|
@ -514,6 +514,18 @@ static inline void bgp_attr_set_pmsi_tnl_type(struct attr *attr,
|
||||||
attr->pmsi_tnl_type = pmsi_tnl_type;
|
attr->pmsi_tnl_type = pmsi_tnl_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct ecommunity *
|
||||||
|
bgp_attr_get_ecommunity(const struct attr *attr)
|
||||||
|
{
|
||||||
|
return attr->ecommunity;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void bgp_attr_set_ecommunity(struct attr *attr,
|
||||||
|
struct ecommunity *ecomm)
|
||||||
|
{
|
||||||
|
attr->ecommunity = ecomm;
|
||||||
|
}
|
||||||
|
|
||||||
static inline struct ecommunity *
|
static inline struct ecommunity *
|
||||||
bgp_attr_get_ipv6_ecommunity(const struct attr *attr)
|
bgp_attr_get_ipv6_ecommunity(const struct attr *attr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,15 +47,16 @@ bool bgp_route_evpn_same(const struct bgp_route_evpn *e1,
|
||||||
void bgp_add_routermac_ecom(struct attr *attr, struct ethaddr *routermac)
|
void bgp_add_routermac_ecom(struct attr *attr, struct ethaddr *routermac)
|
||||||
{
|
{
|
||||||
struct ecommunity_val routermac_ecom;
|
struct ecommunity_val routermac_ecom;
|
||||||
|
struct ecommunity *ecomm = bgp_attr_get_ecommunity(attr);
|
||||||
|
|
||||||
memset(&routermac_ecom, 0, sizeof(struct ecommunity_val));
|
memset(&routermac_ecom, 0, sizeof(struct ecommunity_val));
|
||||||
routermac_ecom.val[0] = ECOMMUNITY_ENCODE_EVPN;
|
routermac_ecom.val[0] = ECOMMUNITY_ENCODE_EVPN;
|
||||||
routermac_ecom.val[1] = ECOMMUNITY_EVPN_SUBTYPE_ROUTERMAC;
|
routermac_ecom.val[1] = ECOMMUNITY_EVPN_SUBTYPE_ROUTERMAC;
|
||||||
memcpy(&routermac_ecom.val[2], routermac->octet, ETH_ALEN);
|
memcpy(&routermac_ecom.val[2], routermac->octet, ETH_ALEN);
|
||||||
if (!attr->ecommunity)
|
if (!ecomm)
|
||||||
attr->ecommunity = ecommunity_new();
|
bgp_attr_set_ecommunity(attr, ecommunity_new());
|
||||||
ecommunity_add_val(attr->ecommunity, &routermac_ecom, false, false);
|
ecommunity_add_val(ecomm, &routermac_ecom, false, false);
|
||||||
ecommunity_str(attr->ecommunity);
|
ecommunity_str(ecomm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* converts to an esi
|
/* converts to an esi
|
||||||
|
@ -100,7 +101,7 @@ bool bgp_attr_rmac(struct attr *attr, struct ethaddr *rmac)
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
struct ecommunity *ecom;
|
struct ecommunity *ecom;
|
||||||
|
|
||||||
ecom = attr->ecommunity;
|
ecom = bgp_attr_get_ecommunity(attr);
|
||||||
if (!ecom || !ecom->size)
|
if (!ecom || !ecom->size)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -132,7 +133,7 @@ uint8_t bgp_attr_default_gw(struct attr *attr)
|
||||||
struct ecommunity *ecom;
|
struct ecommunity *ecom;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
ecom = attr->ecommunity;
|
ecom = bgp_attr_get_ecommunity(attr);
|
||||||
if (!ecom || !ecom->size)
|
if (!ecom || !ecom->size)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -165,7 +166,7 @@ uint16_t bgp_attr_df_pref_from_ec(struct attr *attr, uint8_t *alg)
|
||||||
uint16_t df_pref = 0;
|
uint16_t df_pref = 0;
|
||||||
|
|
||||||
*alg = EVPN_MH_DF_ALG_SERVICE_CARVING;
|
*alg = EVPN_MH_DF_ALG_SERVICE_CARVING;
|
||||||
ecom = attr->ecommunity;
|
ecom = bgp_attr_get_ecommunity(attr);
|
||||||
if (!ecom || !ecom->size)
|
if (!ecom || !ecom->size)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -201,7 +202,7 @@ uint32_t bgp_attr_mac_mobility_seqnum(struct attr *attr, uint8_t *sticky)
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
uint8_t flags = 0;
|
uint8_t flags = 0;
|
||||||
|
|
||||||
ecom = attr->ecommunity;
|
ecom = bgp_attr_get_ecommunity(attr);
|
||||||
if (!ecom || !ecom->size)
|
if (!ecom || !ecom->size)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -248,7 +249,7 @@ void bgp_attr_evpn_na_flag(struct attr *attr,
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
uint8_t val;
|
uint8_t val;
|
||||||
|
|
||||||
ecom = attr->ecommunity;
|
ecom = bgp_attr_get_ecommunity(attr);
|
||||||
if (!ecom || !ecom->size)
|
if (!ecom || !ecom->size)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -420,7 +420,8 @@ bool bgp_dump_attr(struct attr *attr, char *buf, size_t size)
|
||||||
|
|
||||||
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)))
|
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)))
|
||||||
snprintf(buf + strlen(buf), size - strlen(buf),
|
snprintf(buf + strlen(buf), size - strlen(buf),
|
||||||
", extcommunity %s", ecommunity_str(attr->ecommunity));
|
", extcommunity %s",
|
||||||
|
ecommunity_str(bgp_attr_get_ecommunity(attr)));
|
||||||
|
|
||||||
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)))
|
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)))
|
||||||
snprintf(buf + strlen(buf), size - strlen(buf),
|
snprintf(buf + strlen(buf), size - strlen(buf),
|
||||||
|
|
|
@ -736,26 +736,28 @@ static void build_evpn_type5_route_extcomm(struct bgp *bgp_vrf,
|
||||||
ecom_encap.val = (uint8_t *)eval.val;
|
ecom_encap.val = (uint8_t *)eval.val;
|
||||||
|
|
||||||
/* Add Encap */
|
/* Add Encap */
|
||||||
if (attr->ecommunity) {
|
if (bgp_attr_get_ecommunity(attr)) {
|
||||||
old_ecom = attr->ecommunity;
|
old_ecom = bgp_attr_get_ecommunity(attr);
|
||||||
ecom = ecommunity_merge(ecommunity_dup(old_ecom), &ecom_encap);
|
ecom = ecommunity_merge(ecommunity_dup(old_ecom), &ecom_encap);
|
||||||
if (!old_ecom->refcnt)
|
if (!old_ecom->refcnt)
|
||||||
ecommunity_free(&old_ecom);
|
ecommunity_free(&old_ecom);
|
||||||
} else
|
} else
|
||||||
ecom = ecommunity_dup(&ecom_encap);
|
ecom = ecommunity_dup(&ecom_encap);
|
||||||
attr->ecommunity = ecom;
|
bgp_attr_set_ecommunity(attr, ecom);
|
||||||
attr->encap_tunneltype = tnl_type;
|
attr->encap_tunneltype = tnl_type;
|
||||||
|
|
||||||
/* Add the export RTs for L3VNI/VRF */
|
/* Add the export RTs for L3VNI/VRF */
|
||||||
vrf_export_rtl = bgp_vrf->vrf_export_rtl;
|
vrf_export_rtl = bgp_vrf->vrf_export_rtl;
|
||||||
for (ALL_LIST_ELEMENTS(vrf_export_rtl, node, nnode, ecom))
|
for (ALL_LIST_ELEMENTS(vrf_export_rtl, node, nnode, ecom))
|
||||||
attr->ecommunity =
|
bgp_attr_set_ecommunity(
|
||||||
ecommunity_merge(attr->ecommunity, ecom);
|
attr,
|
||||||
|
ecommunity_merge(bgp_attr_get_ecommunity(attr), ecom));
|
||||||
|
|
||||||
/* add the router mac extended community */
|
/* add the router mac extended community */
|
||||||
if (!is_zero_mac(&attr->rmac)) {
|
if (!is_zero_mac(&attr->rmac)) {
|
||||||
encode_rmac_extcomm(&eval_rmac, &attr->rmac);
|
encode_rmac_extcomm(&eval_rmac, &attr->rmac);
|
||||||
ecommunity_add_val(attr->ecommunity, &eval_rmac, true, true);
|
ecommunity_add_val(bgp_attr_get_ecommunity(attr), &eval_rmac,
|
||||||
|
true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
||||||
|
@ -800,12 +802,14 @@ static void build_evpn_route_extcomm(struct bgpevpn *vpn, struct attr *attr,
|
||||||
ecom_encap.val = (uint8_t *)eval.val;
|
ecom_encap.val = (uint8_t *)eval.val;
|
||||||
|
|
||||||
/* Add Encap */
|
/* Add Encap */
|
||||||
attr->ecommunity = ecommunity_dup(&ecom_encap);
|
bgp_attr_set_ecommunity(attr, ecommunity_dup(&ecom_encap));
|
||||||
attr->encap_tunneltype = tnl_type;
|
attr->encap_tunneltype = tnl_type;
|
||||||
|
|
||||||
/* Add the export RTs for L2VNI */
|
/* Add the export RTs for L2VNI */
|
||||||
for (ALL_LIST_ELEMENTS(vpn->export_rtl, node, nnode, ecom))
|
for (ALL_LIST_ELEMENTS(vpn->export_rtl, node, nnode, ecom))
|
||||||
attr->ecommunity = ecommunity_merge(attr->ecommunity, ecom);
|
bgp_attr_set_ecommunity(
|
||||||
|
attr,
|
||||||
|
ecommunity_merge(bgp_attr_get_ecommunity(attr), ecom));
|
||||||
|
|
||||||
/* Add the export RTs for L3VNI if told to - caller determines
|
/* Add the export RTs for L3VNI if told to - caller determines
|
||||||
* when this should be done.
|
* when this should be done.
|
||||||
|
@ -815,8 +819,11 @@ static void build_evpn_route_extcomm(struct bgpevpn *vpn, struct attr *attr,
|
||||||
if (vrf_export_rtl && !list_isempty(vrf_export_rtl)) {
|
if (vrf_export_rtl && !list_isempty(vrf_export_rtl)) {
|
||||||
for (ALL_LIST_ELEMENTS(vrf_export_rtl, node, nnode,
|
for (ALL_LIST_ELEMENTS(vrf_export_rtl, node, nnode,
|
||||||
ecom))
|
ecom))
|
||||||
attr->ecommunity = ecommunity_merge(
|
bgp_attr_set_ecommunity(
|
||||||
attr->ecommunity, ecom);
|
attr,
|
||||||
|
ecommunity_merge(
|
||||||
|
bgp_attr_get_ecommunity(attr),
|
||||||
|
ecom));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -828,14 +835,16 @@ static void build_evpn_route_extcomm(struct bgpevpn *vpn, struct attr *attr,
|
||||||
ecom_sticky.size = 1;
|
ecom_sticky.size = 1;
|
||||||
ecom_sticky.unit_size = ECOMMUNITY_SIZE;
|
ecom_sticky.unit_size = ECOMMUNITY_SIZE;
|
||||||
ecom_sticky.val = (uint8_t *)eval_sticky.val;
|
ecom_sticky.val = (uint8_t *)eval_sticky.val;
|
||||||
attr->ecommunity =
|
bgp_attr_set_ecommunity(
|
||||||
ecommunity_merge(attr->ecommunity, &ecom_sticky);
|
attr, ecommunity_merge(bgp_attr_get_ecommunity(attr),
|
||||||
|
&ecom_sticky));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add RMAC, if told to. */
|
/* Add RMAC, if told to. */
|
||||||
if (add_l3_ecomm) {
|
if (add_l3_ecomm) {
|
||||||
encode_rmac_extcomm(&eval_rmac, &attr->rmac);
|
encode_rmac_extcomm(&eval_rmac, &attr->rmac);
|
||||||
ecommunity_add_val(attr->ecommunity, &eval_rmac, true, true);
|
ecommunity_add_val(bgp_attr_get_ecommunity(attr), &eval_rmac,
|
||||||
|
true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add default gateway, if needed. */
|
/* Add default gateway, if needed. */
|
||||||
|
@ -845,8 +854,9 @@ static void build_evpn_route_extcomm(struct bgpevpn *vpn, struct attr *attr,
|
||||||
ecom_default_gw.size = 1;
|
ecom_default_gw.size = 1;
|
||||||
ecom_default_gw.unit_size = ECOMMUNITY_SIZE;
|
ecom_default_gw.unit_size = ECOMMUNITY_SIZE;
|
||||||
ecom_default_gw.val = (uint8_t *)eval_default_gw.val;
|
ecom_default_gw.val = (uint8_t *)eval_default_gw.val;
|
||||||
attr->ecommunity =
|
bgp_attr_set_ecommunity(
|
||||||
ecommunity_merge(attr->ecommunity, &ecom_default_gw);
|
attr, ecommunity_merge(bgp_attr_get_ecommunity(attr),
|
||||||
|
&ecom_default_gw));
|
||||||
}
|
}
|
||||||
|
|
||||||
proxy = !!(attr->es_flags & ATTR_ES_PROXY_ADVERT);
|
proxy = !!(attr->es_flags & ATTR_ES_PROXY_ADVERT);
|
||||||
|
@ -856,8 +866,9 @@ static void build_evpn_route_extcomm(struct bgpevpn *vpn, struct attr *attr,
|
||||||
ecom_na.size = 1;
|
ecom_na.size = 1;
|
||||||
ecom_na.unit_size = ECOMMUNITY_SIZE;
|
ecom_na.unit_size = ECOMMUNITY_SIZE;
|
||||||
ecom_na.val = (uint8_t *)eval_na.val;
|
ecom_na.val = (uint8_t *)eval_na.val;
|
||||||
attr->ecommunity = ecommunity_merge(attr->ecommunity,
|
bgp_attr_set_ecommunity(
|
||||||
&ecom_na);
|
attr, ecommunity_merge(bgp_attr_get_ecommunity(attr),
|
||||||
|
&ecom_na));
|
||||||
}
|
}
|
||||||
|
|
||||||
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
||||||
|
@ -875,6 +886,7 @@ static void add_mac_mobility_to_attr(uint32_t seq_num, struct attr *attr)
|
||||||
uint8_t *pnt;
|
uint8_t *pnt;
|
||||||
int type = 0;
|
int type = 0;
|
||||||
int sub_type = 0;
|
int sub_type = 0;
|
||||||
|
struct ecommunity *ecomm = bgp_attr_get_ecommunity(attr);
|
||||||
|
|
||||||
/* Build MM */
|
/* Build MM */
|
||||||
encode_mac_mobility_extcomm(0, seq_num, &eval);
|
encode_mac_mobility_extcomm(0, seq_num, &eval);
|
||||||
|
@ -882,10 +894,9 @@ static void add_mac_mobility_to_attr(uint32_t seq_num, struct attr *attr)
|
||||||
/* Find current MM ecommunity */
|
/* Find current MM ecommunity */
|
||||||
ecom_val_ptr = NULL;
|
ecom_val_ptr = NULL;
|
||||||
|
|
||||||
if (attr->ecommunity) {
|
if (ecomm) {
|
||||||
for (i = 0; i < attr->ecommunity->size; i++) {
|
for (i = 0; i < ecomm->size; i++) {
|
||||||
pnt = attr->ecommunity->val +
|
pnt = ecomm->val + (i * ecomm->unit_size);
|
||||||
(i * attr->ecommunity->unit_size);
|
|
||||||
type = *pnt++;
|
type = *pnt++;
|
||||||
sub_type = *pnt++;
|
sub_type = *pnt++;
|
||||||
|
|
||||||
|
@ -893,8 +904,7 @@ static void add_mac_mobility_to_attr(uint32_t seq_num, struct attr *attr)
|
||||||
&& sub_type
|
&& sub_type
|
||||||
== ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY) {
|
== ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY) {
|
||||||
ecom_val_ptr =
|
ecom_val_ptr =
|
||||||
(attr->ecommunity->val +
|
(ecomm->val + (i * ecomm->unit_size));
|
||||||
(i * attr->ecommunity->unit_size));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -902,8 +912,7 @@ static void add_mac_mobility_to_attr(uint32_t seq_num, struct attr *attr)
|
||||||
|
|
||||||
/* Update the existing MM ecommunity */
|
/* Update the existing MM ecommunity */
|
||||||
if (ecom_val_ptr) {
|
if (ecom_val_ptr) {
|
||||||
memcpy(ecom_val_ptr, eval.val, sizeof(char)
|
memcpy(ecom_val_ptr, eval.val, sizeof(char) * ecomm->unit_size);
|
||||||
* attr->ecommunity->unit_size);
|
|
||||||
}
|
}
|
||||||
/* Add MM to existing */
|
/* Add MM to existing */
|
||||||
else {
|
else {
|
||||||
|
@ -912,11 +921,12 @@ static void add_mac_mobility_to_attr(uint32_t seq_num, struct attr *attr)
|
||||||
ecom_tmp.unit_size = ECOMMUNITY_SIZE;
|
ecom_tmp.unit_size = ECOMMUNITY_SIZE;
|
||||||
ecom_tmp.val = (uint8_t *)eval.val;
|
ecom_tmp.val = (uint8_t *)eval.val;
|
||||||
|
|
||||||
if (attr->ecommunity)
|
if (ecomm)
|
||||||
attr->ecommunity =
|
bgp_attr_set_ecommunity(
|
||||||
ecommunity_merge(attr->ecommunity, &ecom_tmp);
|
attr, ecommunity_merge(ecomm, &ecom_tmp));
|
||||||
else
|
else
|
||||||
attr->ecommunity = ecommunity_dup(&ecom_tmp);
|
bgp_attr_set_ecommunity(attr,
|
||||||
|
ecommunity_dup(&ecom_tmp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2823,7 +2833,7 @@ static int is_route_matching_for_vrf(struct bgp *bgp_vrf,
|
||||||
if (!(attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)))
|
if (!(attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ecom = attr->ecommunity;
|
ecom = bgp_attr_get_ecommunity(attr);
|
||||||
if (!ecom || !ecom->size)
|
if (!ecom || !ecom->size)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -2890,7 +2900,7 @@ static int is_route_matching_for_vni(struct bgp *bgp, struct bgpevpn *vpn,
|
||||||
if (!(attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)))
|
if (!(attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ecom = attr->ecommunity;
|
ecom = bgp_attr_get_ecommunity(attr);
|
||||||
if (!ecom || !ecom->size)
|
if (!ecom || !ecom->size)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -3374,7 +3384,7 @@ static int bgp_evpn_install_uninstall_table(struct bgp *bgp, afi_t afi,
|
||||||
if (evp->prefix.route_type == BGP_EVPN_AD_ROUTE)
|
if (evp->prefix.route_type == BGP_EVPN_AD_ROUTE)
|
||||||
evp = evpn_type1_prefix_vni_copy(&ad_evp, evp, attr->nexthop);
|
evp = evpn_type1_prefix_vni_copy(&ad_evp, evp, attr->nexthop);
|
||||||
|
|
||||||
ecom = attr->ecommunity;
|
ecom = bgp_attr_get_ecommunity(attr);
|
||||||
if (!ecom || !ecom->size)
|
if (!ecom || !ecom->size)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
|
@ -598,7 +598,7 @@ static void bgp_evpn_type4_route_extcomm_build(struct bgp_evpn_es *es,
|
||||||
ecom_encap.size = 1;
|
ecom_encap.size = 1;
|
||||||
ecom_encap.unit_size = ECOMMUNITY_SIZE;
|
ecom_encap.unit_size = ECOMMUNITY_SIZE;
|
||||||
ecom_encap.val = (uint8_t *)eval.val;
|
ecom_encap.val = (uint8_t *)eval.val;
|
||||||
attr->ecommunity = ecommunity_dup(&ecom_encap);
|
bgp_attr_set_ecommunity(attr, ecommunity_dup(&ecom_encap));
|
||||||
|
|
||||||
/* ES import RT */
|
/* ES import RT */
|
||||||
memset(&mac, 0, sizeof(struct ethaddr));
|
memset(&mac, 0, sizeof(struct ethaddr));
|
||||||
|
@ -608,15 +608,18 @@ static void bgp_evpn_type4_route_extcomm_build(struct bgp_evpn_es *es,
|
||||||
ecom_es_rt.size = 1;
|
ecom_es_rt.size = 1;
|
||||||
ecom_es_rt.unit_size = ECOMMUNITY_SIZE;
|
ecom_es_rt.unit_size = ECOMMUNITY_SIZE;
|
||||||
ecom_es_rt.val = (uint8_t *)eval_es_rt.val;
|
ecom_es_rt.val = (uint8_t *)eval_es_rt.val;
|
||||||
attr->ecommunity =
|
bgp_attr_set_ecommunity(
|
||||||
ecommunity_merge(attr->ecommunity, &ecom_es_rt);
|
attr,
|
||||||
|
ecommunity_merge(bgp_attr_get_ecommunity(attr), &ecom_es_rt));
|
||||||
|
|
||||||
/* DF election extended community */
|
/* DF election extended community */
|
||||||
memset(&ecom_df, 0, sizeof(ecom_df));
|
memset(&ecom_df, 0, sizeof(ecom_df));
|
||||||
encode_df_elect_extcomm(&eval_df, es->df_pref);
|
encode_df_elect_extcomm(&eval_df, es->df_pref);
|
||||||
ecom_df.size = 1;
|
ecom_df.size = 1;
|
||||||
ecom_df.val = (uint8_t *)eval_df.val;
|
ecom_df.val = (uint8_t *)eval_df.val;
|
||||||
attr->ecommunity = ecommunity_merge(attr->ecommunity, &ecom_df);
|
bgp_attr_set_ecommunity(
|
||||||
|
attr,
|
||||||
|
ecommunity_merge(bgp_attr_get_ecommunity(attr), &ecom_df));
|
||||||
|
|
||||||
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
||||||
}
|
}
|
||||||
|
@ -861,7 +864,7 @@ static void bgp_evpn_type1_es_route_extcomm_build(struct bgp_evpn_es *es,
|
||||||
ecom_encap.size = 1;
|
ecom_encap.size = 1;
|
||||||
ecom_encap.unit_size = ECOMMUNITY_SIZE;
|
ecom_encap.unit_size = ECOMMUNITY_SIZE;
|
||||||
ecom_encap.val = (uint8_t *)eval.val;
|
ecom_encap.val = (uint8_t *)eval.val;
|
||||||
attr->ecommunity = ecommunity_dup(&ecom_encap);
|
bgp_attr_set_ecommunity(attr, ecommunity_dup(&ecom_encap));
|
||||||
|
|
||||||
/* ESI label */
|
/* ESI label */
|
||||||
encode_esi_label_extcomm(&eval_esi_label,
|
encode_esi_label_extcomm(&eval_esi_label,
|
||||||
|
@ -869,8 +872,9 @@ static void bgp_evpn_type1_es_route_extcomm_build(struct bgp_evpn_es *es,
|
||||||
ecom_esi_label.size = 1;
|
ecom_esi_label.size = 1;
|
||||||
ecom_esi_label.unit_size = ECOMMUNITY_SIZE;
|
ecom_esi_label.unit_size = ECOMMUNITY_SIZE;
|
||||||
ecom_esi_label.val = (uint8_t *)eval_esi_label.val;
|
ecom_esi_label.val = (uint8_t *)eval_esi_label.val;
|
||||||
attr->ecommunity =
|
bgp_attr_set_ecommunity(attr,
|
||||||
ecommunity_merge(attr->ecommunity, &ecom_esi_label);
|
ecommunity_merge(bgp_attr_get_ecommunity(attr),
|
||||||
|
&ecom_esi_label));
|
||||||
|
|
||||||
/* Add export RTs for all L2-VNIs associated with this ES */
|
/* Add export RTs for all L2-VNIs associated with this ES */
|
||||||
/* XXX - suppress EAD-ES advertisment if there are no EVIs associated
|
/* XXX - suppress EAD-ES advertisment if there are no EVIs associated
|
||||||
|
@ -882,8 +886,10 @@ static void bgp_evpn_type1_es_route_extcomm_build(struct bgp_evpn_es *es,
|
||||||
continue;
|
continue;
|
||||||
for (ALL_LIST_ELEMENTS_RO(es_evi->vpn->export_rtl,
|
for (ALL_LIST_ELEMENTS_RO(es_evi->vpn->export_rtl,
|
||||||
rt_node, ecom))
|
rt_node, ecom))
|
||||||
attr->ecommunity = ecommunity_merge(attr->ecommunity,
|
bgp_attr_set_ecommunity(
|
||||||
ecom);
|
attr,
|
||||||
|
ecommunity_merge(bgp_attr_get_ecommunity(attr),
|
||||||
|
ecom));
|
||||||
}
|
}
|
||||||
|
|
||||||
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
||||||
|
@ -906,11 +912,13 @@ static void bgp_evpn_type1_evi_route_extcomm_build(struct bgp_evpn_es *es,
|
||||||
ecom_encap.size = 1;
|
ecom_encap.size = 1;
|
||||||
ecom_encap.unit_size = ECOMMUNITY_SIZE;
|
ecom_encap.unit_size = ECOMMUNITY_SIZE;
|
||||||
ecom_encap.val = (uint8_t *)eval.val;
|
ecom_encap.val = (uint8_t *)eval.val;
|
||||||
attr->ecommunity = ecommunity_dup(&ecom_encap);
|
bgp_attr_set_ecommunity(attr, ecommunity_dup(&ecom_encap));
|
||||||
|
|
||||||
/* Add export RTs for the L2-VNI */
|
/* Add export RTs for the L2-VNI */
|
||||||
for (ALL_LIST_ELEMENTS_RO(vpn->export_rtl, rt_node, ecom))
|
for (ALL_LIST_ELEMENTS_RO(vpn->export_rtl, rt_node, ecom))
|
||||||
attr->ecommunity = ecommunity_merge(attr->ecommunity, ecom);
|
bgp_attr_set_ecommunity(
|
||||||
|
attr,
|
||||||
|
ecommunity_merge(bgp_attr_get_ecommunity(attr), ecom));
|
||||||
|
|
||||||
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,9 +170,10 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr,
|
||||||
afi);
|
afi);
|
||||||
snprintf(ec_string, sizeof(ec_string),
|
snprintf(ec_string, sizeof(ec_string),
|
||||||
"EC{none}");
|
"EC{none}");
|
||||||
if (attr && attr->ecommunity) {
|
if (attr && bgp_attr_get_ecommunity(attr)) {
|
||||||
s = ecommunity_ecom2str(attr->ecommunity,
|
s = ecommunity_ecom2str(
|
||||||
ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
|
bgp_attr_get_ecommunity(attr),
|
||||||
|
ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
|
||||||
snprintf(ec_string, sizeof(ec_string),
|
snprintf(ec_string, sizeof(ec_string),
|
||||||
"EC{%s}",
|
"EC{%s}",
|
||||||
s == NULL ? "none" : s);
|
s == NULL ? "none" : s);
|
||||||
|
|
|
@ -303,12 +303,13 @@ void route_vty_out_flowspec(struct vty *vty, const struct prefix *p,
|
||||||
if (path->attr)
|
if (path->attr)
|
||||||
ipv6_ecomm = bgp_attr_get_ipv6_ecommunity(path->attr);
|
ipv6_ecomm = bgp_attr_get_ipv6_ecommunity(path->attr);
|
||||||
|
|
||||||
if (path->attr && (path->attr->ecommunity || ipv6_ecomm)) {
|
if (path->attr && (bgp_attr_get_ecommunity(path->attr) || ipv6_ecomm)) {
|
||||||
/* Print attribute */
|
/* Print attribute */
|
||||||
attr = path->attr;
|
attr = path->attr;
|
||||||
if (attr->ecommunity)
|
if (bgp_attr_get_ecommunity(attr))
|
||||||
s1 = ecommunity_ecom2str(attr->ecommunity,
|
s1 = ecommunity_ecom2str(bgp_attr_get_ecommunity(attr),
|
||||||
ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
|
ECOMMUNITY_FORMAT_ROUTE_MAP,
|
||||||
|
0);
|
||||||
if (ipv6_ecomm)
|
if (ipv6_ecomm)
|
||||||
s2 = ecommunity_ecom2str(
|
s2 = ecommunity_ecom2str(
|
||||||
ipv6_ecomm, ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
|
ipv6_ecomm, ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
|
||||||
|
|
|
@ -624,7 +624,8 @@ void bgp_path_info_mpath_update(struct bgp *bgp, struct bgp_dest *dest,
|
||||||
prev_mpath = cur_mpath;
|
prev_mpath = cur_mpath;
|
||||||
mpath_count++;
|
mpath_count++;
|
||||||
if (ecommunity_linkbw_present(
|
if (ecommunity_linkbw_present(
|
||||||
cur_mpath->attr->ecommunity,
|
bgp_attr_get_ecommunity(
|
||||||
|
cur_mpath->attr),
|
||||||
&bwval))
|
&bwval))
|
||||||
cum_bw += bwval;
|
cum_bw += bwval;
|
||||||
else
|
else
|
||||||
|
@ -714,7 +715,8 @@ void bgp_path_info_mpath_update(struct bgp *bgp, struct bgp_dest *dest,
|
||||||
mpath_changed = 1;
|
mpath_changed = 1;
|
||||||
mpath_count++;
|
mpath_count++;
|
||||||
if (ecommunity_linkbw_present(
|
if (ecommunity_linkbw_present(
|
||||||
new_mpath->attr->ecommunity,
|
bgp_attr_get_ecommunity(
|
||||||
|
new_mpath->attr),
|
||||||
&bwval))
|
&bwval))
|
||||||
cum_bw += bwval;
|
cum_bw += bwval;
|
||||||
else
|
else
|
||||||
|
@ -737,9 +739,9 @@ void bgp_path_info_mpath_update(struct bgp *bgp, struct bgp_dest *dest,
|
||||||
|
|
||||||
if (new_best) {
|
if (new_best) {
|
||||||
bgp_path_info_mpath_count_set(new_best, mpath_count - 1);
|
bgp_path_info_mpath_count_set(new_best, mpath_count - 1);
|
||||||
if (mpath_count <= 1
|
if (mpath_count <= 1 ||
|
||||||
|| !ecommunity_linkbw_present(new_best->attr->ecommunity,
|
!ecommunity_linkbw_present(
|
||||||
&bwval))
|
bgp_attr_get_ecommunity(new_best->attr), &bwval))
|
||||||
all_paths_lb = false;
|
all_paths_lb = false;
|
||||||
else
|
else
|
||||||
cum_bw += bwval;
|
cum_bw += bwval;
|
||||||
|
@ -841,8 +843,9 @@ void bgp_path_info_mpath_aggregate_update(struct bgp_path_info *new_best,
|
||||||
origin = attr.origin;
|
origin = attr.origin;
|
||||||
community =
|
community =
|
||||||
attr.community ? community_dup(attr.community) : NULL;
|
attr.community ? community_dup(attr.community) : NULL;
|
||||||
ecomm = (attr.ecommunity) ? ecommunity_dup(attr.ecommunity)
|
ecomm = (bgp_attr_get_ecommunity(&attr))
|
||||||
: NULL;
|
? ecommunity_dup(bgp_attr_get_ecommunity(&attr))
|
||||||
|
: NULL;
|
||||||
lcomm = (attr.lcommunity) ? lcommunity_dup(attr.lcommunity)
|
lcomm = (attr.lcommunity) ? lcommunity_dup(attr.lcommunity)
|
||||||
: NULL;
|
: NULL;
|
||||||
|
|
||||||
|
@ -869,16 +872,17 @@ void bgp_path_info_mpath_aggregate_update(struct bgp_path_info *new_best,
|
||||||
mpinfo->attr->community);
|
mpinfo->attr->community);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mpinfo->attr->ecommunity) {
|
if (bgp_attr_get_ecommunity(mpinfo->attr)) {
|
||||||
if (ecomm) {
|
if (ecomm) {
|
||||||
ecommerge = ecommunity_merge(
|
ecommerge = ecommunity_merge(
|
||||||
ecomm,
|
ecomm, bgp_attr_get_ecommunity(
|
||||||
mpinfo->attr->ecommunity);
|
mpinfo->attr));
|
||||||
ecomm = ecommunity_uniq_sort(ecommerge);
|
ecomm = ecommunity_uniq_sort(ecommerge);
|
||||||
ecommunity_free(&ecommerge);
|
ecommunity_free(&ecommerge);
|
||||||
} else
|
} else
|
||||||
ecomm = ecommunity_dup(
|
ecomm = ecommunity_dup(
|
||||||
mpinfo->attr->ecommunity);
|
bgp_attr_get_ecommunity(
|
||||||
|
mpinfo->attr));
|
||||||
}
|
}
|
||||||
if (mpinfo->attr->lcommunity) {
|
if (mpinfo->attr->lcommunity) {
|
||||||
if (lcomm) {
|
if (lcomm) {
|
||||||
|
@ -900,7 +904,7 @@ void bgp_path_info_mpath_aggregate_update(struct bgp_path_info *new_best,
|
||||||
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES);
|
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES);
|
||||||
}
|
}
|
||||||
if (ecomm) {
|
if (ecomm) {
|
||||||
attr.ecommunity = ecomm;
|
bgp_attr_set_ecommunity(&attr, ecomm);
|
||||||
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
||||||
}
|
}
|
||||||
if (lcomm) {
|
if (lcomm) {
|
||||||
|
|
|
@ -1053,9 +1053,10 @@ void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, /* to */
|
||||||
if (debug)
|
if (debug)
|
||||||
zlog_debug("%s: from vrf %s", __func__, bgp_vrf->name_pretty);
|
zlog_debug("%s: from vrf %s", __func__, bgp_vrf->name_pretty);
|
||||||
|
|
||||||
if (debug && path_vrf->attr->ecommunity) {
|
if (debug && bgp_attr_get_ecommunity(path_vrf->attr)) {
|
||||||
char *s = ecommunity_ecom2str(path_vrf->attr->ecommunity,
|
char *s = ecommunity_ecom2str(
|
||||||
ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
|
bgp_attr_get_ecommunity(path_vrf->attr),
|
||||||
|
ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
|
||||||
|
|
||||||
zlog_debug("%s: %s path_vrf->type=%d, EC{%s}", __func__,
|
zlog_debug("%s: %s path_vrf->type=%d, EC{%s}", __func__,
|
||||||
bgp_vrf->name, path_vrf->type, s);
|
bgp_vrf->name, path_vrf->type, s);
|
||||||
|
@ -1111,9 +1112,10 @@ void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, /* to */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug && static_attr.ecommunity) {
|
if (debug && bgp_attr_get_ecommunity(&static_attr)) {
|
||||||
char *s = ecommunity_ecom2str(static_attr.ecommunity,
|
char *s = ecommunity_ecom2str(
|
||||||
ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
|
bgp_attr_get_ecommunity(&static_attr),
|
||||||
|
ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
|
||||||
|
|
||||||
zlog_debug("%s: post route map static_attr.ecommunity{%s}",
|
zlog_debug("%s: post route map static_attr.ecommunity{%s}",
|
||||||
__func__, s);
|
__func__, s);
|
||||||
|
@ -1128,7 +1130,7 @@ void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, /* to */
|
||||||
|
|
||||||
/* Export with the 'from' instance's export RTs. */
|
/* Export with the 'from' instance's export RTs. */
|
||||||
/* If doing VRF-to-VRF leaking, strip existing RTs first. */
|
/* If doing VRF-to-VRF leaking, strip existing RTs first. */
|
||||||
old_ecom = static_attr.ecommunity;
|
old_ecom = bgp_attr_get_ecommunity(&static_attr);
|
||||||
if (old_ecom) {
|
if (old_ecom) {
|
||||||
new_ecom = ecommunity_dup(old_ecom);
|
new_ecom = ecommunity_dup(old_ecom);
|
||||||
if (CHECK_FLAG(bgp_vrf->af_flags[afi][SAFI_UNICAST],
|
if (CHECK_FLAG(bgp_vrf->af_flags[afi][SAFI_UNICAST],
|
||||||
|
@ -1144,12 +1146,13 @@ void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, /* to */
|
||||||
bgp_vrf->vpn_policy[afi]
|
bgp_vrf->vpn_policy[afi]
|
||||||
.rtlist[BGP_VPN_POLICY_DIR_TOVPN]);
|
.rtlist[BGP_VPN_POLICY_DIR_TOVPN]);
|
||||||
}
|
}
|
||||||
static_attr.ecommunity = new_ecom;
|
bgp_attr_set_ecommunity(&static_attr, new_ecom);
|
||||||
SET_FLAG(static_attr.flag, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES));
|
SET_FLAG(static_attr.flag, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES));
|
||||||
|
|
||||||
if (debug && static_attr.ecommunity) {
|
if (debug && bgp_attr_get_ecommunity(&static_attr)) {
|
||||||
char *s = ecommunity_ecom2str(static_attr.ecommunity,
|
char *s = ecommunity_ecom2str(
|
||||||
ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
|
bgp_attr_get_ecommunity(&static_attr),
|
||||||
|
ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
|
||||||
|
|
||||||
zlog_debug("%s: post merge static_attr.ecommunity{%s}",
|
zlog_debug("%s: post merge static_attr.ecommunity{%s}",
|
||||||
__func__, s);
|
__func__, s);
|
||||||
|
@ -1261,8 +1264,8 @@ void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, /* to */
|
||||||
&static_attr); /* hashed refcounted everything */
|
&static_attr); /* hashed refcounted everything */
|
||||||
bgp_attr_flush(&static_attr); /* free locally-allocated parts */
|
bgp_attr_flush(&static_attr); /* free locally-allocated parts */
|
||||||
|
|
||||||
if (debug && new_attr->ecommunity) {
|
if (debug && bgp_attr_get_ecommunity(new_attr)) {
|
||||||
char *s = ecommunity_ecom2str(new_attr->ecommunity,
|
char *s = ecommunity_ecom2str(bgp_attr_get_ecommunity(new_attr),
|
||||||
ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
|
ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
|
||||||
|
|
||||||
zlog_debug("%s: new_attr->ecommunity{%s}", __func__, s);
|
zlog_debug("%s: new_attr->ecommunity{%s}", __func__, s);
|
||||||
|
@ -1481,7 +1484,7 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf, /* to */
|
||||||
/* Check for intersection of route targets */
|
/* Check for intersection of route targets */
|
||||||
if (!ecom_intersect(
|
if (!ecom_intersect(
|
||||||
bgp_vrf->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN],
|
bgp_vrf->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN],
|
||||||
path_vpn->attr->ecommunity)) {
|
bgp_attr_get_ecommunity(path_vpn->attr))) {
|
||||||
if (debug)
|
if (debug)
|
||||||
zlog_debug(
|
zlog_debug(
|
||||||
"from vpn to vrf %s, skipping after no intersection of route targets",
|
"from vpn to vrf %s, skipping after no intersection of route targets",
|
||||||
|
@ -1500,18 +1503,18 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf, /* to */
|
||||||
struct ecommunity *new_ecom;
|
struct ecommunity *new_ecom;
|
||||||
|
|
||||||
/* If doing VRF-to-VRF leaking, strip RTs. */
|
/* If doing VRF-to-VRF leaking, strip RTs. */
|
||||||
old_ecom = static_attr.ecommunity;
|
old_ecom = bgp_attr_get_ecommunity(&static_attr);
|
||||||
if (old_ecom && CHECK_FLAG(bgp_vrf->af_flags[afi][safi],
|
if (old_ecom && CHECK_FLAG(bgp_vrf->af_flags[afi][safi],
|
||||||
BGP_CONFIG_VRF_TO_VRF_IMPORT)) {
|
BGP_CONFIG_VRF_TO_VRF_IMPORT)) {
|
||||||
new_ecom = ecommunity_dup(old_ecom);
|
new_ecom = ecommunity_dup(old_ecom);
|
||||||
ecommunity_strip_rts(new_ecom);
|
ecommunity_strip_rts(new_ecom);
|
||||||
static_attr.ecommunity = new_ecom;
|
bgp_attr_set_ecommunity(&static_attr, new_ecom);
|
||||||
|
|
||||||
if (new_ecom->size == 0) {
|
if (new_ecom->size == 0) {
|
||||||
UNSET_FLAG(static_attr.flag,
|
UNSET_FLAG(static_attr.flag,
|
||||||
ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES));
|
ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES));
|
||||||
ecommunity_free(&new_ecom);
|
ecommunity_free(&new_ecom);
|
||||||
static_attr.ecommunity = NULL;
|
bgp_attr_set_ecommunity(&static_attr, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!old_ecom->refcnt)
|
if (!old_ecom->refcnt)
|
||||||
|
@ -1728,7 +1731,7 @@ void vpn_leak_to_vrf_withdraw(struct bgp *bgp_vpn, /* from */
|
||||||
/* Check for intersection of route targets */
|
/* Check for intersection of route targets */
|
||||||
if (!ecom_intersect(bgp->vpn_policy[afi]
|
if (!ecom_intersect(bgp->vpn_policy[afi]
|
||||||
.rtlist[BGP_VPN_POLICY_DIR_FROMVPN],
|
.rtlist[BGP_VPN_POLICY_DIR_FROMVPN],
|
||||||
path_vpn->attr->ecommunity)) {
|
bgp_attr_get_ecommunity(path_vpn->attr))) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -770,8 +770,8 @@ int bgp_pbr_build_and_validate_entry(const struct prefix *p,
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return -1;
|
return -1;
|
||||||
/* extract actiosn from flowspec ecom list */
|
/* extract actiosn from flowspec ecom list */
|
||||||
if (path && path->attr->ecommunity) {
|
if (path && bgp_attr_get_ecommunity(path->attr)) {
|
||||||
ecom = path->attr->ecommunity;
|
ecom = bgp_attr_get_ecommunity(path->attr);
|
||||||
for (i = 0; i < ecom->size; i++) {
|
for (i = 0; i < ecom->size; i++) {
|
||||||
ecom_eval = (struct ecommunity_val *)
|
ecom_eval = (struct ecommunity_val *)
|
||||||
(ecom->val + (i * ECOMMUNITY_SIZE));
|
(ecom->val + (i * ECOMMUNITY_SIZE));
|
||||||
|
|
|
@ -2374,10 +2374,13 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
|
||||||
bgp_path_info_mpath_chkwtd(bgp, pi) &&
|
bgp_path_info_mpath_chkwtd(bgp, pi) &&
|
||||||
(cum_bw = bgp_path_info_mpath_cumbw(pi)) != 0 &&
|
(cum_bw = bgp_path_info_mpath_cumbw(pi)) != 0 &&
|
||||||
!CHECK_FLAG(attr->rmap_change_flags, BATTR_RMAP_LINK_BW_SET))
|
!CHECK_FLAG(attr->rmap_change_flags, BATTR_RMAP_LINK_BW_SET))
|
||||||
attr->ecommunity = ecommunity_replace_linkbw(
|
bgp_attr_set_ecommunity(
|
||||||
bgp->as, attr->ecommunity, cum_bw,
|
attr,
|
||||||
CHECK_FLAG(peer->flags,
|
ecommunity_replace_linkbw(
|
||||||
PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE));
|
bgp->as, bgp_attr_get_ecommunity(attr), cum_bw,
|
||||||
|
CHECK_FLAG(
|
||||||
|
peer->flags,
|
||||||
|
PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE)));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -4118,16 +4121,19 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
|
||||||
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))) {
|
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))) {
|
||||||
int cmp;
|
int cmp;
|
||||||
|
|
||||||
cmp = ecommunity_cmp(pi->attr->ecommunity,
|
cmp = ecommunity_cmp(
|
||||||
attr_new->ecommunity);
|
bgp_attr_get_ecommunity(pi->attr),
|
||||||
|
bgp_attr_get_ecommunity(attr_new));
|
||||||
if (!cmp) {
|
if (!cmp) {
|
||||||
if (bgp_debug_update(peer, p, NULL, 1))
|
if (bgp_debug_update(peer, p, NULL, 1))
|
||||||
zlog_debug(
|
zlog_debug(
|
||||||
"Change in EXT-COMM, existing %s new %s",
|
"Change in EXT-COMM, existing %s new %s",
|
||||||
ecommunity_str(
|
ecommunity_str(
|
||||||
pi->attr->ecommunity),
|
bgp_attr_get_ecommunity(
|
||||||
|
pi->attr)),
|
||||||
ecommunity_str(
|
ecommunity_str(
|
||||||
attr_new->ecommunity));
|
bgp_attr_get_ecommunity(
|
||||||
|
attr_new)));
|
||||||
if (safi == SAFI_EVPN)
|
if (safi == SAFI_EVPN)
|
||||||
bgp_evpn_unimport_route(
|
bgp_evpn_unimport_route(
|
||||||
bgp, afi, safi, p, pi);
|
bgp, afi, safi, p, pi);
|
||||||
|
@ -7032,7 +7038,7 @@ static bool bgp_aggregate_info_same(struct bgp_path_info *pi, uint8_t origin,
|
||||||
if (!community_cmp(pi->attr->community, comm))
|
if (!community_cmp(pi->attr->community, comm))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!ecommunity_cmp(pi->attr->ecommunity, ecomm))
|
if (!ecommunity_cmp(bgp_attr_get_ecommunity(pi->attr), ecomm))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!lcommunity_cmp(pi->attr->lcommunity, lcomm))
|
if (!lcommunity_cmp(pi->attr->lcommunity, lcomm))
|
||||||
|
@ -7455,10 +7461,10 @@ void bgp_aggregate_route(struct bgp *bgp, const struct prefix *p, afi_t afi,
|
||||||
|
|
||||||
/* Compute aggregate route's extended community.
|
/* Compute aggregate route's extended community.
|
||||||
*/
|
*/
|
||||||
if (pi->attr->ecommunity)
|
if (bgp_attr_get_ecommunity(pi->attr))
|
||||||
bgp_compute_aggregate_ecommunity_hash(
|
bgp_compute_aggregate_ecommunity_hash(
|
||||||
aggregate,
|
aggregate,
|
||||||
pi->attr->ecommunity);
|
bgp_attr_get_ecommunity(pi->attr));
|
||||||
|
|
||||||
/* Compute aggregate route's large community.
|
/* Compute aggregate route's large community.
|
||||||
*/
|
*/
|
||||||
|
@ -7577,12 +7583,13 @@ void bgp_aggregate_delete(struct bgp *bgp, const struct prefix *p, afi_t afi,
|
||||||
aggregate,
|
aggregate,
|
||||||
pi->attr->community);
|
pi->attr->community);
|
||||||
|
|
||||||
if (pi->attr->ecommunity)
|
if (bgp_attr_get_ecommunity(pi->attr))
|
||||||
/* Remove ecommunity from aggregate.
|
/* Remove ecommunity from aggregate.
|
||||||
*/
|
*/
|
||||||
bgp_remove_ecomm_from_aggregate_hash(
|
bgp_remove_ecomm_from_aggregate_hash(
|
||||||
aggregate,
|
aggregate,
|
||||||
pi->attr->ecommunity);
|
bgp_attr_get_ecommunity(
|
||||||
|
pi->attr));
|
||||||
|
|
||||||
if (pi->attr->lcommunity)
|
if (pi->attr->lcommunity)
|
||||||
/* Remove lcommunity from aggregate.
|
/* Remove lcommunity from aggregate.
|
||||||
|
@ -7695,10 +7702,10 @@ static void bgp_add_route_to_aggregate(struct bgp *bgp,
|
||||||
|
|
||||||
/* Compute aggregate route's extended community.
|
/* Compute aggregate route's extended community.
|
||||||
*/
|
*/
|
||||||
if (pinew->attr->ecommunity)
|
if (bgp_attr_get_ecommunity(pinew->attr))
|
||||||
bgp_compute_aggregate_ecommunity(
|
bgp_compute_aggregate_ecommunity(
|
||||||
aggregate,
|
aggregate,
|
||||||
pinew->attr->ecommunity);
|
bgp_attr_get_ecommunity(pinew->attr));
|
||||||
|
|
||||||
/* Compute aggregate route's large community.
|
/* Compute aggregate route's large community.
|
||||||
*/
|
*/
|
||||||
|
@ -7798,12 +7805,11 @@ static void bgp_remove_route_from_aggregate(struct bgp *bgp, afi_t afi,
|
||||||
aggregate,
|
aggregate,
|
||||||
pi->attr->community);
|
pi->attr->community);
|
||||||
|
|
||||||
if (pi->attr->ecommunity)
|
if (bgp_attr_get_ecommunity(pi->attr))
|
||||||
/* Remove ecommunity from aggregate.
|
/* Remove ecommunity from aggregate.
|
||||||
*/
|
*/
|
||||||
bgp_remove_ecommunity_from_aggregate(
|
bgp_remove_ecommunity_from_aggregate(
|
||||||
aggregate,
|
aggregate, bgp_attr_get_ecommunity(pi->attr));
|
||||||
pi->attr->ecommunity);
|
|
||||||
|
|
||||||
if (pi->attr->lcommunity)
|
if (pi->attr->lcommunity)
|
||||||
/* Remove lcommunity from aggregate.
|
/* Remove lcommunity from aggregate.
|
||||||
|
@ -9130,9 +9136,9 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
|
||||||
if (safi == SAFI_EVPN &&
|
if (safi == SAFI_EVPN &&
|
||||||
attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) {
|
attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) {
|
||||||
json_ext_community = json_object_new_object();
|
json_ext_community = json_object_new_object();
|
||||||
json_object_string_add(json_ext_community,
|
json_object_string_add(
|
||||||
"string",
|
json_ext_community, "string",
|
||||||
attr->ecommunity->str);
|
bgp_attr_get_ecommunity(attr)->str);
|
||||||
json_object_object_add(json_path,
|
json_object_object_add(json_path,
|
||||||
"extendedCommunity",
|
"extendedCommunity",
|
||||||
json_ext_community);
|
json_ext_community);
|
||||||
|
@ -9185,7 +9191,8 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
|
||||||
if (attr->flag &
|
if (attr->flag &
|
||||||
ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) {
|
ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) {
|
||||||
vty_out(vty, "%*s", 20, " ");
|
vty_out(vty, "%*s", 20, " ");
|
||||||
vty_out(vty, "%s\n", attr->ecommunity->str);
|
vty_out(vty, "%s\n",
|
||||||
|
bgp_attr_get_ecommunity(attr)->str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9518,10 +9525,10 @@ void route_vty_out_overlay(struct vty *vty, const struct prefix *p,
|
||||||
else
|
else
|
||||||
json_object_string_add(json_overlay, "gw", buf);
|
json_object_string_add(json_overlay, "gw", buf);
|
||||||
|
|
||||||
if (attr->ecommunity) {
|
if (bgp_attr_get_ecommunity(attr)) {
|
||||||
char *mac = NULL;
|
char *mac = NULL;
|
||||||
struct ecommunity_val *routermac = ecommunity_lookup(
|
struct ecommunity_val *routermac = ecommunity_lookup(
|
||||||
attr->ecommunity, ECOMMUNITY_ENCODE_EVPN,
|
bgp_attr_get_ecommunity(attr), ECOMMUNITY_ENCODE_EVPN,
|
||||||
ECOMMUNITY_EVPN_SUBTYPE_ROUTERMAC);
|
ECOMMUNITY_EVPN_SUBTYPE_ROUTERMAC);
|
||||||
|
|
||||||
if (routermac)
|
if (routermac)
|
||||||
|
@ -10491,13 +10498,14 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
|
||||||
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) {
|
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) {
|
||||||
if (json_paths) {
|
if (json_paths) {
|
||||||
json_ext_community = json_object_new_object();
|
json_ext_community = json_object_new_object();
|
||||||
json_object_string_add(json_ext_community, "string",
|
json_object_string_add(
|
||||||
attr->ecommunity->str);
|
json_ext_community, "string",
|
||||||
|
bgp_attr_get_ecommunity(attr)->str);
|
||||||
json_object_object_add(json_path, "extendedCommunity",
|
json_object_object_add(json_path, "extendedCommunity",
|
||||||
json_ext_community);
|
json_ext_community);
|
||||||
} else {
|
} else {
|
||||||
vty_out(vty, " Extended Community: %s\n",
|
vty_out(vty, " Extended Community: %s\n",
|
||||||
attr->ecommunity->str);
|
bgp_attr_get_ecommunity(attr)->str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1589,7 +1589,7 @@ route_match_ecommunity(void *rule, const struct prefix *prefix, void *object)
|
||||||
if (!list)
|
if (!list)
|
||||||
return RMAP_NOMATCH;
|
return RMAP_NOMATCH;
|
||||||
|
|
||||||
if (ecommunity_list_match(path->attr->ecommunity, list))
|
if (ecommunity_list_match(bgp_attr_get_ecommunity(path->attr), list))
|
||||||
return RMAP_MATCH;
|
return RMAP_MATCH;
|
||||||
|
|
||||||
return RMAP_NOMATCH;
|
return RMAP_NOMATCH;
|
||||||
|
@ -2590,7 +2590,7 @@ route_set_ecommunity(void *rule, const struct prefix *prefix, void *object)
|
||||||
|
|
||||||
if (rcs->none) {
|
if (rcs->none) {
|
||||||
attr->flag &= ~(ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES));
|
attr->flag &= ~(ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES));
|
||||||
attr->ecommunity = NULL;
|
bgp_attr_set_ecommunity(attr, NULL);
|
||||||
return RMAP_OKAY;
|
return RMAP_OKAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2598,7 +2598,7 @@ route_set_ecommunity(void *rule, const struct prefix *prefix, void *object)
|
||||||
return RMAP_OKAY;
|
return RMAP_OKAY;
|
||||||
|
|
||||||
/* We assume additive for Extended Community. */
|
/* We assume additive for Extended Community. */
|
||||||
old_ecom = path->attr->ecommunity;
|
old_ecom = bgp_attr_get_ecommunity(path->attr);
|
||||||
|
|
||||||
if (old_ecom) {
|
if (old_ecom) {
|
||||||
new_ecom =
|
new_ecom =
|
||||||
|
@ -2614,7 +2614,7 @@ route_set_ecommunity(void *rule, const struct prefix *prefix, void *object)
|
||||||
new_ecom = ecommunity_dup(rcs->ecom);
|
new_ecom = ecommunity_dup(rcs->ecom);
|
||||||
|
|
||||||
/* will be intern()'d or attr_flush()'d by bgp_update_main() */
|
/* will be intern()'d or attr_flush()'d by bgp_update_main() */
|
||||||
path->attr->ecommunity = new_ecom;
|
bgp_attr_set_ecommunity(path->attr, new_ecom);
|
||||||
|
|
||||||
path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
||||||
|
|
||||||
|
@ -2764,7 +2764,7 @@ route_set_ecommunity_lb(void *rule, const struct prefix *prefix, void *object)
|
||||||
PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE));
|
PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE));
|
||||||
|
|
||||||
/* add to route or merge with existing */
|
/* add to route or merge with existing */
|
||||||
old_ecom = path->attr->ecommunity;
|
old_ecom = bgp_attr_get_ecommunity(path->attr);
|
||||||
if (old_ecom) {
|
if (old_ecom) {
|
||||||
new_ecom = ecommunity_dup(old_ecom);
|
new_ecom = ecommunity_dup(old_ecom);
|
||||||
ecommunity_add_val(new_ecom, &lb_eval, true, true);
|
ecommunity_add_val(new_ecom, &lb_eval, true, true);
|
||||||
|
@ -2778,7 +2778,7 @@ route_set_ecommunity_lb(void *rule, const struct prefix *prefix, void *object)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* new_ecom will be intern()'d or attr_flush()'d in call stack */
|
/* new_ecom will be intern()'d or attr_flush()'d in call stack */
|
||||||
path->attr->ecommunity = new_ecom;
|
bgp_attr_set_ecommunity(path->attr, new_ecom);
|
||||||
path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
||||||
|
|
||||||
/* Mark that route-map has set link bandwidth; used in attribute
|
/* Mark that route-map has set link bandwidth; used in attribute
|
||||||
|
|
|
@ -800,8 +800,8 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
attr.ecommunity = ecommunity_new();
|
bgp_attr_set_ecommunity(&attr, ecommunity_new());
|
||||||
assert(attr.ecommunity);
|
assert(bgp_attr_get_ecommunity(&attr));
|
||||||
|
|
||||||
if (TunnelType != BGP_ENCAP_TYPE_MPLS
|
if (TunnelType != BGP_ENCAP_TYPE_MPLS
|
||||||
&& TunnelType != BGP_ENCAP_TYPE_RESERVED) {
|
&& TunnelType != BGP_ENCAP_TYPE_RESERVED) {
|
||||||
|
@ -817,25 +817,28 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
|
||||||
beec.val[1] = ECOMMUNITY_OPAQUE_SUBTYPE_ENCAP;
|
beec.val[1] = ECOMMUNITY_OPAQUE_SUBTYPE_ENCAP;
|
||||||
beec.val[6] = ((TunnelType) >> 8) & 0xff;
|
beec.val[6] = ((TunnelType) >> 8) & 0xff;
|
||||||
beec.val[7] = (TunnelType)&0xff;
|
beec.val[7] = (TunnelType)&0xff;
|
||||||
ecommunity_add_val(attr.ecommunity, &beec, false, false);
|
ecommunity_add_val(bgp_attr_get_ecommunity(&attr), &beec, false,
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add extended community attributes to match rt export list
|
* Add extended community attributes to match rt export list
|
||||||
*/
|
*/
|
||||||
if (rt_export_list) {
|
if (rt_export_list) {
|
||||||
attr.ecommunity =
|
bgp_attr_set_ecommunity(
|
||||||
ecommunity_merge(attr.ecommunity, rt_export_list);
|
&attr, ecommunity_merge(bgp_attr_get_ecommunity(&attr),
|
||||||
|
rt_export_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attr.ecommunity->size) {
|
struct ecommunity *ecomm = bgp_attr_get_ecommunity(&attr);
|
||||||
|
|
||||||
|
if (ecomm->size) {
|
||||||
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
||||||
} else {
|
} else {
|
||||||
ecommunity_free(&attr.ecommunity);
|
ecommunity_free(&ecomm);
|
||||||
attr.ecommunity = NULL;
|
bgp_attr_set_ecommunity(&attr, NULL);
|
||||||
}
|
}
|
||||||
vnc_zlog_debug_verbose("%s: attr.ecommunity=%p", __func__,
|
vnc_zlog_debug_verbose("%s: attr.ecommunity=%p", __func__, ecomm);
|
||||||
attr.ecommunity);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1292,10 +1292,11 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix,
|
||||||
|
|
||||||
memcpy(&vo->v.l2addr.macaddr, &p->u.prefix_eth.octet, ETH_ALEN);
|
memcpy(&vo->v.l2addr.macaddr, &p->u.prefix_eth.octet, ETH_ALEN);
|
||||||
/* only low 3 bytes of this are significant */
|
/* only low 3 bytes of this are significant */
|
||||||
(void)rfapiEcommunityGetLNI(bpi->attr->ecommunity,
|
(void)rfapiEcommunityGetLNI(bgp_attr_get_ecommunity(bpi->attr),
|
||||||
&vo->v.l2addr.logical_net_id);
|
&vo->v.l2addr.logical_net_id);
|
||||||
(void)rfapiEcommunityGetEthernetTag(bpi->attr->ecommunity,
|
(void)rfapiEcommunityGetEthernetTag(
|
||||||
&vo->v.l2addr.tag_id);
|
bgp_attr_get_ecommunity(bpi->attr),
|
||||||
|
&vo->v.l2addr.tag_id);
|
||||||
|
|
||||||
/* local_nve_id comes from lower byte of RD type */
|
/* local_nve_id comes from lower byte of RD type */
|
||||||
vo->v.l2addr.local_nve_id = bpi->extra->vnc.import.rd.val[1];
|
vo->v.l2addr.local_nve_id = bpi->extra->vnc.import.rd.val[1];
|
||||||
|
@ -2946,7 +2947,7 @@ static void rfapiBgpInfoFilteredImportEncap(
|
||||||
* On a withdraw, peer and RD are sufficient to determine if
|
* On a withdraw, peer and RD are sufficient to determine if
|
||||||
* we should act.
|
* we should act.
|
||||||
*/
|
*/
|
||||||
if (!attr || !attr->ecommunity) {
|
if (!attr || !bgp_attr_get_ecommunity(attr)) {
|
||||||
|
|
||||||
vnc_zlog_debug_verbose(
|
vnc_zlog_debug_verbose(
|
||||||
"%s: attr, extra, or ecommunity missing, not importing",
|
"%s: attr, extra, or ecommunity missing, not importing",
|
||||||
|
@ -2954,15 +2955,17 @@ static void rfapiBgpInfoFilteredImportEncap(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef RFAPI_REQUIRE_ENCAP_BEEC
|
#ifdef RFAPI_REQUIRE_ENCAP_BEEC
|
||||||
if (!rfapiEcommunitiesMatchBeec(attr->ecommunity)) {
|
if (!rfapiEcommunitiesMatchBeec(
|
||||||
|
bgp_attr_get_ecommunity(attr))) {
|
||||||
vnc_zlog_debug_verbose(
|
vnc_zlog_debug_verbose(
|
||||||
"%s: it=%p: no match for BGP Encapsulation ecommunity",
|
"%s: it=%p: no match for BGP Encapsulation ecommunity",
|
||||||
__func__, import_table);
|
__func__, import_table);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!rfapiEcommunitiesIntersect(import_table->rt_import_list,
|
if (!rfapiEcommunitiesIntersect(
|
||||||
attr->ecommunity)) {
|
import_table->rt_import_list,
|
||||||
|
bgp_attr_get_ecommunity(attr))) {
|
||||||
|
|
||||||
vnc_zlog_debug_verbose(
|
vnc_zlog_debug_verbose(
|
||||||
"%s: it=%p: no ecommunity intersection",
|
"%s: it=%p: no ecommunity intersection",
|
||||||
|
@ -3407,16 +3410,17 @@ void rfapiBgpInfoFilteredImportVPN(
|
||||||
* we should act.
|
* we should act.
|
||||||
*/
|
*/
|
||||||
if (action == FIF_ACTION_UPDATE) {
|
if (action == FIF_ACTION_UPDATE) {
|
||||||
if (!attr || !attr->ecommunity) {
|
if (!attr || !bgp_attr_get_ecommunity(attr)) {
|
||||||
|
|
||||||
vnc_zlog_debug_verbose(
|
vnc_zlog_debug_verbose(
|
||||||
"%s: attr, extra, or ecommunity missing, not importing",
|
"%s: attr, extra, or ecommunity missing, not importing",
|
||||||
__func__);
|
__func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((import_table != bgp->rfapi->it_ce)
|
if ((import_table != bgp->rfapi->it_ce) &&
|
||||||
&& !rfapiEcommunitiesIntersect(import_table->rt_import_list,
|
!rfapiEcommunitiesIntersect(
|
||||||
attr->ecommunity)) {
|
import_table->rt_import_list,
|
||||||
|
bgp_attr_get_ecommunity(attr))) {
|
||||||
|
|
||||||
vnc_zlog_debug_verbose(
|
vnc_zlog_debug_verbose(
|
||||||
"%s: it=%p: no ecommunity intersection",
|
"%s: it=%p: no ecommunity intersection",
|
||||||
|
@ -3891,7 +3895,7 @@ void rfapiProcessUpdate(struct peer *peer,
|
||||||
* Find rt containing LNI (Logical Network ID), which
|
* Find rt containing LNI (Logical Network ID), which
|
||||||
* _should_ always be present when mac address is present
|
* _should_ always be present when mac address is present
|
||||||
*/
|
*/
|
||||||
rc = rfapiEcommunityGetLNI(attr->ecommunity, &lni);
|
rc = rfapiEcommunityGetLNI(bgp_attr_get_ecommunity(attr), &lni);
|
||||||
|
|
||||||
vnc_zlog_debug_verbose(
|
vnc_zlog_debug_verbose(
|
||||||
"%s: rfapiEcommunityGetLNI returned %d, lni=%d, attr=%p",
|
"%s: rfapiEcommunityGetLNI returned %d, lni=%d, attr=%p",
|
||||||
|
|
|
@ -682,10 +682,11 @@ static void rfapiRibBi2Ri(struct bgp_path_info *bpi, struct rfapi_info *ri,
|
||||||
memcpy(&vo->v.l2addr.macaddr, bpi->extra->vnc.import.rd.val + 2,
|
memcpy(&vo->v.l2addr.macaddr, bpi->extra->vnc.import.rd.val + 2,
|
||||||
ETH_ALEN);
|
ETH_ALEN);
|
||||||
|
|
||||||
(void)rfapiEcommunityGetLNI(bpi->attr->ecommunity,
|
(void)rfapiEcommunityGetLNI(bgp_attr_get_ecommunity(bpi->attr),
|
||||||
&vo->v.l2addr.logical_net_id);
|
&vo->v.l2addr.logical_net_id);
|
||||||
(void)rfapiEcommunityGetEthernetTag(bpi->attr->ecommunity,
|
(void)rfapiEcommunityGetEthernetTag(
|
||||||
&vo->v.l2addr.tag_id);
|
bgp_attr_get_ecommunity(bpi->attr),
|
||||||
|
&vo->v.l2addr.tag_id);
|
||||||
|
|
||||||
/* local_nve_id comes from RD */
|
/* local_nve_id comes from RD */
|
||||||
vo->v.l2addr.local_nve_id = bpi->extra->vnc.import.rd.val[1];
|
vo->v.l2addr.local_nve_id = bpi->extra->vnc.import.rd.val[1];
|
||||||
|
|
|
@ -417,8 +417,8 @@ void rfapi_vty_out_vncinfo(struct vty *vty, const struct prefix *p,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bpi->attr->ecommunity) {
|
if (bgp_attr_get_ecommunity(bpi->attr)) {
|
||||||
s = ecommunity_ecom2str(bpi->attr->ecommunity,
|
s = ecommunity_ecom2str(bgp_attr_get_ecommunity(bpi->attr),
|
||||||
ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
|
ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
|
||||||
vty_out(vty, " EC{%s}", s);
|
vty_out(vty, " EC{%s}", s);
|
||||||
XFREE(MTYPE_ECOMMUNITY_STR, s);
|
XFREE(MTYPE_ECOMMUNITY_STR, s);
|
||||||
|
@ -467,6 +467,7 @@ void rfapiPrintAttrPtrs(void *stream, struct attr *attr)
|
||||||
struct transit *transit;
|
struct transit *transit;
|
||||||
struct cluster_list *cluster;
|
struct cluster_list *cluster;
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
|
struct ecommunity *ecomm = bgp_attr_get_ecommunity(attr);
|
||||||
|
|
||||||
if (rfapiStream2Vty(stream, &fp, &vty, &out, &vty_newline) == 0)
|
if (rfapiStream2Vty(stream, &fp, &vty, &out, &vty_newline) == 0)
|
||||||
return;
|
return;
|
||||||
|
@ -484,8 +485,8 @@ void rfapiPrintAttrPtrs(void *stream, struct attr *attr)
|
||||||
fp(out, " community=%p, refcnt=%d%s", attr->community,
|
fp(out, " community=%p, refcnt=%d%s", attr->community,
|
||||||
(attr->community ? attr->community->refcnt : 0), HVTYNL);
|
(attr->community ? attr->community->refcnt : 0), HVTYNL);
|
||||||
|
|
||||||
fp(out, " ecommunity=%p, refcnt=%d%s", attr->ecommunity,
|
fp(out, " ecommunity=%p, refcnt=%d%s", ecomm,
|
||||||
(attr->ecommunity ? attr->ecommunity->refcnt : 0), HVTYNL);
|
(ecomm ? ecomm->refcnt : 0), HVTYNL);
|
||||||
|
|
||||||
cluster = bgp_attr_get_cluster(attr);
|
cluster = bgp_attr_get_cluster(attr);
|
||||||
fp(out, " cluster=%p, refcnt=%d%s", cluster,
|
fp(out, " cluster=%p, refcnt=%d%s", cluster,
|
||||||
|
@ -623,8 +624,8 @@ void rfapiPrintBi(void *stream, struct bgp_path_info *bpi)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* RT list */
|
/* RT list */
|
||||||
if (bpi->attr->ecommunity) {
|
if (bgp_attr_get_ecommunity(bpi->attr)) {
|
||||||
s = ecommunity_ecom2str(bpi->attr->ecommunity,
|
s = ecommunity_ecom2str(bgp_attr_get_ecommunity(bpi->attr),
|
||||||
ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
|
ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
|
||||||
r = snprintf(p, REMAIN, " %s", s);
|
r = snprintf(p, REMAIN, " %s", s);
|
||||||
INCP;
|
INCP;
|
||||||
|
|
|
@ -136,8 +136,9 @@ static int getce(struct bgp *bgp, struct attr *attr, struct prefix *pfx_ce)
|
||||||
uint8_t *ecp;
|
uint8_t *ecp;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
uint16_t localadmin = bgp->rfapi_cfg->resolve_nve_roo_local_admin;
|
uint16_t localadmin = bgp->rfapi_cfg->resolve_nve_roo_local_admin;
|
||||||
|
struct ecommunity *ecomm = bgp_attr_get_ecommunity(attr);
|
||||||
|
|
||||||
for (ecp = attr->ecommunity->val, i = 0; i < attr->ecommunity->size;
|
for (ecp = ecomm->val, i = 0; i < ecomm->size;
|
||||||
++i, ecp += ECOMMUNITY_SIZE) {
|
++i, ecp += ECOMMUNITY_SIZE) {
|
||||||
|
|
||||||
if (VNC_DEBUG(EXPORT_BGP_GETCE)) {
|
if (VNC_DEBUG(EXPORT_BGP_GETCE)) {
|
||||||
|
@ -640,12 +641,14 @@ encap_attr_export(struct attr *new, struct attr *orig,
|
||||||
/* TBD use lcom for IPv6 */
|
/* TBD use lcom for IPv6 */
|
||||||
ecom_ro = vnc_route_origin_ecom_single(&use_nexthop->u.prefix4);
|
ecom_ro = vnc_route_origin_ecom_single(&use_nexthop->u.prefix4);
|
||||||
}
|
}
|
||||||
if (new->ecommunity) {
|
if (bgp_attr_get_ecommunity(new)) {
|
||||||
if (ecom_ro)
|
if (ecom_ro)
|
||||||
new->ecommunity =
|
bgp_attr_set_ecommunity(
|
||||||
ecommunity_merge(ecom_ro, new->ecommunity);
|
new,
|
||||||
|
ecommunity_merge(ecom_ro,
|
||||||
|
bgp_attr_get_ecommunity(new)));
|
||||||
} else {
|
} else {
|
||||||
new->ecommunity = ecom_ro;
|
bgp_attr_set_ecommunity(new, ecom_ro);
|
||||||
}
|
}
|
||||||
if (ecom_ro) {
|
if (ecom_ro) {
|
||||||
new->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
new->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
||||||
|
|
|
@ -373,8 +373,8 @@ static int process_unicast_route(struct bgp *bgp, /* in */
|
||||||
*/
|
*/
|
||||||
rfapiUnicastNexthop2Prefix(afi, &hattr, unicast_nexthop);
|
rfapiUnicastNexthop2Prefix(afi, &hattr, unicast_nexthop);
|
||||||
|
|
||||||
if (hattr.ecommunity)
|
if (bgp_attr_get_ecommunity(&hattr))
|
||||||
*ecom = ecommunity_dup(hattr.ecommunity);
|
*ecom = ecommunity_dup(bgp_attr_get_ecommunity(&hattr));
|
||||||
else
|
else
|
||||||
*ecom = ecommunity_new();
|
*ecom = ecommunity_new();
|
||||||
|
|
||||||
|
@ -480,8 +480,8 @@ static void vnc_import_bgp_add_route_mode_resolve_nve_one_bi(
|
||||||
|
|
||||||
struct ecommunity *new_ecom = ecommunity_dup(ecom);
|
struct ecommunity *new_ecom = ecommunity_dup(ecom);
|
||||||
|
|
||||||
if (bpi->attr->ecommunity)
|
if (bgp_attr_get_ecommunity(bpi->attr))
|
||||||
ecommunity_merge(new_ecom, bpi->attr->ecommunity);
|
ecommunity_merge(new_ecom, bgp_attr_get_ecommunity(bpi->attr));
|
||||||
|
|
||||||
if (bpi->extra)
|
if (bpi->extra)
|
||||||
label = decode_label(&bpi->extra->label[0]);
|
label = decode_label(&bpi->extra->label[0]);
|
||||||
|
@ -818,8 +818,8 @@ static void vnc_import_bgp_add_route_mode_plain(struct bgp *bgp,
|
||||||
memset(&prd, 0, sizeof(prd));
|
memset(&prd, 0, sizeof(prd));
|
||||||
rfapi_set_autord_from_vn(&prd, &vnaddr);
|
rfapi_set_autord_from_vn(&prd, &vnaddr);
|
||||||
|
|
||||||
if (iattr && iattr->ecommunity)
|
if (iattr && bgp_attr_get_ecommunity(iattr))
|
||||||
ecom = ecommunity_dup(iattr->ecommunity);
|
ecom = ecommunity_dup(bgp_attr_get_ecommunity(iattr));
|
||||||
}
|
}
|
||||||
|
|
||||||
local_pref = calc_local_pref(iattr, peer);
|
local_pref = calc_local_pref(iattr, peer);
|
||||||
|
@ -1015,8 +1015,9 @@ static void vnc_import_bgp_add_route_mode_nvegroup(
|
||||||
else
|
else
|
||||||
ecom = ecommunity_new();
|
ecom = ecommunity_new();
|
||||||
|
|
||||||
if (iattr && iattr->ecommunity)
|
if (iattr && bgp_attr_get_ecommunity(iattr))
|
||||||
ecom = ecommunity_merge(ecom, iattr->ecommunity);
|
ecom = ecommunity_merge(ecom,
|
||||||
|
bgp_attr_get_ecommunity(iattr));
|
||||||
}
|
}
|
||||||
|
|
||||||
local_pref = calc_local_pref(iattr, peer);
|
local_pref = calc_local_pref(iattr, peer);
|
||||||
|
|
Loading…
Reference in a new issue