]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Allow generating EVPN type-5 routes with existing extended community
authorvivek <vivek@cumulusnetworks.com>
Tue, 24 Mar 2020 21:58:42 +0000 (14:58 -0700)
committervivek <vivek@cumulusnetworks.com>
Tue, 31 Mar 2020 03:12:32 +0000 (20:12 -0700)
The EVPN advertise route-map may generate extended communities for an IPv4
or IPv6 route injected into EVPN as type-5. If so, allow for it and add
to it.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
bgpd/bgp_evpn.c

index 6a7db87ec43ca592ad29b1732adf7b76549ac547..47f8c5a8b6c4bc77ed5fd8074f884b17c03789b5 100644 (file)
@@ -744,6 +744,7 @@ static void build_evpn_type5_route_extcomm(struct bgp *bgp_vrf,
        bgp_encap_types tnl_type;
        struct listnode *node, *nnode;
        struct ecommunity *ecom;
+       struct ecommunity *old_ecom;
        struct list *vrf_export_rtl = NULL;
 
        /* Encap */
@@ -754,7 +755,14 @@ static void build_evpn_type5_route_extcomm(struct bgp *bgp_vrf,
        ecom_encap.val = (uint8_t *)eval.val;
 
        /* Add Encap */
-       attr->ecommunity = ecommunity_dup(&ecom_encap);
+       if (attr->ecommunity) {
+               old_ecom = attr->ecommunity;
+               ecom = ecommunity_merge(ecommunity_dup(old_ecom), &ecom_encap);
+               if (!old_ecom->refcnt)
+                       ecommunity_free(&old_ecom);
+       } else
+               ecom = ecommunity_dup(&ecom_encap);
+       attr->ecommunity = ecom;
 
        /* Add the export RTs for L3VNI/VRF */
        vrf_export_rtl = bgp_vrf->vrf_export_rtl;