From faafdfa8381e3b65711ee8a4473cd113f9904798 Mon Sep 17 00:00:00 2001 From: vivek Date: Fri, 5 Jan 2018 12:41:25 -0800 Subject: [PATCH] bgpd: Fix spurious error messages in EVPN type-5 route injection/withdraw Ensure that spurious error messages are not generated in a non-EVPN configuration when routes in a VRF get deleted or added. Also, check on EVPN advertisement being enabled before walking VRF routing table. Signed-off-by: Vivek Venkatraman Reviewed-by: Donald Sharp Ticket: CM-19206 Reviewed By: CCR-7073 Testing Done: 1. Recreate errors and validate fix 2. Type-5 route related testing - new routes, neighbor flap etc. --- bgpd/bgp_evpn.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index 35703a7591..438b29b4ef 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -1082,7 +1082,7 @@ static int update_evpn_type5_route(struct bgp *bgp_vrf, bgp_def = bgp_get_default(); if (!bgp_def) - return -1; + return 0; /* Build path attribute for this route - use the source attr, if * present, else treat as locally originated. @@ -1362,7 +1362,7 @@ static int delete_evpn_type5_route(struct bgp *bgp_vrf, bgp_def = bgp_get_default(); if (!bgp_def) - return -1; + return 0; /* locate the global route entry for this type-5 prefix */ rn = bgp_afi_node_lookup(bgp_def->rib[afi][safi], afi, safi, @@ -3204,6 +3204,10 @@ void bgp_evpn_withdraw_type5_route(struct bgp *bgp_vrf, struct prefix *p, struct prefix_evpn evp; char buf[PREFIX_STRLEN]; + /* NOTE: Check needed as this is called per-route also. */ + if (!advertise_type5_routes(bgp_vrf, afi)) + return; + build_type5_prefix_from_ip_prefix(&evp, p); ret = delete_evpn_type5_route(bgp_vrf, &evp); if (ret) { @@ -3222,6 +3226,7 @@ void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf, struct bgp_table *table = NULL; struct bgp_node *rn = NULL; + /* Bail out early if we don't have to advertise type-5 routes. */ if (!advertise_type5_routes(bgp_vrf, afi)) return; @@ -3245,6 +3250,7 @@ void bgp_evpn_advertise_type5_route(struct bgp *bgp_vrf, struct prefix *p, struct prefix_evpn evp; char buf[PREFIX_STRLEN]; + /* NOTE: Check needed as this is called per-route also. */ if (!advertise_type5_routes(bgp_vrf, afi)) return; @@ -3272,6 +3278,10 @@ void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf, struct bgp_node *rn = NULL; struct bgp_info *ri; + /* Bail out early if we don't have to advertise type-5 routes. */ + if (!advertise_type5_routes(bgp_vrf, afi)) + return; + table = bgp_vrf->rib[afi][safi]; for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { /* Need to identify the "selected" route entry to use its -- 2.39.5