From 1995cb77bfc8a2b437044763054f417d4c1d8de6 Mon Sep 17 00:00:00 2001 From: Don Slice Date: Mon, 8 Jun 2020 18:05:40 +0000 Subject: [PATCH] bgpd: remove extcommunity attribute on leaked route if empty Problem reported where bgp sessions were being torn down for ibgp peers with the reason being optional attribute error. Found that when a route was leaked, the RTs were stripped but the actual EXTCOMMUNUNITY attribute was not cleared so an empty ecommunity attribute stayed in the bgp table and was sent in updates. Ticket: CM-30000 Signed-off-by: Don Slice --- bgpd/bgp_mplsvpn.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 46dcd2864e..3b82c60ae9 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -1095,6 +1095,14 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf, /* to */ new_ecom = ecommunity_dup(old_ecom); ecommunity_strip_rts(new_ecom); static_attr.ecommunity = new_ecom; + + if (new_ecom->size == 0) { + UNSET_FLAG(static_attr.flag, + ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)); + ecommunity_free(&new_ecom); + static_attr.ecommunity = NULL; + } + if (!old_ecom->refcnt) ecommunity_free(&old_ecom); }