summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_ecommunity.c30
-rw-r--r--bgpd/bgp_ecommunity.h2
2 files changed, 15 insertions, 17 deletions
diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c
index 0443203fe0..df32d75103 100644
--- a/bgpd/bgp_ecommunity.c
+++ b/bgpd/bgp_ecommunity.c
@@ -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 */
diff --git a/bgpd/bgp_ecommunity.h b/bgpd/bgp_ecommunity.h
index e076885fb5..0544cbd316 100644
--- a/bgpd/bgp_ecommunity.h
+++ b/bgpd/bgp_ecommunity.h
@@ -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. */