]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Reuse bgp_attr_set_ecommunity() for setting attribute flags
authorDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 12 Apr 2022 08:06:52 +0000 (11:06 +0300)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 12 Apr 2022 19:09:28 +0000 (22:09 +0300)
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
bgpd/bgp_attr.c
bgpd/bgp_attr.h
bgpd/bgp_evpn.c
bgpd/bgp_evpn_mh.c
bgpd/bgp_mpath.c
bgpd/bgp_mplsvpn.c
bgpd/bgp_routemap.c
bgpd/rfapi/rfapi.c
bgpd/rfapi/vnc_export_bgp.c

index 310227f33a4e85e5d1146d6d60251a95aeb31840..628d7001881a6a210b71b58d422d3b740d2fa039 100644 (file)
@@ -1010,10 +1010,8 @@ struct attr *bgp_attr_aggregate_intern(
                bgp_attr_set_community(&attr, community);
        }
 
-       if (ecommunity) {
+       if (ecommunity)
                bgp_attr_set_ecommunity(&attr, ecommunity);
-               attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
-       }
 
        if (lcommunity)
                bgp_attr_set_lcommunity(&attr, lcommunity);
@@ -1097,12 +1095,10 @@ void bgp_attr_unintern_sub(struct attr *attr)
 
        ecomm = bgp_attr_get_ecommunity(attr);
        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));
        bgp_attr_set_ipv6_ecommunity(attr, NULL);
 
        lcomm = bgp_attr_get_lcommunity(attr);
@@ -2323,8 +2319,6 @@ bgp_attr_ext_communities(struct bgp_attr_parser_args *args)
                return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_OPT_ATTR_ERR,
                                          args->total);
 
-       attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
-
        /* Extract DF election preference and  mobility sequence number */
        attr->df_pref = bgp_attr_df_pref_from_ec(attr, &attr->df_alg);
 
@@ -2394,8 +2388,6 @@ bgp_attr_ipv6_ext_communities(struct bgp_attr_parser_args *args)
                return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_OPT_ATTR_ERR,
                                          args->total);
 
-       attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_IPV6_EXT_COMMUNITIES);
-
        return BGP_ATTR_PARSE_PROCEED;
 }
 
index 49702a0e31b1cec81184c031ca06d05b51a1c37b..4ed0ca5e7a0997af7ad35d3ce35e9053fa10d6ac 100644 (file)
@@ -516,6 +516,11 @@ static inline void bgp_attr_set_ecommunity(struct attr *attr,
                                           struct ecommunity *ecomm)
 {
        attr->ecommunity = ecomm;
+
+       if (ecomm)
+               SET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES));
+       else
+               UNSET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES));
 }
 
 static inline struct lcommunity *
@@ -562,6 +567,13 @@ static inline void bgp_attr_set_ipv6_ecommunity(struct attr *attr,
                                                struct ecommunity *ipv6_ecomm)
 {
        attr->ipv6_ecommunity = ipv6_ecomm;
+
+       if (ipv6_ecomm)
+               SET_FLAG(attr->flag,
+                        ATTR_FLAG_BIT(BGP_ATTR_IPV6_EXT_COMMUNITIES));
+       else
+               UNSET_FLAG(attr->flag,
+                          ATTR_FLAG_BIT(BGP_ATTR_IPV6_EXT_COMMUNITIES));
 }
 
 static inline struct transit *bgp_attr_get_transit(const struct attr *attr)
index 9f3f8389ad226f67a921c387b3f5ecb9ca27e271..3224c1a2b04c671e45694447651196edafb02dd1 100644 (file)
@@ -759,8 +759,6 @@ static void build_evpn_type5_route_extcomm(struct bgp *bgp_vrf,
                ecommunity_add_val(bgp_attr_get_ecommunity(attr), &eval_rmac,
                                   true, true);
        }
-
-       attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
 }
 
 /*
@@ -870,8 +868,6 @@ static void build_evpn_route_extcomm(struct bgpevpn *vpn, struct attr *attr,
                        attr, ecommunity_merge(bgp_attr_get_ecommunity(attr),
                                               &ecom_na));
        }
-
-       attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
 }
 
 /*
index f6516d220c2d87f46f27ee419f3eb83391750e51..d3460674beb4ed034084f79de1093676a9b0b154 100644 (file)
@@ -622,8 +622,6 @@ static void bgp_evpn_type4_route_extcomm_build(struct bgp_evpn_es *es,
        bgp_attr_set_ecommunity(
                attr,
                ecommunity_merge(bgp_attr_get_ecommunity(attr), &ecom_df));
-
-       attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
 }
 
 /* Create or update local type-4 route */
@@ -904,8 +902,6 @@ bgp_evpn_type1_es_route_extcomm_build(struct bgp_evpn_es_frag *es_frag,
                                                               ecom));
                }
        }
-
-       attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
 }
 
 /* Extended communities associated with EAD-per-EVI */
@@ -932,8 +928,6 @@ static void bgp_evpn_type1_evi_route_extcomm_build(struct bgp_evpn_es *es,
                bgp_attr_set_ecommunity(
                        attr,
                        ecommunity_merge(bgp_attr_get_ecommunity(attr), ecom));
-
-       attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
 }
 
 /* Update EVPN EAD (type-1) route -
index 7ff0df74092f1570d29afbdfc376ef791601c5df..37d2c45215ec8426ea752cf27a74396616bfb7ad 100644 (file)
@@ -908,10 +908,8 @@ void bgp_path_info_mpath_aggregate_update(struct bgp_path_info *new_best,
                if (community) {
                        bgp_attr_set_community(&attr, community);
                }
-               if (ecomm) {
+               if (ecomm)
                        bgp_attr_set_ecommunity(&attr, ecomm);
-                       attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
-               }
                if (lcomm)
                        bgp_attr_set_lcommunity(&attr, lcomm);
 
index 08a68d0c123140e81225956988135e7d421d2ee3..defe367484ca3117bccde9cd29db887142e22241 100644 (file)
@@ -1147,7 +1147,6 @@ void vpn_leak_from_vrf_update(struct bgp *bgp_vpn,            /* to */
                                .rtlist[BGP_VPN_POLICY_DIR_TOVPN]);
        }
        bgp_attr_set_ecommunity(&static_attr, new_ecom);
-       SET_FLAG(static_attr.flag, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES));
 
        if (debug && bgp_attr_get_ecommunity(&static_attr)) {
                char *s = ecommunity_ecom2str(
@@ -1511,8 +1510,6 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf,            /* to */
                bgp_attr_set_ecommunity(&static_attr, new_ecom);
 
                if (new_ecom->size == 0) {
-                       UNSET_FLAG(static_attr.flag,
-                                  ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES));
                        ecommunity_free(&new_ecom);
                        bgp_attr_set_ecommunity(&static_attr, NULL);
                }
index df92a24ce15e4abe6b8d9977a29324c238fd98d6..6ab753f476d7d7b13fb954ff576b1982dd6652f3 100644 (file)
@@ -2584,7 +2584,6 @@ route_set_ecommunity(void *rule, const struct prefix *prefix, void *object)
        attr = path->attr;
 
        if (rcs->none) {
-               attr->flag &= ~(ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES));
                bgp_attr_set_ecommunity(attr, NULL);
                return RMAP_OKAY;
        }
@@ -2611,8 +2610,6 @@ route_set_ecommunity(void *rule, const struct prefix *prefix, void *object)
        /* will be intern()'d or attr_flush()'d by bgp_update_main() */
        bgp_attr_set_ecommunity(path->attr, new_ecom);
 
-       path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
-
        return RMAP_OKAY;
 }
 
@@ -2774,7 +2771,6 @@ 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 */
        bgp_attr_set_ecommunity(path->attr, new_ecom);
-       path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
 
        /* Mark that route-map has set link bandwidth; used in attribute
         * setting decisions.
index c96c321d7674b0e910e2db23c7c0828db20010d0..3aa88683745a5e534cea28698c62776540abd18e 100644 (file)
@@ -832,9 +832,7 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
 
        struct ecommunity *ecomm = bgp_attr_get_ecommunity(&attr);
 
-       if (ecomm->size) {
-               attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
-       } else {
+       if (!ecomm->size) {
                ecommunity_free(&ecomm);
                bgp_attr_set_ecommunity(&attr, NULL);
        }
index f4f2e11391c5f634346a8b01eed042e0fae99156..c479b4d65a9f4884f0cad849aaac0d6e83c8fafc 100644 (file)
@@ -650,9 +650,6 @@ encap_attr_export(struct attr *new, struct attr *orig,
        } else {
                bgp_attr_set_ecommunity(new, ecom_ro);
        }
-       if (ecom_ro) {
-               new->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
-       }
 
        /*
         * Set MED