From e935c14711ae0f68f4a58abb8cc8c7d75ba19324 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Wed, 26 Jan 2022 15:48:44 -0800 Subject: [PATCH] bgpd: copy asn of src vrf to evpn type5 route When a unicast route from source vrf is imported into evpn as type5 route, prepend the asn of the source vrf into type5 asn path list. The condition of evpn type5 prefix path info is present but source vrf route has been cleared via clear command. In this case existing path info needs to rewrite the source vrf asn. prepends asn of the source vrf, but the further condition for existing path attribute for the same route needs to prepend source vrf asn. Ticket: #2943080 Testing: Before fix: r4# clear ip bgp vrf overlay prefix 0.0.0.0/0 Route Distinguisher: 128.117.243.209:4 *> [5]:[0]:[0]:[0.0.0.0] 203.0.113.1 0 0 194 ? <--- 64512 is missing ET:8 RT:64532:104001 Rmac:06:ec:bf:59:e8:93 After fix: r4# clear ip bgp vrf overlay prefix 0.0.0.0/0 Route's source vrf bgp output containing ASN 64512: r4# show bgp vrf overlay BGP table version is 2, local router ID is 128.117.243.209, vrf id 10 Default local pref 100, local AS 64512 ... Notice after clear command source vrf asn 64512 is retained. Route Distinguisher: 128.117.243.209:4 *> [5]:[0]:[0]:[0.0.0.0] 203.0.113.1 0 0 64512 194 ? ET:8 RT:64532:104001 Rmac:06:ec:bf:59:e8:93 Signed-off-by: Chirag Shah --- bgpd/bgp_evpn.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index 113ec85c2639..1309ccc17e16 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -1669,9 +1669,19 @@ static int update_evpn_type5_route_entry(struct bgp *bgp_evpn, /* attribute changed */ *route_changed = 1; + /* if the asn values are different, copy the asn of + * source vrf to the target (evpn) vrf entry. + */ + if (bgp_vrf->as != bgp_evpn->as) { + new_aspath = aspath_dup(static_attr.aspath); + new_aspath = + aspath_add_seq(new_aspath, bgp_vrf->as); + static_attr.aspath = new_aspath; + } /* The attribute has changed. */ /* Add (or update) attribute to hash. */ - attr_new = bgp_attr_intern(attr); + attr_new = bgp_attr_intern(&static_attr); + bgp_attr_flush(&static_attr); bgp_path_info_set_flag(dest, tmp_pi, BGP_PATH_ATTR_CHANGED);