summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvivek <vivek@cumulusnetworks.com>2020-03-24 15:00:56 -0700
committervivek <vivek@cumulusnetworks.com>2020-03-30 20:12:32 -0700
commitfeca4f1e67bb342826d898ae1ce5679798ef1e86 (patch)
tree73cf94b4227e012b52bc3381a25a3e512f13260a
parentfab92da7ca916b8ddf4b88dbb8a71e08c4513d7f (diff)
bgpd: Ensure RMAC extended community is unique
The BGP Router MAC extended community should be unique and not occur multiple times. In a VRF-to-VRF route-leak scenario where EVPN routes from a source VRF are leaked into the target VRF and then injected back into EVPN from the target VRF, the resulting route had more than one RMAC. With this fix, the resulting route will have only the target VRF's RMAC. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
-rw-r--r--bgpd/bgp_evpn.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c
index 47f8c5a8b6..9d895fa27c 100644
--- a/bgpd/bgp_evpn.c
+++ b/bgpd/bgp_evpn.c
@@ -738,7 +738,6 @@ static void build_evpn_type5_route_extcomm(struct bgp *bgp_vrf,
struct attr *attr)
{
struct ecommunity ecom_encap;
- struct ecommunity ecom_rmac;
struct ecommunity_val eval;
struct ecommunity_val eval_rmac;
bgp_encap_types tnl_type;
@@ -772,12 +771,8 @@ static void build_evpn_type5_route_extcomm(struct bgp *bgp_vrf,
/* add the router mac extended community */
if (!is_zero_mac(&attr->rmac)) {
- memset(&ecom_rmac, 0, sizeof(ecom_rmac));
encode_rmac_extcomm(&eval_rmac, &attr->rmac);
- ecom_rmac.size = 1;
- ecom_rmac.val = (uint8_t *)eval_rmac.val;
- attr->ecommunity =
- ecommunity_merge(attr->ecommunity, &ecom_rmac);
+ ecommunity_add_val(attr->ecommunity, &eval_rmac, true, true);
}
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
@@ -799,7 +794,6 @@ static void build_evpn_route_extcomm(struct bgpevpn *vpn, struct attr *attr,
struct ecommunity ecom_encap;
struct ecommunity ecom_sticky;
struct ecommunity ecom_default_gw;
- struct ecommunity ecom_rmac;
struct ecommunity ecom_na;
struct ecommunity_val eval;
struct ecommunity_val eval_sticky;
@@ -853,12 +847,8 @@ static void build_evpn_route_extcomm(struct bgpevpn *vpn, struct attr *attr,
/* Add RMAC, if told to. */
if (add_l3_ecomm) {
- memset(&ecom_rmac, 0, sizeof(ecom_rmac));
encode_rmac_extcomm(&eval_rmac, &attr->rmac);
- ecom_rmac.size = 1;
- ecom_rmac.val = (uint8_t *)eval_rmac.val;
- attr->ecommunity =
- ecommunity_merge(attr->ecommunity, &ecom_rmac);
+ ecommunity_add_val(attr->ecommunity, &eval_rmac, true, true);
}
/* Add default gateway, if needed. */