mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-12 14:27:36 +00:00
bgpd: Reuse bgp_attr_set_[l]community() for setting attribute flags
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
This commit is contained in:
parent
695c24c3b0
commit
9d34440bf8
@ -1008,7 +1008,6 @@ struct attr *bgp_attr_aggregate_intern(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bgp_attr_set_community(&attr, community);
|
bgp_attr_set_community(&attr, community);
|
||||||
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ecommunity) {
|
if (ecommunity) {
|
||||||
@ -1016,10 +1015,8 @@ struct attr *bgp_attr_aggregate_intern(
|
|||||||
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lcommunity) {
|
if (lcommunity)
|
||||||
bgp_attr_set_lcommunity(&attr, lcommunity);
|
bgp_attr_set_lcommunity(&attr, lcommunity);
|
||||||
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bgp_in_graceful_shutdown(bgp))
|
if (bgp_in_graceful_shutdown(bgp))
|
||||||
bgp_attr_add_gshut_community(&attr);
|
bgp_attr_add_gshut_community(&attr);
|
||||||
@ -1096,7 +1093,6 @@ void bgp_attr_unintern_sub(struct attr *attr)
|
|||||||
|
|
||||||
comm = bgp_attr_get_community(attr);
|
comm = bgp_attr_get_community(attr);
|
||||||
community_unintern(&comm);
|
community_unintern(&comm);
|
||||||
UNSET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES));
|
|
||||||
bgp_attr_set_community(attr, NULL);
|
bgp_attr_set_community(attr, NULL);
|
||||||
|
|
||||||
ecomm = bgp_attr_get_ecommunity(attr);
|
ecomm = bgp_attr_get_ecommunity(attr);
|
||||||
@ -1111,7 +1107,6 @@ void bgp_attr_unintern_sub(struct attr *attr)
|
|||||||
|
|
||||||
lcomm = bgp_attr_get_lcommunity(attr);
|
lcomm = bgp_attr_get_lcommunity(attr);
|
||||||
lcommunity_unintern(&lcomm);
|
lcommunity_unintern(&lcomm);
|
||||||
UNSET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES));
|
|
||||||
bgp_attr_set_lcommunity(attr, NULL);
|
bgp_attr_set_lcommunity(attr, NULL);
|
||||||
|
|
||||||
cluster = bgp_attr_get_cluster(attr);
|
cluster = bgp_attr_get_cluster(attr);
|
||||||
@ -1963,8 +1958,6 @@ bgp_attr_community(struct bgp_attr_parser_args *args)
|
|||||||
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->flag |= ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES);
|
|
||||||
|
|
||||||
return BGP_ATTR_PARSE_PROCEED;
|
return BGP_ATTR_PARSE_PROCEED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2294,8 +2287,6 @@ bgp_attr_large_community(struct bgp_attr_parser_args *args)
|
|||||||
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->flag |= ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES);
|
|
||||||
|
|
||||||
return BGP_ATTR_PARSE_PROCEED;
|
return BGP_ATTR_PARSE_PROCEED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -528,6 +528,12 @@ static inline void bgp_attr_set_lcommunity(struct attr *attr,
|
|||||||
struct lcommunity *lcomm)
|
struct lcommunity *lcomm)
|
||||||
{
|
{
|
||||||
attr->lcommunity = lcomm;
|
attr->lcommunity = lcomm;
|
||||||
|
|
||||||
|
if (lcomm)
|
||||||
|
SET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES));
|
||||||
|
else
|
||||||
|
UNSET_FLAG(attr->flag,
|
||||||
|
ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct community *bgp_attr_get_community(const struct attr *attr)
|
static inline struct community *bgp_attr_get_community(const struct attr *attr)
|
||||||
@ -539,6 +545,11 @@ static inline void bgp_attr_set_community(struct attr *attr,
|
|||||||
struct community *comm)
|
struct community *comm)
|
||||||
{
|
{
|
||||||
attr->community = comm;
|
attr->community = comm;
|
||||||
|
|
||||||
|
if (comm)
|
||||||
|
SET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES));
|
||||||
|
else
|
||||||
|
UNSET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct ecommunity *
|
static inline struct ecommunity *
|
||||||
|
@ -907,16 +907,13 @@ void bgp_path_info_mpath_aggregate_update(struct bgp_path_info *new_best,
|
|||||||
attr.origin = origin;
|
attr.origin = origin;
|
||||||
if (community) {
|
if (community) {
|
||||||
bgp_attr_set_community(&attr, community);
|
bgp_attr_set_community(&attr, community);
|
||||||
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES);
|
|
||||||
}
|
}
|
||||||
if (ecomm) {
|
if (ecomm) {
|
||||||
bgp_attr_set_ecommunity(&attr, 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)
|
||||||
bgp_attr_set_lcommunity(&attr, lcomm);
|
bgp_attr_set_lcommunity(&attr, lcomm);
|
||||||
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Zap multipath attr nexthop so we set nexthop to self */
|
/* Zap multipath attr nexthop so we set nexthop to self */
|
||||||
attr.nexthop.s_addr = INADDR_ANY;
|
attr.nexthop.s_addr = INADDR_ANY;
|
||||||
|
@ -1769,7 +1769,6 @@ void bgp_attr_add_llgr_community(struct attr *attr)
|
|||||||
community_free(&llgr);
|
community_free(&llgr);
|
||||||
|
|
||||||
bgp_attr_set_community(attr, new);
|
bgp_attr_set_community(attr, new);
|
||||||
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void bgp_attr_add_gshut_community(struct attr *attr)
|
void bgp_attr_add_gshut_community(struct attr *attr)
|
||||||
@ -1798,7 +1797,6 @@ void bgp_attr_add_gshut_community(struct attr *attr)
|
|||||||
|
|
||||||
community_free(&gshut);
|
community_free(&gshut);
|
||||||
bgp_attr_set_community(attr, new);
|
bgp_attr_set_community(attr, new);
|
||||||
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES);
|
|
||||||
|
|
||||||
/* When we add the graceful-shutdown community we must also
|
/* When we add the graceful-shutdown community we must also
|
||||||
* lower the local-preference */
|
* lower the local-preference */
|
||||||
@ -3711,7 +3709,6 @@ static void bgp_attr_add_no_export_community(struct attr *attr)
|
|||||||
community_free(&no_export);
|
community_free(&no_export);
|
||||||
|
|
||||||
bgp_attr_set_community(attr, new);
|
bgp_attr_set_community(attr, new);
|
||||||
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
|
int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
|
||||||
|
@ -2199,7 +2199,6 @@ route_set_community(void *rule, const struct prefix *prefix, void *object)
|
|||||||
|
|
||||||
/* "none" case. */
|
/* "none" case. */
|
||||||
if (rcs->none) {
|
if (rcs->none) {
|
||||||
attr->flag &= ~(ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES));
|
|
||||||
bgp_attr_set_community(attr, NULL);
|
bgp_attr_set_community(attr, NULL);
|
||||||
/* See the longer comment down below. */
|
/* See the longer comment down below. */
|
||||||
if (old && old->refcnt == 0)
|
if (old && old->refcnt == 0)
|
||||||
@ -2227,8 +2226,6 @@ route_set_community(void *rule, const struct prefix *prefix, void *object)
|
|||||||
/* will be interned by caller if required */
|
/* will be interned by caller if required */
|
||||||
bgp_attr_set_community(attr, new);
|
bgp_attr_set_community(attr, new);
|
||||||
|
|
||||||
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES);
|
|
||||||
|
|
||||||
return RMAP_OKAY;
|
return RMAP_OKAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2313,7 +2310,6 @@ route_set_lcommunity(void *rule, const struct prefix *prefix, void *object)
|
|||||||
|
|
||||||
/* "none" case. */
|
/* "none" case. */
|
||||||
if (rcs->none) {
|
if (rcs->none) {
|
||||||
attr->flag &= ~(ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES));
|
|
||||||
bgp_attr_set_lcommunity(attr, NULL);
|
bgp_attr_set_lcommunity(attr, NULL);
|
||||||
|
|
||||||
/* See the longer comment down below. */
|
/* See the longer comment down below. */
|
||||||
@ -2341,8 +2337,6 @@ route_set_lcommunity(void *rule, const struct prefix *prefix, void *object)
|
|||||||
/* will be intern()'d or attr_flush()'d by bgp_update_main() */
|
/* will be intern()'d or attr_flush()'d by bgp_update_main() */
|
||||||
bgp_attr_set_lcommunity(attr, new);
|
bgp_attr_set_lcommunity(attr, new);
|
||||||
|
|
||||||
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES);
|
|
||||||
|
|
||||||
return RMAP_OKAY;
|
return RMAP_OKAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2438,13 +2432,9 @@ route_set_lcommunity_delete(void *rule, const struct prefix *pfx, void *object)
|
|||||||
|
|
||||||
if (new->size == 0) {
|
if (new->size == 0) {
|
||||||
bgp_attr_set_lcommunity(path->attr, NULL);
|
bgp_attr_set_lcommunity(path->attr, NULL);
|
||||||
path->attr->flag &=
|
|
||||||
~ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES);
|
|
||||||
lcommunity_free(&new);
|
lcommunity_free(&new);
|
||||||
} else {
|
} else {
|
||||||
bgp_attr_set_lcommunity(path->attr, new);
|
bgp_attr_set_lcommunity(path->attr, new);
|
||||||
path->attr->flag |=
|
|
||||||
ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2526,12 +2516,9 @@ route_set_community_delete(void *rule, const struct prefix *prefix,
|
|||||||
|
|
||||||
if (new->size == 0) {
|
if (new->size == 0) {
|
||||||
bgp_attr_set_community(path->attr, NULL);
|
bgp_attr_set_community(path->attr, NULL);
|
||||||
path->attr->flag &=
|
|
||||||
~ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES);
|
|
||||||
community_free(&new);
|
community_free(&new);
|
||||||
} else {
|
} else {
|
||||||
bgp_attr_set_community(path->attr, new);
|
bgp_attr_set_community(path->attr, new);
|
||||||
path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user