bgpd: Fix missing deletion of evpn routes

Consider the scenario of evpn, the box has some type-5 ECMP routes.

After one of its remote peers is removed ( or down ), `show evpn rmac vni all`
kept no change **sometimes**, it means the rmac of the removed peer maybe is
still in this box, and the traffic will be wrongly forwarded to the removed
peer.

The root cause is that the best path selection for type-5 routes maybe
keep no change and the best path is not routed to the removed peer, so `bgpd`
wrongly doesn't tell `zebra` to remove ( withdraw ) the type-5 routes owned
by the removed peer.

So, add a new flag to force the deletion.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
This commit is contained in:
anlan_cs 2023-05-18 20:49:16 +08:00
parent ff82184fae
commit 0c061db4d0
3 changed files with 13 additions and 4 deletions

View File

@ -3271,6 +3271,9 @@ static int uninstall_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
bgp_aggregate_decrement(bgp_vrf, bgp_dest_get_prefix(dest), pi, afi,
safi);
/* Force deletion */
SET_FLAG(dest->flags, BGP_NODE_PROCESS_CLEAR);
/* Mark entry for deletion */
bgp_path_info_delete(dest, pi);

View File

@ -3227,10 +3227,11 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest,
/* If best route remains the same and this is not due to user-initiated
* clear, see exactly what needs to be done.
*/
if (old_select && old_select == new_select
&& !CHECK_FLAG(dest->flags, BGP_NODE_USER_CLEAR)
&& !CHECK_FLAG(old_select->flags, BGP_PATH_ATTR_CHANGED)
&& !bgp_addpath_is_addpath_used(&bgp->tx_addpath, afi, safi)) {
if (old_select && old_select == new_select &&
!CHECK_FLAG(dest->flags, BGP_NODE_USER_CLEAR) &&
!CHECK_FLAG(dest->flags, BGP_NODE_PROCESS_CLEAR) &&
!CHECK_FLAG(old_select->flags, BGP_PATH_ATTR_CHANGED) &&
!bgp_addpath_is_addpath_used(&bgp->tx_addpath, afi, safi)) {
if (bgp_zebra_has_route_changed(old_select)) {
#ifdef ENABLE_BGP_VNC
vnc_import_bgp_add_route(bgp, p, old_select);
@ -3284,6 +3285,10 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest,
*/
UNSET_FLAG(dest->flags, BGP_NODE_USER_CLEAR);
/* If the process wants to force deletion this flag will be set
*/
UNSET_FLAG(dest->flags, BGP_NODE_PROCESS_CLEAR);
/* bestpath has changed; bump version */
if (old_select || new_select) {
bgp_bump_version(dest);

View File

@ -100,6 +100,7 @@ struct bgp_node {
#define BGP_NODE_FIB_INSTALLED (1 << 6)
#define BGP_NODE_LABEL_REQUESTED (1 << 7)
#define BGP_NODE_SOFT_RECONFIG (1 << 8)
#define BGP_NODE_PROCESS_CLEAR (1 << 9)
struct bgp_addpath_node_data tx_addpath;