mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 20:34:33 +00:00
bgpd: Use get/set helpers for attr->lcommunity
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
This commit is contained in:
parent
eae63cb501
commit
1bcf3a96de
@ -682,8 +682,8 @@ unsigned int attrhash_key_make(const void *p)
|
|||||||
if (attr->community)
|
if (attr->community)
|
||||||
MIX(community_hash_make(attr->community));
|
MIX(community_hash_make(attr->community));
|
||||||
|
|
||||||
if (attr->lcommunity)
|
if (bgp_attr_get_lcommunity(attr))
|
||||||
MIX(lcommunity_hash_make(attr->lcommunity));
|
MIX(lcommunity_hash_make(bgp_attr_get_lcommunity(attr)));
|
||||||
if (bgp_attr_get_ecommunity(attr))
|
if (bgp_attr_get_ecommunity(attr))
|
||||||
MIX(ecommunity_hash_make(bgp_attr_get_ecommunity(attr)));
|
MIX(ecommunity_hash_make(bgp_attr_get_ecommunity(attr)));
|
||||||
if (bgp_attr_get_ipv6_ecommunity(attr))
|
if (bgp_attr_get_ipv6_ecommunity(attr))
|
||||||
@ -737,7 +737,8 @@ bool attrhash_cmp(const void *p1, const void *p2)
|
|||||||
== bgp_attr_get_ecommunity(attr2)
|
== 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
|
&& bgp_attr_get_lcommunity(attr1)
|
||||||
|
== bgp_attr_get_lcommunity(attr2)
|
||||||
&& bgp_attr_get_cluster(attr1)
|
&& bgp_attr_get_cluster(attr1)
|
||||||
== bgp_attr_get_cluster(attr2)
|
== bgp_attr_get_cluster(attr2)
|
||||||
&& bgp_attr_get_transit(attr1)
|
&& bgp_attr_get_transit(attr1)
|
||||||
@ -853,6 +854,7 @@ struct attr *bgp_attr_intern(struct attr *attr)
|
|||||||
struct attr *find;
|
struct attr *find;
|
||||||
struct ecommunity *ecomm = NULL;
|
struct ecommunity *ecomm = NULL;
|
||||||
struct ecommunity *ipv6_ecomm = NULL;
|
struct ecommunity *ipv6_ecomm = NULL;
|
||||||
|
struct lcommunity *lcomm = NULL;
|
||||||
|
|
||||||
/* Intern referenced strucutre. */
|
/* Intern referenced strucutre. */
|
||||||
if (attr->aspath) {
|
if (attr->aspath) {
|
||||||
@ -885,11 +887,12 @@ struct attr *bgp_attr_intern(struct attr *attr)
|
|||||||
ipv6_ecomm->refcnt++;
|
ipv6_ecomm->refcnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attr->lcommunity) {
|
lcomm = bgp_attr_get_lcommunity(attr);
|
||||||
if (!attr->lcommunity->refcnt)
|
if (lcomm) {
|
||||||
attr->lcommunity = lcommunity_intern(attr->lcommunity);
|
if (!lcomm->refcnt)
|
||||||
|
bgp_attr_set_lcommunity(attr, lcommunity_intern(lcomm));
|
||||||
else
|
else
|
||||||
attr->lcommunity->refcnt++;
|
lcomm->refcnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cluster_list *cluster = bgp_attr_get_cluster(attr);
|
struct cluster_list *cluster = bgp_attr_get_cluster(attr);
|
||||||
@ -1021,7 +1024,7 @@ struct attr *bgp_attr_aggregate_intern(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lcommunity) {
|
if (lcommunity) {
|
||||||
attr.lcommunity = lcommunity;
|
bgp_attr_set_lcommunity(&attr, lcommunity);
|
||||||
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES);
|
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1091,6 +1094,7 @@ void bgp_attr_unintern_sub(struct attr *attr)
|
|||||||
struct ecommunity *ecomm = NULL;
|
struct ecommunity *ecomm = NULL;
|
||||||
struct ecommunity *ipv6_ecomm = NULL;
|
struct ecommunity *ipv6_ecomm = NULL;
|
||||||
struct cluster_list *cluster;
|
struct cluster_list *cluster;
|
||||||
|
struct lcommunity *lcomm = NULL;
|
||||||
|
|
||||||
/* aspath refcount shoud be decrement. */
|
/* aspath refcount shoud be decrement. */
|
||||||
if (attr->aspath)
|
if (attr->aspath)
|
||||||
@ -1111,9 +1115,10 @@ void bgp_attr_unintern_sub(struct attr *attr)
|
|||||||
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);
|
||||||
|
|
||||||
if (attr->lcommunity)
|
lcomm = bgp_attr_get_lcommunity(attr);
|
||||||
lcommunity_unintern(&attr->lcommunity);
|
lcommunity_unintern(&lcomm);
|
||||||
UNSET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES));
|
UNSET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES));
|
||||||
|
bgp_attr_set_lcommunity(attr, NULL);
|
||||||
|
|
||||||
cluster = bgp_attr_get_cluster(attr);
|
cluster = bgp_attr_get_cluster(attr);
|
||||||
if (cluster) {
|
if (cluster) {
|
||||||
@ -1177,6 +1182,7 @@ void bgp_attr_flush(struct attr *attr)
|
|||||||
struct ecommunity *ecomm;
|
struct ecommunity *ecomm;
|
||||||
struct ecommunity *ipv6_ecomm;
|
struct ecommunity *ipv6_ecomm;
|
||||||
struct cluster_list *cluster;
|
struct cluster_list *cluster;
|
||||||
|
struct lcommunity *lcomm;
|
||||||
|
|
||||||
if (attr->aspath && !attr->aspath->refcnt) {
|
if (attr->aspath && !attr->aspath->refcnt) {
|
||||||
aspath_free(attr->aspath);
|
aspath_free(attr->aspath);
|
||||||
@ -1192,8 +1198,10 @@ void bgp_attr_flush(struct attr *attr)
|
|||||||
if (ipv6_ecomm && !ipv6_ecomm->refcnt)
|
if (ipv6_ecomm && !ipv6_ecomm->refcnt)
|
||||||
ecommunity_free(&ipv6_ecomm);
|
ecommunity_free(&ipv6_ecomm);
|
||||||
bgp_attr_set_ipv6_ecommunity(attr, NULL);
|
bgp_attr_set_ipv6_ecommunity(attr, NULL);
|
||||||
if (attr->lcommunity && !attr->lcommunity->refcnt)
|
lcomm = bgp_attr_get_lcommunity(attr);
|
||||||
lcommunity_free(&attr->lcommunity);
|
if (lcomm && !lcomm->refcnt)
|
||||||
|
lcommunity_free(&lcomm);
|
||||||
|
bgp_attr_set_lcommunity(attr, NULL);
|
||||||
|
|
||||||
cluster = bgp_attr_get_cluster(attr);
|
cluster = bgp_attr_get_cluster(attr);
|
||||||
if (cluster && !cluster->refcnt) {
|
if (cluster && !cluster->refcnt) {
|
||||||
@ -2271,17 +2279,18 @@ bgp_attr_large_community(struct bgp_attr_parser_args *args)
|
|||||||
* Large community follows new attribute format.
|
* Large community follows new attribute format.
|
||||||
*/
|
*/
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
attr->lcommunity = NULL;
|
bgp_attr_set_lcommunity(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->lcommunity = lcommunity_parse(stream_pnt(peer->curr), length);
|
bgp_attr_set_lcommunity(
|
||||||
|
attr, lcommunity_parse(stream_pnt(peer->curr), length));
|
||||||
/* 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);
|
||||||
|
|
||||||
if (!attr->lcommunity)
|
if (!bgp_attr_get_lcommunity(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);
|
||||||
|
|
||||||
@ -4103,21 +4112,23 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
|
|||||||
if (CHECK_FLAG(peer->af_flags[afi][safi],
|
if (CHECK_FLAG(peer->af_flags[afi][safi],
|
||||||
PEER_FLAG_SEND_LARGE_COMMUNITY)
|
PEER_FLAG_SEND_LARGE_COMMUNITY)
|
||||||
&& (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES))) {
|
&& (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES))) {
|
||||||
if (lcom_length(attr->lcommunity) > 255) {
|
if (lcom_length(bgp_attr_get_lcommunity(attr)) > 255) {
|
||||||
stream_putc(s,
|
stream_putc(s,
|
||||||
BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS
|
BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS
|
||||||
| BGP_ATTR_FLAG_EXTLEN);
|
| BGP_ATTR_FLAG_EXTLEN);
|
||||||
stream_putc(s, BGP_ATTR_LARGE_COMMUNITIES);
|
stream_putc(s, BGP_ATTR_LARGE_COMMUNITIES);
|
||||||
stream_putw(s, lcom_length(attr->lcommunity));
|
stream_putw(s,
|
||||||
|
lcom_length(bgp_attr_get_lcommunity(attr)));
|
||||||
} 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_LARGE_COMMUNITIES);
|
stream_putc(s, BGP_ATTR_LARGE_COMMUNITIES);
|
||||||
stream_putc(s, lcom_length(attr->lcommunity));
|
stream_putc(s,
|
||||||
|
lcom_length(bgp_attr_get_lcommunity(attr)));
|
||||||
}
|
}
|
||||||
stream_put(s, attr->lcommunity->val,
|
stream_put(s, bgp_attr_get_lcommunity(attr)->val,
|
||||||
lcom_length(attr->lcommunity));
|
lcom_length(bgp_attr_get_lcommunity(attr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Route Reflector. */
|
/* Route Reflector. */
|
||||||
@ -4547,22 +4558,24 @@ void bgp_dump_routes_attr(struct stream *s, struct attr *attr,
|
|||||||
|
|
||||||
/* Large Community attribute. */
|
/* Large Community attribute. */
|
||||||
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES)) {
|
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES)) {
|
||||||
if (lcom_length(attr->lcommunity) > 255) {
|
if (lcom_length(bgp_attr_get_lcommunity(attr)) > 255) {
|
||||||
stream_putc(s,
|
stream_putc(s,
|
||||||
BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS
|
BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS
|
||||||
| BGP_ATTR_FLAG_EXTLEN);
|
| BGP_ATTR_FLAG_EXTLEN);
|
||||||
stream_putc(s, BGP_ATTR_LARGE_COMMUNITIES);
|
stream_putc(s, BGP_ATTR_LARGE_COMMUNITIES);
|
||||||
stream_putw(s, lcom_length(attr->lcommunity));
|
stream_putw(s,
|
||||||
|
lcom_length(bgp_attr_get_lcommunity(attr)));
|
||||||
} 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_LARGE_COMMUNITIES);
|
stream_putc(s, BGP_ATTR_LARGE_COMMUNITIES);
|
||||||
stream_putc(s, lcom_length(attr->lcommunity));
|
stream_putc(s,
|
||||||
|
lcom_length(bgp_attr_get_lcommunity(attr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
stream_put(s, attr->lcommunity->val,
|
stream_put(s, bgp_attr_get_lcommunity(attr)->val,
|
||||||
lcom_length(attr->lcommunity));
|
lcom_length(bgp_attr_get_lcommunity(attr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add a MP_NLRI attribute to dump the IPv6 next hop */
|
/* Add a MP_NLRI attribute to dump the IPv6 next hop */
|
||||||
|
@ -531,6 +531,18 @@ static inline void bgp_attr_set_ecommunity(struct attr *attr,
|
|||||||
attr->ecommunity = ecomm;
|
attr->ecommunity = ecomm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct lcommunity *
|
||||||
|
bgp_attr_get_lcommunity(const struct attr *attr)
|
||||||
|
{
|
||||||
|
return attr->lcommunity;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void bgp_attr_set_lcommunity(struct attr *attr,
|
||||||
|
struct lcommunity *lcomm)
|
||||||
|
{
|
||||||
|
attr->lcommunity = lcomm;
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -416,7 +416,7 @@ bool bgp_dump_attr(struct attr *attr, char *buf, size_t size)
|
|||||||
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES)))
|
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES)))
|
||||||
snprintf(buf + strlen(buf), size - strlen(buf),
|
snprintf(buf + strlen(buf), size - strlen(buf),
|
||||||
", large-community %s",
|
", large-community %s",
|
||||||
lcommunity_str(attr->lcommunity, false));
|
lcommunity_str(bgp_attr_get_lcommunity(attr), false));
|
||||||
|
|
||||||
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),
|
||||||
|
@ -1246,17 +1246,23 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
|
|||||||
if (type == bgp_show_type_lcommunity_exact) {
|
if (type == bgp_show_type_lcommunity_exact) {
|
||||||
struct lcommunity *lcom = output_arg;
|
struct lcommunity *lcom = output_arg;
|
||||||
|
|
||||||
if (!pi->attr->lcommunity ||
|
if (!bgp_attr_get_lcommunity(
|
||||||
|
pi->attr) ||
|
||||||
!lcommunity_cmp(
|
!lcommunity_cmp(
|
||||||
pi->attr->lcommunity, lcom))
|
bgp_attr_get_lcommunity(
|
||||||
|
pi->attr),
|
||||||
|
lcom))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (type == bgp_show_type_lcommunity) {
|
if (type == bgp_show_type_lcommunity) {
|
||||||
struct lcommunity *lcom = output_arg;
|
struct lcommunity *lcom = output_arg;
|
||||||
|
|
||||||
if (!pi->attr->lcommunity ||
|
if (!bgp_attr_get_lcommunity(
|
||||||
|
pi->attr) ||
|
||||||
!lcommunity_match(
|
!lcommunity_match(
|
||||||
pi->attr->lcommunity, lcom))
|
bgp_attr_get_lcommunity(
|
||||||
|
pi->attr),
|
||||||
|
lcom))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (type == bgp_show_type_community) {
|
if (type == bgp_show_type_community) {
|
||||||
|
@ -274,6 +274,9 @@ void lcommunity_unintern(struct lcommunity **lcom)
|
|||||||
{
|
{
|
||||||
struct lcommunity *ret;
|
struct lcommunity *ret;
|
||||||
|
|
||||||
|
if (!*lcom)
|
||||||
|
return;
|
||||||
|
|
||||||
if ((*lcom)->refcnt)
|
if ((*lcom)->refcnt)
|
||||||
(*lcom)->refcnt--;
|
(*lcom)->refcnt--;
|
||||||
|
|
||||||
|
@ -846,7 +846,8 @@ void bgp_path_info_mpath_aggregate_update(struct bgp_path_info *new_best,
|
|||||||
ecomm = (bgp_attr_get_ecommunity(&attr))
|
ecomm = (bgp_attr_get_ecommunity(&attr))
|
||||||
? ecommunity_dup(bgp_attr_get_ecommunity(&attr))
|
? ecommunity_dup(bgp_attr_get_ecommunity(&attr))
|
||||||
: NULL;
|
: NULL;
|
||||||
lcomm = (attr.lcommunity) ? lcommunity_dup(attr.lcommunity)
|
lcomm = (bgp_attr_get_lcommunity(&attr))
|
||||||
|
? lcommunity_dup(bgp_attr_get_lcommunity(&attr))
|
||||||
: NULL;
|
: NULL;
|
||||||
|
|
||||||
for (mpinfo = bgp_path_info_mpath_first(new_best); mpinfo;
|
for (mpinfo = bgp_path_info_mpath_first(new_best); mpinfo;
|
||||||
@ -884,16 +885,17 @@ void bgp_path_info_mpath_aggregate_update(struct bgp_path_info *new_best,
|
|||||||
bgp_attr_get_ecommunity(
|
bgp_attr_get_ecommunity(
|
||||||
mpinfo->attr));
|
mpinfo->attr));
|
||||||
}
|
}
|
||||||
if (mpinfo->attr->lcommunity) {
|
if (bgp_attr_get_lcommunity(mpinfo->attr)) {
|
||||||
if (lcomm) {
|
if (lcomm) {
|
||||||
lcommerge = lcommunity_merge(
|
lcommerge = lcommunity_merge(
|
||||||
lcomm,
|
lcomm, bgp_attr_get_lcommunity(
|
||||||
mpinfo->attr->lcommunity);
|
mpinfo->attr));
|
||||||
lcomm = lcommunity_uniq_sort(lcommerge);
|
lcomm = lcommunity_uniq_sort(lcommerge);
|
||||||
lcommunity_free(&lcommerge);
|
lcommunity_free(&lcommerge);
|
||||||
} else
|
} else
|
||||||
lcomm = lcommunity_dup(
|
lcomm = lcommunity_dup(
|
||||||
mpinfo->attr->lcommunity);
|
bgp_attr_get_lcommunity(
|
||||||
|
mpinfo->attr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -908,7 +910,7 @@ void bgp_path_info_mpath_aggregate_update(struct bgp_path_info *new_best,
|
|||||||
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
||||||
}
|
}
|
||||||
if (lcomm) {
|
if (lcomm) {
|
||||||
attr.lcommunity = lcomm;
|
bgp_attr_set_lcommunity(&attr, lcomm);
|
||||||
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES);
|
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7046,7 +7046,7 @@ static bool bgp_aggregate_info_same(struct bgp_path_info *pi, uint8_t origin,
|
|||||||
if (!ecommunity_cmp(bgp_attr_get_ecommunity(pi->attr), 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(bgp_attr_get_lcommunity(pi->attr), lcomm))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!CHECK_FLAG(pi->flags, BGP_PATH_VALID))
|
if (!CHECK_FLAG(pi->flags, BGP_PATH_VALID))
|
||||||
@ -7473,10 +7473,10 @@ void bgp_aggregate_route(struct bgp *bgp, const struct prefix *p, afi_t afi,
|
|||||||
|
|
||||||
/* Compute aggregate route's large community.
|
/* Compute aggregate route's large community.
|
||||||
*/
|
*/
|
||||||
if (pi->attr->lcommunity)
|
if (bgp_attr_get_lcommunity(pi->attr))
|
||||||
bgp_compute_aggregate_lcommunity_hash(
|
bgp_compute_aggregate_lcommunity_hash(
|
||||||
aggregate,
|
aggregate,
|
||||||
pi->attr->lcommunity);
|
bgp_attr_get_lcommunity(pi->attr));
|
||||||
}
|
}
|
||||||
if (match)
|
if (match)
|
||||||
bgp_process(bgp, dest, afi, safi);
|
bgp_process(bgp, dest, afi, safi);
|
||||||
@ -7596,12 +7596,13 @@ void bgp_aggregate_delete(struct bgp *bgp, const struct prefix *p, afi_t afi,
|
|||||||
bgp_attr_get_ecommunity(
|
bgp_attr_get_ecommunity(
|
||||||
pi->attr));
|
pi->attr));
|
||||||
|
|
||||||
if (pi->attr->lcommunity)
|
if (bgp_attr_get_lcommunity(pi->attr))
|
||||||
/* Remove lcommunity from aggregate.
|
/* Remove lcommunity from aggregate.
|
||||||
*/
|
*/
|
||||||
bgp_remove_lcomm_from_aggregate_hash(
|
bgp_remove_lcomm_from_aggregate_hash(
|
||||||
aggregate,
|
aggregate,
|
||||||
pi->attr->lcommunity);
|
bgp_attr_get_lcommunity(
|
||||||
|
pi->attr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7714,10 +7715,10 @@ static void bgp_add_route_to_aggregate(struct bgp *bgp,
|
|||||||
|
|
||||||
/* Compute aggregate route's large community.
|
/* Compute aggregate route's large community.
|
||||||
*/
|
*/
|
||||||
if (pinew->attr->lcommunity)
|
if (bgp_attr_get_lcommunity(pinew->attr))
|
||||||
bgp_compute_aggregate_lcommunity(
|
bgp_compute_aggregate_lcommunity(
|
||||||
aggregate,
|
aggregate,
|
||||||
pinew->attr->lcommunity);
|
bgp_attr_get_lcommunity(pinew->attr));
|
||||||
|
|
||||||
/* Retrieve aggregate route's as-path.
|
/* Retrieve aggregate route's as-path.
|
||||||
*/
|
*/
|
||||||
@ -7816,12 +7817,11 @@ static void bgp_remove_route_from_aggregate(struct bgp *bgp, afi_t afi,
|
|||||||
bgp_remove_ecommunity_from_aggregate(
|
bgp_remove_ecommunity_from_aggregate(
|
||||||
aggregate, bgp_attr_get_ecommunity(pi->attr));
|
aggregate, bgp_attr_get_ecommunity(pi->attr));
|
||||||
|
|
||||||
if (pi->attr->lcommunity)
|
if (bgp_attr_get_lcommunity(pi->attr))
|
||||||
/* Remove lcommunity from aggregate.
|
/* Remove lcommunity from aggregate.
|
||||||
*/
|
*/
|
||||||
bgp_remove_lcommunity_from_aggregate(
|
bgp_remove_lcommunity_from_aggregate(
|
||||||
aggregate,
|
aggregate, bgp_attr_get_lcommunity(pi->attr));
|
||||||
pi->attr->lcommunity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If this node was suppressed, process the change. */
|
/* If this node was suppressed, process the change. */
|
||||||
@ -10517,14 +10517,16 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
|
|||||||
/* Line 6 display Large community */
|
/* Line 6 display Large community */
|
||||||
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES)) {
|
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES)) {
|
||||||
if (json_paths) {
|
if (json_paths) {
|
||||||
if (!attr->lcommunity->json)
|
if (!bgp_attr_get_lcommunity(attr)->json)
|
||||||
lcommunity_str(attr->lcommunity, true);
|
lcommunity_str(bgp_attr_get_lcommunity(attr),
|
||||||
json_object_lock(attr->lcommunity->json);
|
true);
|
||||||
json_object_object_add(json_path, "largeCommunity",
|
json_object_lock(bgp_attr_get_lcommunity(attr)->json);
|
||||||
attr->lcommunity->json);
|
json_object_object_add(
|
||||||
|
json_path, "largeCommunity",
|
||||||
|
bgp_attr_get_lcommunity(attr)->json);
|
||||||
} else {
|
} else {
|
||||||
vty_out(vty, " Large Community: %s\n",
|
vty_out(vty, " Large Community: %s\n",
|
||||||
attr->lcommunity->str);
|
bgp_attr_get_lcommunity(attr)->str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10909,8 +10911,11 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
|
|||||||
XFREE(MTYPE_TMP, communities);
|
XFREE(MTYPE_TMP, communities);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found && pi->attr->lcommunity) {
|
if (!found &&
|
||||||
frrstr_split(pi->attr->lcommunity->str,
|
bgp_attr_get_lcommunity(pi->attr)) {
|
||||||
|
frrstr_split(bgp_attr_get_lcommunity(
|
||||||
|
pi->attr)
|
||||||
|
->str,
|
||||||
" ", &communities, &num);
|
" ", &communities, &num);
|
||||||
for (int i = 0; i < num; i++) {
|
for (int i = 0; i < num; i++) {
|
||||||
const char *com2alias =
|
const char *com2alias =
|
||||||
@ -11050,8 +11055,9 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
|
|||||||
if (type == bgp_show_type_lcommunity) {
|
if (type == bgp_show_type_lcommunity) {
|
||||||
struct lcommunity *lcom = output_arg;
|
struct lcommunity *lcom = output_arg;
|
||||||
|
|
||||||
if (!pi->attr->lcommunity
|
if (!bgp_attr_get_lcommunity(pi->attr) ||
|
||||||
|| !lcommunity_match(pi->attr->lcommunity,
|
!lcommunity_match(
|
||||||
|
bgp_attr_get_lcommunity(pi->attr),
|
||||||
lcom))
|
lcom))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -11059,15 +11065,17 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
|
|||||||
if (type == bgp_show_type_lcommunity_exact) {
|
if (type == bgp_show_type_lcommunity_exact) {
|
||||||
struct lcommunity *lcom = output_arg;
|
struct lcommunity *lcom = output_arg;
|
||||||
|
|
||||||
if (!pi->attr->lcommunity
|
if (!bgp_attr_get_lcommunity(pi->attr) ||
|
||||||
|| !lcommunity_cmp(pi->attr->lcommunity,
|
!lcommunity_cmp(
|
||||||
|
bgp_attr_get_lcommunity(pi->attr),
|
||||||
lcom))
|
lcom))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (type == bgp_show_type_lcommunity_list) {
|
if (type == bgp_show_type_lcommunity_list) {
|
||||||
struct community_list *list = output_arg;
|
struct community_list *list = output_arg;
|
||||||
|
|
||||||
if (!lcommunity_list_match(pi->attr->lcommunity,
|
if (!lcommunity_list_match(
|
||||||
|
bgp_attr_get_lcommunity(pi->attr),
|
||||||
list))
|
list))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -11076,11 +11084,12 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
|
|||||||
struct community_list *list = output_arg;
|
struct community_list *list = output_arg;
|
||||||
|
|
||||||
if (!lcommunity_list_exact_match(
|
if (!lcommunity_list_exact_match(
|
||||||
pi->attr->lcommunity, list))
|
bgp_attr_get_lcommunity(pi->attr),
|
||||||
|
list))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (type == bgp_show_type_lcommunity_all) {
|
if (type == bgp_show_type_lcommunity_all) {
|
||||||
if (!pi->attr->lcommunity)
|
if (!bgp_attr_get_lcommunity(pi->attr))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (type == bgp_show_type_dampend_paths
|
if (type == bgp_show_type_dampend_paths
|
||||||
|
@ -1258,10 +1258,10 @@ route_match_alias(void *rule, const struct prefix *prefix, void *object)
|
|||||||
return RMAP_MATCH;
|
return RMAP_MATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path->attr->lcommunity) {
|
if (bgp_attr_get_lcommunity(path->attr)) {
|
||||||
found = false;
|
found = false;
|
||||||
frrstr_split(path->attr->lcommunity->str, " ", &communities,
|
frrstr_split(bgp_attr_get_lcommunity(path->attr)->str, " ",
|
||||||
&num);
|
&communities, &num);
|
||||||
for (int i = 0; i < num; i++) {
|
for (int i = 0; i < num; i++) {
|
||||||
const char *com2alias =
|
const char *com2alias =
|
||||||
bgp_community2alias(communities[i]);
|
bgp_community2alias(communities[i]);
|
||||||
@ -1521,10 +1521,12 @@ route_match_lcommunity(void *rule, const struct prefix *prefix, void *object)
|
|||||||
return RMAP_NOMATCH;
|
return RMAP_NOMATCH;
|
||||||
|
|
||||||
if (rcom->exact) {
|
if (rcom->exact) {
|
||||||
if (lcommunity_list_exact_match(path->attr->lcommunity, list))
|
if (lcommunity_list_exact_match(
|
||||||
|
bgp_attr_get_lcommunity(path->attr), list))
|
||||||
return RMAP_MATCH;
|
return RMAP_MATCH;
|
||||||
} else {
|
} else {
|
||||||
if (lcommunity_list_match(path->attr->lcommunity, list))
|
if (lcommunity_list_match(bgp_attr_get_lcommunity(path->attr),
|
||||||
|
list))
|
||||||
return RMAP_MATCH;
|
return RMAP_MATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2301,12 +2303,12 @@ route_set_lcommunity(void *rule, const struct prefix *prefix, void *object)
|
|||||||
rcs = rule;
|
rcs = rule;
|
||||||
path = object;
|
path = object;
|
||||||
attr = path->attr;
|
attr = path->attr;
|
||||||
old = attr->lcommunity;
|
old = bgp_attr_get_lcommunity(attr);
|
||||||
|
|
||||||
/* "none" case. */
|
/* "none" case. */
|
||||||
if (rcs->none) {
|
if (rcs->none) {
|
||||||
attr->flag &= ~(ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES));
|
attr->flag &= ~(ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES));
|
||||||
attr->lcommunity = NULL;
|
bgp_attr_set_lcommunity(attr, NULL);
|
||||||
|
|
||||||
/* See the longer comment down below. */
|
/* See the longer comment down below. */
|
||||||
if (old && old->refcnt == 0)
|
if (old && old->refcnt == 0)
|
||||||
@ -2331,7 +2333,7 @@ route_set_lcommunity(void *rule, const struct prefix *prefix, void *object)
|
|||||||
lcommunity_free(&old);
|
lcommunity_free(&old);
|
||||||
|
|
||||||
/* will be intern()'d or attr_flush()'d by bgp_update_main() */
|
/* will be intern()'d or attr_flush()'d by bgp_update_main() */
|
||||||
attr->lcommunity = new;
|
bgp_attr_set_lcommunity(attr, new);
|
||||||
|
|
||||||
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES);
|
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES);
|
||||||
|
|
||||||
@ -2413,7 +2415,7 @@ route_set_lcommunity_delete(void *rule, const struct prefix *pfx, void *object)
|
|||||||
path = object;
|
path = object;
|
||||||
list = community_list_lookup(bgp_clist, rcom->name, rcom->name_hash,
|
list = community_list_lookup(bgp_clist, rcom->name, rcom->name_hash,
|
||||||
LARGE_COMMUNITY_LIST_MASTER);
|
LARGE_COMMUNITY_LIST_MASTER);
|
||||||
old = path->attr->lcommunity;
|
old = bgp_attr_get_lcommunity(path->attr);
|
||||||
|
|
||||||
if (list && old) {
|
if (list && old) {
|
||||||
merge = lcommunity_list_match_delete(lcommunity_dup(old), list);
|
merge = lcommunity_list_match_delete(lcommunity_dup(old), list);
|
||||||
@ -2429,12 +2431,12 @@ route_set_lcommunity_delete(void *rule, const struct prefix *pfx, void *object)
|
|||||||
lcommunity_free(&old);
|
lcommunity_free(&old);
|
||||||
|
|
||||||
if (new->size == 0) {
|
if (new->size == 0) {
|
||||||
path->attr->lcommunity = NULL;
|
bgp_attr_set_lcommunity(path->attr, NULL);
|
||||||
path->attr->flag &=
|
path->attr->flag &=
|
||||||
~ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES);
|
~ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES);
|
||||||
lcommunity_free(&new);
|
lcommunity_free(&new);
|
||||||
} else {
|
} else {
|
||||||
path->attr->lcommunity = new;
|
bgp_attr_set_lcommunity(path->attr, new);
|
||||||
path->attr->flag |=
|
path->attr->flag |=
|
||||||
ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES);
|
ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES);
|
||||||
}
|
}
|
||||||
|
@ -1502,7 +1502,8 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
|
|||||||
|
|
||||||
if (info->attr->flag
|
if (info->attr->flag
|
||||||
& ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES))
|
& ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES))
|
||||||
strlcpy(bzo.lcommunity, info->attr->lcommunity->str,
|
strlcpy(bzo.lcommunity,
|
||||||
|
bgp_attr_get_lcommunity(info->attr)->str,
|
||||||
sizeof(bzo.lcommunity));
|
sizeof(bzo.lcommunity));
|
||||||
|
|
||||||
strlcpy(bzo.selection_reason, reason,
|
strlcpy(bzo.selection_reason, reason,
|
||||||
|
Loading…
Reference in New Issue
Block a user