From 4248407b6d8788c4d8bb567ff13a54da733076cb Mon Sep 17 00:00:00 2001 From: Anuradha Karuppiah Date: Fri, 27 Mar 2020 13:56:08 -0700 Subject: [PATCH] bgpd: extended community for EAD routes 1. EAD routes require support for ESI_LABEL extended community. The primary info in this EC is a flags the specifies if the ES is Single-active or active-acive. 2. Also fixed up ES_IMPORT_RT string. Support was added a long time ago for ESR/Type-4 routes but it has not really been exercised for MH functionality till now. Signed-off-by: Anuradha Karuppiah --- bgpd/bgp_ecommunity.c | 39 ++++++++++++++++++++++++--------------- bgpd/bgp_ecommunity.h | 2 ++ 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c index d6c311bfa0..0990d0b872 100644 --- a/bgpd/bgp_ecommunity.c +++ b/bgpd/bgp_ecommunity.c @@ -810,6 +810,30 @@ char *ecommunity_ecom2str(struct ecommunity *ecom, int format, int filter) ECOMMUNITY_EVPN_SUBTYPE_ND_ROUTER_FLAG)) strlcpy(encbuf, "ND:Router Flag", sizeof(encbuf)); + } else if (*pnt + == ECOMMUNITY_EVPN_SUBTYPE_ES_IMPORT_RT) { + struct ethaddr mac; + + pnt++; + memcpy(&mac, pnt, ETH_ALEN); + snprintf(encbuf, + sizeof(encbuf), + "ES-Import-Rt:%02x:%02x:%02x:%02x:%02x:%02x", + (uint8_t)mac.octet[0], + (uint8_t)mac.octet[1], + (uint8_t)mac.octet[2], + (uint8_t)mac.octet[3], + (uint8_t)mac.octet[4], + (uint8_t)mac.octet[5]); + } else if (*pnt + == ECOMMUNITY_EVPN_SUBTYPE_ESI_LABEL) { + uint8_t flags = *++pnt; + + snprintf(encbuf, + sizeof(encbuf), "ESI-label-Rt:%s", + (flags & + ECOMMUNITY_EVPN_SUBTYPE_ESI_SA_FLAG) ? + "SA":"AA"); } else unk_ecom = 1; } else if (type == ECOMMUNITY_ENCODE_REDIRECT_IP_NH) { @@ -865,21 +889,6 @@ char *ecommunity_ecom2str(struct ecommunity *ecom, int format, int filter) } else if (sub_type == ECOMMUNITY_TRAFFIC_MARKING) { snprintf(encbuf, sizeof(encbuf), "FS:marking %u", *(pnt + 5)); - } else if (*pnt - == ECOMMUNITY_EVPN_SUBTYPE_ES_IMPORT_RT) { - struct ethaddr mac; - - memcpy(&mac, pnt, ETH_ALEN); - - snprintf( - encbuf, sizeof(encbuf), - "ES-Import-Rt:%02x:%02x:%02x:%02x:%02x:%02x", - (uint8_t)mac.octet[0], - (uint8_t)mac.octet[1], - (uint8_t)mac.octet[2], - (uint8_t)mac.octet[3], - (uint8_t)mac.octet[4], - (uint8_t)mac.octet[5]); } else unk_ecom = 1; } else if (type == ECOMMUNITY_ENCODE_AS_NON_TRANS) { diff --git a/bgpd/bgp_ecommunity.h b/bgpd/bgp_ecommunity.h index 7deae8e746..1e9ffcb678 100644 --- a/bgpd/bgp_ecommunity.h +++ b/bgpd/bgp_ecommunity.h @@ -76,6 +76,8 @@ #define ECOMMUNITY_EVPN_SUBTYPE_ND_ROUTER_FLAG 0x01 #define ECOMMUNITY_EVPN_SUBTYPE_ND_OVERRIDE_FLAG 0x02 +#define ECOMMUNITY_EVPN_SUBTYPE_ESI_SA_FLAG (1 << 0) /* single-active */ + /* Low-order octet of the Extended Communities type field for OPAQUE types */ #define ECOMMUNITY_OPAQUE_SUBTYPE_ENCAP 0x0c -- 2.39.5