]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: distinguish between frr prefixlen and packet prefixlen for EVPN type-5 routes
authorMitesh Kanjariya <mitesh@marvel-07.cumulusnetworks.com>
Mon, 6 Nov 2017 22:32:32 +0000 (14:32 -0800)
committerMitesh Kanjariya <mitesh@marvel-07.cumulusnetworks.com>
Thu, 14 Dec 2017 18:57:08 +0000 (10:57 -0800)
for EVPN routes prefixlen filed in struct prefix
represents the sizeof of the struct rather than the actual prefix len.
This is later used in looking up route node in RIB.

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
bgpd/bgp_evpn.c
bgpd/bgp_evpn_private.h

index 682bdb0075832f4f4b0c1d068e85e145586c834f..42bc686cdfb6736b065b03e3dba02de7c3a8a6b2 100644 (file)
@@ -2847,6 +2847,7 @@ static int process_type5_route(struct peer *peer, afi_t afi, safi_t safi,
        /* Make EVPN prefix. */
        memset(&p, 0, sizeof(struct prefix_evpn));
        p.family = AF_EVPN;
+       p.prefixlen = EVPN_TYPE_5_ROUTE_PREFIXLEN;
        p.prefix.route_type = BGP_EVPN_IP_PREFIX_ROUTE;
 
        /* Additional information outside of prefix - ESI and GW IP */
@@ -2881,14 +2882,12 @@ static int process_type5_route(struct peer *peer, afi_t afi, safi_t safi,
                pfx += 4;
                memcpy(&evpn.gw_ip.ipv4, pfx, 4);
                pfx += 4;
-               p.prefixlen = PREFIX_LEN_ROUTE_TYPE_5_IPV4;
        } else {
                SET_IPADDR_V6(&p.prefix.ip);
                memcpy(&p.prefix.ip.ipaddr_v6, pfx, 16);
                pfx += 16;
                memcpy(&evpn.gw_ip.ipv6, pfx, 16);
                pfx += 16;
-               p.prefixlen = PREFIX_LEN_ROUTE_TYPE_5_IPV6;
        }
 
        label_pnt = (mpls_label_t *)pfx;
@@ -2919,10 +2918,12 @@ static void evpn_mpattr_encode_type5(struct stream *s, struct prefix *p,
                return;
        p_evpn_p = &(p->u.prefix_evpn);
 
+       /* len denites the total len of IP and GW-IP in the route
+          IP and GW-IP have to be both ipv4 or ipv6 */
        if (IS_IPADDR_V4(&p_evpn_p->ip))
-               len = 8; /* ipv4 */
+               len = 8; /* IP and GWIP are both ipv4 */
        else
-               len = 32; /* ipv6 */
+               len = 32; /* IP and GWIP are both ipv6 */
        /* Prefix contains RD, ESI, EthTag, IP length, IP, GWIP and VNI */
        stream_putc(s, 8 + 10 + 4 + 1 + len + 3);
        stream_put(s, prd->val, 8);
index 89078124f0bbeca60d16b7102e27a699e73235ad..f308f5ed9a05c7e830962b15c2ada66bbaba7e57 100644 (file)
 
 #define RT_ADDRSTRLEN 28
 
-/* EVPN prefix lengths. */
+/* EVPN prefix lengths. This reprsent the sizeof struct prefix_evpn  */
 #define EVPN_TYPE_2_ROUTE_PREFIXLEN      224
 #define EVPN_TYPE_3_ROUTE_PREFIXLEN      224
-#define EVPN_TYPE_5_ROUTE_PREFIXLEN      168
+#define EVPN_TYPE_5_ROUTE_PREFIXLEN      224
 
 /* EVPN route types. */
 typedef enum {