]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: add L2 attr community support as per RFC8214
authorPhilippe Guibert <philippe.guibert@6wind.com>
Mon, 3 Feb 2025 15:08:45 +0000 (16:08 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 4 Feb 2025 15:12:39 +0000 (16:12 +0100)
The L2 attribute extended community can not be decoded when using L2VPN
EVPN as a route reflector. Decode the extended community and dump the
detailed information about flags and MTU information.

> rt4# show bgp l2vpn evpn
> BGP table version is 1, local router ID is 4.4.4.4
> Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
> Origin codes: i - IGP, e - EGP, ? - incomplete
> EVPN type-1 prefix: [1]:[EthTag]:[ESI]:[IPlen]:[VTEP-IP]:[Frag-id]
> EVPN type-2 prefix: [2]:[EthTag]:[MAClen]:[MAC]:[IPlen]:[IP]
> EVPN type-3 prefix: [3]:[EthTag]:[IPlen]:[OrigIP]
> EVPN type-4 prefix: [4]:[ESI]:[IPlen]:[OrigIP]
> EVPN type-5 prefix: [5]:[EthTag]:[IPlen]:[IP]
>
>    Network          Next Hop            Metric LocPrf Weight Path
> Route Distinguisher: 1.1.1.1:100
>  *>i[1]:[12]:[00:00:00:00:00:00:00:00:00:00]:[32]:[0.0.0.0]:[0]
>                     1.1.1.1                       100      0 i
>                     RT:65500:100 L2: P flag:N, B Flag N, C word N, MTU 0
> Route Distinguisher: 5.5.5.5:100
>  *>i[1]:[10]:[00:00:00:00:00:00:00:00:00:00]:[32]:[0.0.0.0]:[0]
>                     5.5.5.5                       100      0 i
>                     RT:65500:100 L2: P flag:N, B Flag N, C word N, MTU 0
>

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
bgpd/bgp_ecommunity.c
bgpd/bgp_ecommunity.h

index e794ccb3086a9fa8238d67594ec4550ac20fc66d..2c6ae65f85f0dcb2068c595e29b93e21a99c7382 100644 (file)
@@ -1337,6 +1337,31 @@ char *ecommunity_ecom2str(struct ecommunity *ecom, int format, int filter)
                                        snprintf(encbuf, sizeof(encbuf),
                                                 "DF: (alg: %u, pref: %u)", alg,
                                                 pref);
+                       } else if (*pnt == ECOMMUNITY_EVPN_SUBTYPE_LAYER2_ATTR) {
+                               uint16_t flags, l2mtu;
+
+                               ++pnt;
+                               memcpy(&flags, pnt, 2);
+                               ++pnt;
+                               ++pnt;
+
+                               memcpy(&l2mtu, pnt, 2);
+
+                               snprintf(encbuf, sizeof(encbuf),
+                                        "L2: P flag:%c, B Flag %c, C word %c, MTU %d",
+                                        CHECK_FLAG(flags,
+                                                   ECOMMUNITY_EVPN_SUBTYPE_LAYER2_ATTR_PRIMARY_PE_FLAG)
+                                                ? 'Y'
+                                                : 'N',
+                                        CHECK_FLAG(flags,
+                                                   ECOMMUNITY_EVPN_SUBTYPE_LAYER2_ATTR_BACKUP_PE_FLAG)
+                                                ? 'Y'
+                                                : 'N',
+                                        CHECK_FLAG(flags,
+                                                   ECOMMUNITY_EVPN_SUBTYPE_LAYER2_ATTR_CONTROL_WORD_FLAG)
+                                                ? 'Y'
+                                                : 'N',
+                                        l2mtu);
                        } else
                                unk_ecom = true;
                } else if (type == ECOMMUNITY_ENCODE_REDIRECT_IP_NH) {
index af9d481c19aedd8455c2b284be4404505205ef70..0e68b158074955968ce84482e348b466af957b44 100644 (file)
 #define ECOMMUNITY_EVPN_SUBTYPE_ESI_LABEL    0x01
 #define ECOMMUNITY_EVPN_SUBTYPE_ES_IMPORT_RT 0x02
 #define ECOMMUNITY_EVPN_SUBTYPE_ROUTERMAC    0x03
+#define ECOMMUNITY_EVPN_SUBTYPE_LAYER2_ATTR  0x04
 #define ECOMMUNITY_EVPN_SUBTYPE_DF_ELECTION 0x06
 #define ECOMMUNITY_EVPN_SUBTYPE_DEF_GW       0x0d
 #define ECOMMUNITY_EVPN_SUBTYPE_ND           0x08
 
 #define ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY_FLAG_STICKY 0x01
 
+/* Layer2 Attributes: RFC8214 */
+#define ECOMMUNITY_EVPN_SUBTYPE_LAYER2_ATTR_PRIMARY_PE_FLAG   0x01
+#define ECOMMUNITY_EVPN_SUBTYPE_LAYER2_ATTR_BACKUP_PE_FLAG    0x02
+#define ECOMMUNITY_EVPN_SUBTYPE_LAYER2_ATTR_CONTROL_WORD_FLAG 0x04
+
 /* DF alg bits - only lower 5 bits are applicable */
 #define ECOMMUNITY_EVPN_SUBTYPE_DF_ALG_BITS 0x1f