@@ -892,28 +892,31 @@ struct bgp_dest *bgp_evpn_vni_node_lookup(const struct bgpevpn *vpn,
892892/*
893893 * Add (update) or delete MACIP from zebra.
894894 */
895- static int bgp_zebra_send_remote_macip (struct bgp * bgp , struct bgpevpn * vpn ,
896- const struct prefix_evpn * p ,
897- const struct ethaddr * mac ,
898- struct in_addr remote_vtep_ip , int add ,
899- uint8_t flags , uint32_t seq , esi_t * esi )
895+ static enum zclient_send_status bgp_zebra_send_remote_macip (
896+ struct bgp * bgp , struct bgpevpn * vpn , const struct prefix_evpn * p ,
897+ const struct ethaddr * mac , struct in_addr remote_vtep_ip , int add ,
898+ uint8_t flags , uint32_t seq , esi_t * esi )
900899{
901900 struct stream * s ;
902901 uint16_t ipa_len ;
903902 static struct in_addr zero_remote_vtep_ip ;
904903 bool esi_valid ;
905904
906905 /* Check socket. */
907- if (!zclient || zclient -> sock < 0 )
908- return 0 ;
906+ if (!zclient || zclient -> sock < 0 ) {
907+ if (BGP_DEBUG (zebra , ZEBRA ))
908+ zlog_debug ("%s: No zclient or zclient->sock exists" ,
909+ __func__ );
910+ return ZCLIENT_SEND_SUCCESS ;
911+ }
909912
910913 /* Don't try to register if Zebra doesn't know of this instance. */
911914 if (!IS_BGP_INST_KNOWN_TO_ZEBRA (bgp )) {
912915 if (BGP_DEBUG (zebra , ZEBRA ))
913916 zlog_debug (
914917 "%s: No zebra instance to talk to, not installing remote macip" ,
915918 __func__ );
916- return 0 ;
919+ return ZCLIENT_SEND_SUCCESS ;
917920 }
918921
919922 if (!esi )
@@ -979,32 +982,34 @@ static int bgp_zebra_send_remote_macip(struct bgp *bgp, struct bgpevpn *vpn,
979982 frrtrace (5 , frr_bgp , evpn_mac_ip_zsend , add , vpn , p , remote_vtep_ip ,
980983 esi );
981984
982- if (zclient_send_message (zclient ) == ZCLIENT_SEND_FAILURE )
983- return -1 ;
984-
985- return 0 ;
985+ return zclient_send_message (zclient );
986986}
987987
988988/*
989989 * Add (update) or delete remote VTEP from zebra.
990990 */
991- static int bgp_zebra_send_remote_vtep (struct bgp * bgp , struct bgpevpn * vpn ,
992- const struct prefix_evpn * p ,
993- int flood_control , int add )
991+ static enum zclient_send_status
992+ bgp_zebra_send_remote_vtep (struct bgp * bgp , struct bgpevpn * vpn ,
993+ const struct prefix_evpn * p , int flood_control ,
994+ int add )
994995{
995996 struct stream * s ;
996997
997998 /* Check socket. */
998- if (!zclient || zclient -> sock < 0 )
999- return 0 ;
999+ if (!zclient || zclient -> sock < 0 ) {
1000+ if (BGP_DEBUG (zebra , ZEBRA ))
1001+ zlog_debug ("%s: No zclient or zclient->sock exists" ,
1002+ __func__ );
1003+ return ZCLIENT_SEND_SUCCESS ;
1004+ }
10001005
10011006 /* Don't try to register if Zebra doesn't know of this instance. */
10021007 if (!IS_BGP_INST_KNOWN_TO_ZEBRA (bgp )) {
10031008 if (BGP_DEBUG (zebra , ZEBRA ))
10041009 zlog_debug (
10051010 "%s: No zebra instance to talk to, not installing remote vtep" ,
10061011 __func__ );
1007- return 0 ;
1012+ return ZCLIENT_SEND_SUCCESS ;
10081013 }
10091014
10101015 s = zclient -> obuf ;
@@ -1021,7 +1026,7 @@ static int bgp_zebra_send_remote_vtep(struct bgp *bgp, struct bgpevpn *vpn,
10211026 EC_BGP_VTEP_INVALID ,
10221027 "Bad remote IP when trying to %s remote VTEP for VNI %u" ,
10231028 add ? "ADD" : "DEL" , (vpn ? vpn -> vni : 0 ));
1024- return -1 ;
1029+ return ZCLIENT_SEND_FAILURE ;
10251030 }
10261031 stream_putl (s , flood_control );
10271032
@@ -1034,10 +1039,7 @@ static int bgp_zebra_send_remote_vtep(struct bgp *bgp, struct bgpevpn *vpn,
10341039
10351040 frrtrace (3 , frr_bgp , evpn_bum_vtep_zsend , add , vpn , p );
10361041
1037- if (zclient_send_message (zclient ) == ZCLIENT_SEND_FAILURE )
1038- return -1 ;
1039-
1040- return 0 ;
1042+ return zclient_send_message (zclient );
10411043}
10421044
10431045/*
@@ -1263,14 +1265,14 @@ static void add_mac_mobility_to_attr(uint32_t seq_num, struct attr *attr)
12631265}
12641266
12651267/* Install EVPN route into zebra. */
1266- static int evpn_zebra_install (struct bgp * bgp , struct bgpevpn * vpn ,
1267- const struct prefix_evpn * p ,
1268- struct bgp_path_info * pi )
1268+ enum zclient_send_status evpn_zebra_install (struct bgp * bgp , struct bgpevpn * vpn ,
1269+ const struct prefix_evpn * p ,
1270+ struct bgp_path_info * pi )
12691271{
1270- int ret ;
12711272 uint8_t flags ;
12721273 int flood_control = VXLAN_FLOOD_DISABLED ;
12731274 uint32_t seq ;
1275+ enum zclient_send_status ret = ZCLIENT_SEND_SUCCESS ;
12741276
12751277 if (p -> prefix .route_type == BGP_EVPN_MAC_IP_ROUTE ) {
12761278 flags = 0 ;
@@ -1348,18 +1350,21 @@ static int evpn_zebra_install(struct bgp *bgp, struct bgpevpn *vpn,
13481350 flood_control = VXLAN_FLOOD_DISABLED ;
13491351 break ;
13501352 }
1353+
13511354 ret = bgp_zebra_send_remote_vtep (bgp , vpn , p , flood_control , 1 );
13521355 }
13531356
13541357 return ret ;
13551358}
13561359
13571360/* Uninstall EVPN route from zebra. */
1358- static int evpn_zebra_uninstall (struct bgp * bgp , struct bgpevpn * vpn ,
1359- const struct prefix_evpn * p ,
1360- struct bgp_path_info * pi , bool is_sync )
1361+ enum zclient_send_status evpn_zebra_uninstall (struct bgp * bgp ,
1362+ struct bgpevpn * vpn ,
1363+ const struct prefix_evpn * p ,
1364+ struct bgp_path_info * pi ,
1365+ bool is_sync )
13611366{
1362- int ret ;
1367+ enum zclient_send_status ret = ZCLIENT_SEND_SUCCESS ;
13631368
13641369 if (p -> prefix .route_type == BGP_EVPN_MAC_IP_ROUTE )
13651370 ret = bgp_zebra_send_remote_macip (
@@ -1374,7 +1379,7 @@ static int evpn_zebra_uninstall(struct bgp *bgp, struct bgpevpn *vpn,
13741379 ret = bgp_evpn_remote_es_evi_del (bgp , vpn , p );
13751380 else
13761381 ret = bgp_zebra_send_remote_vtep (bgp , vpn , p ,
1377- VXLAN_FLOOD_DISABLED , 0 );
1382+ VXLAN_FLOOD_DISABLED , 0 );
13781383
13791384 return ret ;
13801385}
@@ -1465,12 +1470,19 @@ int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,
14651470 && !CHECK_FLAG (dest -> flags , BGP_NODE_USER_CLEAR )
14661471 && !CHECK_FLAG (old_select -> flags , BGP_PATH_ATTR_CHANGED )
14671472 && !bgp_addpath_is_addpath_used (& bgp -> tx_addpath , afi , safi )) {
1468- if (bgp_zebra_has_route_changed (old_select ))
1469- ret = evpn_zebra_install (
1470- bgp , vpn ,
1471- (const struct prefix_evpn * )bgp_dest_get_prefix (
1472- dest ),
1473- old_select );
1473+ if (bgp_zebra_has_route_changed (old_select )) {
1474+ if (CHECK_FLAG (bgp -> flags , BGP_FLAG_DELETE_IN_PROGRESS ))
1475+ (void )evpn_zebra_install (bgp , vpn ,
1476+ (const struct prefix_evpn
1477+ * )
1478+ bgp_dest_get_prefix (
1479+ dest ),
1480+ old_select );
1481+ else
1482+ bgp_zebra_route_install (dest , old_select , bgp ,
1483+ true, vpn , false);
1484+ }
1485+
14741486 UNSET_FLAG (old_select -> flags , BGP_PATH_MULTIPATH_CHG );
14751487 UNSET_FLAG (old_select -> flags , BGP_PATH_LINK_BW_CHG );
14761488 bgp_zebra_clear_route_change_flags (dest );
@@ -1502,10 +1514,15 @@ int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,
15021514 if (new_select && new_select -> type == ZEBRA_ROUTE_BGP
15031515 && (new_select -> sub_type == BGP_ROUTE_IMPORTED ||
15041516 bgp_evpn_attr_is_sync (new_select -> attr ))) {
1505- ret = evpn_zebra_install (
1506- bgp , vpn ,
1507- (struct prefix_evpn * )bgp_dest_get_prefix (dest ),
1508- new_select );
1517+ if (CHECK_FLAG (bgp -> flags , BGP_FLAG_DELETE_IN_PROGRESS ))
1518+ (void )evpn_zebra_install (bgp , vpn ,
1519+ (const struct prefix_evpn * )
1520+ bgp_dest_get_prefix (
1521+ dest ),
1522+ new_select );
1523+ else
1524+ bgp_zebra_route_install (dest , new_select , bgp , true,
1525+ vpn , false);
15091526
15101527 /* If an old best existed and it was a "local" route, the only
15111528 * reason
@@ -1522,13 +1539,21 @@ int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,
15221539 evpn_delete_old_local_route (bgp , vpn , dest ,
15231540 old_select , new_select );
15241541 } else {
1525- if (old_select && old_select -> type == ZEBRA_ROUTE_BGP
1526- && old_select -> sub_type == BGP_ROUTE_IMPORTED )
1527- ret = evpn_zebra_uninstall (
1528- bgp , vpn ,
1529- (const struct prefix_evpn * )bgp_dest_get_prefix (
1530- dest ),
1531- old_select , false);
1542+ if (old_select && old_select -> type == ZEBRA_ROUTE_BGP &&
1543+ old_select -> sub_type == BGP_ROUTE_IMPORTED ) {
1544+ if ((CHECK_FLAG (bgp -> flags ,
1545+ BGP_FLAG_DELETE_IN_PROGRESS )) ||
1546+ (CHECK_FLAG (bgp -> flags , BGP_FLAG_VNI_DOWN )))
1547+ (void )evpn_zebra_uninstall (bgp , vpn ,
1548+ (const struct prefix_evpn
1549+ * )
1550+ bgp_dest_get_prefix (
1551+ dest ),
1552+ old_select , false);
1553+ else
1554+ bgp_zebra_route_install (dest , old_select , bgp ,
1555+ false, vpn , false);
1556+ }
15321557 }
15331558
15341559 /* Clear any route change flags. */
@@ -2062,9 +2087,20 @@ static void evpn_zebra_reinstall_best_route(struct bgp *bgp,
20622087 if (curr_select && curr_select -> type == ZEBRA_ROUTE_BGP
20632088 && (curr_select -> sub_type == BGP_ROUTE_IMPORTED ||
20642089 bgp_evpn_attr_is_sync (curr_select -> attr )))
2065- evpn_zebra_install (bgp , vpn ,
2066- (const struct prefix_evpn * )bgp_dest_get_prefix (dest ),
2067- curr_select );
2090+ if (curr_select && curr_select -> type == ZEBRA_ROUTE_BGP &&
2091+ (curr_select -> sub_type == BGP_ROUTE_IMPORTED ||
2092+ bgp_evpn_attr_is_sync (curr_select -> attr ))) {
2093+ if (CHECK_FLAG (bgp -> flags , BGP_FLAG_DELETE_IN_PROGRESS ))
2094+ (void )evpn_zebra_install (bgp , vpn ,
2095+ (const struct prefix_evpn
2096+ * )
2097+ bgp_dest_get_prefix (
2098+ dest ),
2099+ curr_select );
2100+ else
2101+ bgp_zebra_route_install (dest , curr_select , bgp ,
2102+ true, vpn , false);
2103+ }
20682104}
20692105
20702106/*
@@ -2245,8 +2281,16 @@ static int update_evpn_route(struct bgp *bgp, struct bgpevpn *vpn,
22452281 * has been removed.
22462282 */
22472283 new_is_sync = bgp_evpn_attr_is_sync (pi -> attr );
2248- if (!new_is_sync && old_is_sync )
2249- evpn_zebra_uninstall (bgp , vpn , p , pi , true);
2284+ if (!new_is_sync && old_is_sync ) {
2285+ if (CHECK_FLAG (bgp -> flags ,
2286+ BGP_FLAG_DELETE_IN_PROGRESS ))
2287+ (void )evpn_zebra_uninstall (bgp , vpn , p ,
2288+ pi , true);
2289+ else
2290+ bgp_zebra_route_install (dest , pi , bgp ,
2291+ false, vpn ,
2292+ true);
2293+ }
22502294 }
22512295 }
22522296 bgp_path_info_unlock (pi );
@@ -2512,8 +2556,17 @@ void bgp_evpn_update_type2_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
25122556 * has been removed.
25132557 */
25142558 new_is_sync = bgp_evpn_attr_is_sync (pi -> attr );
2515- if (!new_is_sync && old_is_sync )
2516- evpn_zebra_uninstall (bgp , vpn , & evp , pi , true);
2559+ if (!new_is_sync && old_is_sync ) {
2560+ if (CHECK_FLAG (bgp -> flags ,
2561+ BGP_FLAG_DELETE_IN_PROGRESS ))
2562+ (void )evpn_zebra_uninstall (bgp , vpn ,
2563+ & evp , pi ,
2564+ true);
2565+ else
2566+ bgp_zebra_route_install (dest , pi , bgp ,
2567+ false, vpn ,
2568+ true);
2569+ }
25172570 }
25182571 }
25192572
@@ -2795,7 +2848,22 @@ static int delete_routes_for_vni(struct bgp *bgp, struct bgpevpn *vpn)
27952848 delete_all_type2_routes (bgp , vpn );
27962849
27972850 build_evpn_type3_prefix (& p , vpn -> originator_ip );
2851+
2852+ /*
2853+ * To handle the following scenario:
2854+ * - Say, the new zebra announce fifo list has few vni Evpn prefixes yet
2855+ * to be sent to zebra.
2856+ * - At this point if we have triggers like "no advertise-all-vni" or
2857+ * "networking restart", where a vni is going down.
2858+ *
2859+ * Perform the below
2860+ * 1) send withdraw routes to zebra immediately in case it is installed.
2861+ * 2) before we blow up the vni table, we need to walk the list and
2862+ * pop all the dest whose za_vpn points to this vni.
2863+ */
2864+ SET_FLAG (bgp -> flags , BGP_FLAG_VNI_DOWN );
27982865 ret = delete_evpn_route (bgp , vpn , & p );
2866+ UNSET_FLAG (bgp -> flags , BGP_FLAG_VNI_DOWN );
27992867 if (ret )
28002868 return ret ;
28012869
@@ -6262,6 +6330,17 @@ struct bgpevpn *bgp_evpn_new(struct bgp *bgp, vni_t vni,
62626330 */
62636331void bgp_evpn_free (struct bgp * bgp , struct bgpevpn * vpn )
62646332{
6333+ struct bgp_dest * dest = NULL ;
6334+
6335+ while (zebra_announce_count (& bm -> zebra_announce_head )) {
6336+ dest = zebra_announce_pop (& bm -> zebra_announce_head );
6337+ if (dest -> za_vpn == vpn ) {
6338+ bgp_path_info_unlock (dest -> za_bgp_pi );
6339+ bgp_dest_unlock_node (dest );
6340+ } else
6341+ zebra_announce_add_tail (& bm -> zebra_announce_head , dest );
6342+ }
6343+
62656344 bgp_evpn_remote_ip_hash_destroy (vpn );
62666345 bgp_evpn_vni_es_cleanup (vpn );
62676346 bgpevpn_unlink_from_l3vni (vpn );
0 commit comments