]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Handle non-transitive opaque extended communities also for eBGP peers 17151/head
authorDonatas Abraitis <donatas@opensourcerouting.org>
Thu, 17 Oct 2024 11:24:32 +0000 (14:24 +0300)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 22 Oct 2024 06:02:50 +0000 (09:02 +0300)
Fixes: 765a0855f1ffec68ed42f2fac8afcaaeed99fd1a ("bgpd: Rework extended community transitiviness")
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
bgpd/bgp_ecommunity.c
bgpd/bgp_ecommunity.h

index 0443203fe0ed262d7b5934d0ca946d30b5b913ac..df32d751031683205e6e32204b40e0bdaf47c8d5 100644 (file)
@@ -1408,10 +1408,12 @@ char *ecommunity_ecom2str(struct ecommunity *ecom, int format, int filter)
                                         "FS:marking %u", *(pnt + 5));
                        } else
                                unk_ecom = true;
-               } else if (CHECK_FLAG(type, ECOMMUNITY_ENCODE_AS_NON_TRANS) ||
-                          CHECK_FLAG(type, ECOMMUNITY_FLAG_NON_TRANSITIVE)) {
+               } else if (CHECK_FLAG(type, ECOMMUNITY_FLAG_NON_TRANSITIVE) ||
+                          type == ECOMMUNITY_ENCODE_OPAQUE_NON_TRANS) {
                        sub_type = *pnt++;
-                       if (sub_type == ECOMMUNITY_LINK_BANDWIDTH)
+                       if (sub_type == ECOMMUNITY_ORIGIN_VALIDATION_STATE)
+                               ecommunity_origin_validation_state_str(encbuf, sizeof(encbuf), pnt);
+                       else if (sub_type == ECOMMUNITY_LINK_BANDWIDTH)
                                ecommunity_lb_str(encbuf, sizeof(encbuf), pnt,
                                                  ecom->disable_ieee_floating);
                        else if (sub_type == ECOMMUNITY_EXTENDED_LINK_BANDWIDTH)
@@ -1426,13 +1428,6 @@ char *ecommunity_ecom2str(struct ecommunity *ecom, int format, int filter)
                                        encbuf, sizeof(encbuf), pnt, format);
                        else
                                unk_ecom = true;
-               } else if (type == ECOMMUNITY_ENCODE_OPAQUE_NON_TRANS) {
-                       sub_type = *pnt++;
-                       if (sub_type == ECOMMUNITY_ORIGIN_VALIDATION_STATE)
-                               ecommunity_origin_validation_state_str(
-                                       encbuf, sizeof(encbuf), pnt);
-                       else
-                               unk_ecom = true;
                } else {
                        sub_type = *pnt++;
                        unk_ecom = true;
@@ -1588,6 +1583,13 @@ bool ecommunity_strip(struct ecommunity *ecom, uint8_t type,
        return true;
 }
 
+static bool ecommunity_non_transitive(uint8_t type)
+{
+       return (CHECK_FLAG(type, ECOMMUNITY_FLAG_NON_TRANSITIVE) ||
+               CHECK_FLAG(type, ECOMMUNITY_ENCODE_IP_NON_TRANS) ||
+               type == ECOMMUNITY_ENCODE_OPAQUE_NON_TRANS);
+}
+
 /* Delete all non-transitive extended communities */
 bool ecommunity_strip_non_transitive(struct ecommunity *ecom)
 {
@@ -1602,7 +1604,7 @@ bool ecommunity_strip_non_transitive(struct ecommunity *ecom)
         */
        c = 0;
        for (p = ecom->val; c < ecom->size; p += ecom->unit_size, c++)
-               if (CHECK_FLAG(*p, ECOMMUNITY_FLAG_NON_TRANSITIVE))
+               if (ecommunity_non_transitive(*p))
                        found++;
 
        if (!found)
@@ -1619,7 +1621,7 @@ bool ecommunity_strip_non_transitive(struct ecommunity *ecom)
        new = XMALLOC(MTYPE_ECOMMUNITY_VAL, (ecom->size - found) * ecom->unit_size);
        q = new;
        for (c = 0, p = ecom->val; c < ecom->size; c++, p += ecom->unit_size) {
-               if (!CHECK_FLAG(*p, ECOMMUNITY_FLAG_NON_TRANSITIVE)) {
+               if (!ecommunity_non_transitive(*p)) {
                        memcpy(q, p, ecom->unit_size);
                        q += ecom->unit_size;
                }
@@ -1928,9 +1930,7 @@ const uint8_t *ecommunity_linkbw_present(struct ecommunity *ecom, uint64_t *bw)
                if (len < ecom->unit_size)
                        return NULL;
 
-               if ((type == ECOMMUNITY_ENCODE_AS ||
-                    type == ECOMMUNITY_ENCODE_AS_NON_TRANS) &&
-                   sub_type == ECOMMUNITY_LINK_BANDWIDTH) {
+               if ((type == ECOMMUNITY_ENCODE_AS) && sub_type == ECOMMUNITY_LINK_BANDWIDTH) {
                        uint32_t bwval;
 
                        pnt += 2; /* bandwidth is encoded as AS:val */
index e076885fb57c2205499b9a63a7fc5027984f1d07..0544cbd316e0f6fdd55a0900333eb6b2cb5e921d 100644 (file)
@@ -32,9 +32,7 @@
 #define ECOMMUNITY_EXTENDED_COMMUNITY_PART_3 0x82
 
 /* Non-transitive extended community types. */
-#define ECOMMUNITY_ENCODE_AS_NON_TRANS      0x40
 #define ECOMMUNITY_ENCODE_IP_NON_TRANS      0x41
-#define ECOMMUNITY_ENCODE_AS4_NON_TRANS     0x42
 #define ECOMMUNITY_ENCODE_OPAQUE_NON_TRANS  0x43
 
 /* Low-order octet of the Extended Communities type field.  */