From f6ca545a214cdd4112f133df3da82fad827186fa Mon Sep 17 00:00:00 2001 From: vivek Date: Tue, 24 Mar 2020 13:53:09 -0700 Subject: [PATCH] bgpd: Ensure link bandwidth extcommunity is not repeated The BGP link bandwidth extended community must not be repeated. If the attribute already carries this and the route-map specifies a new value, the implementation will honor the policy configuration and overwrite the existing values. Signed-off-by: Vivek Venkatraman --- bgpd/bgp_routemap.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 2be49bbc0..ffcb65555 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -2570,17 +2570,19 @@ route_set_ecommunity_lb(void *rule, const struct prefix *prefix, bw_bytes = ((uint64_t)(rels->bw * 1000 * 1000))/8; encode_lb_extcomm(as, bw_bytes, rels->non_trans, &lb_eval); - ecom_lb.size = 1; - ecom_lb.val = (uint8_t *)lb_eval.val; /* add to route or merge with existing */ old_ecom = path->attr->ecommunity; if (old_ecom) { - new_ecom = ecommunity_merge(ecommunity_dup(old_ecom), &ecom_lb); + new_ecom = ecommunity_dup(old_ecom); + ecommunity_add_val(new_ecom, &lb_eval, true, true); if (!old_ecom->refcnt) ecommunity_free(&old_ecom); - } else + } else { + ecom_lb.size = 1; + ecom_lb.val = (uint8_t *)lb_eval.val; new_ecom = ecommunity_dup(&ecom_lb); + } /* new_ecom will be intern()'d or attr_flush()'d in call stack */ path->attr->ecommunity = new_ecom; -- 2.39.5