@@ -892,28 +892,31 @@ struct bgp_dest *bgp_evpn_vni_node_lookup(const struct bgpevpn *vpn,
892
892
/*
893
893
* Add (update) or delete MACIP from zebra.
894
894
*/
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 )
900
899
{
901
900
struct stream * s ;
902
901
uint16_t ipa_len ;
903
902
static struct in_addr zero_remote_vtep_ip ;
904
903
bool esi_valid ;
905
904
906
905
/* 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
+ }
909
912
910
913
/* Don't try to register if Zebra doesn't know of this instance. */
911
914
if (!IS_BGP_INST_KNOWN_TO_ZEBRA (bgp )) {
912
915
if (BGP_DEBUG (zebra , ZEBRA ))
913
916
zlog_debug (
914
917
"%s: No zebra instance to talk to, not installing remote macip" ,
915
918
__func__ );
916
- return 0 ;
919
+ return ZCLIENT_SEND_SUCCESS ;
917
920
}
918
921
919
922
if (!esi )
@@ -979,32 +982,34 @@ static int bgp_zebra_send_remote_macip(struct bgp *bgp, struct bgpevpn *vpn,
979
982
frrtrace (5 , frr_bgp , evpn_mac_ip_zsend , add , vpn , p , remote_vtep_ip ,
980
983
esi );
981
984
982
- if (zclient_send_message (zclient ) == ZCLIENT_SEND_FAILURE )
983
- return -1 ;
984
-
985
- return 0 ;
985
+ return zclient_send_message (zclient );
986
986
}
987
987
988
988
/*
989
989
* Add (update) or delete remote VTEP from zebra.
990
990
*/
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 )
994
995
{
995
996
struct stream * s ;
996
997
997
998
/* 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
+ }
1000
1005
1001
1006
/* Don't try to register if Zebra doesn't know of this instance. */
1002
1007
if (!IS_BGP_INST_KNOWN_TO_ZEBRA (bgp )) {
1003
1008
if (BGP_DEBUG (zebra , ZEBRA ))
1004
1009
zlog_debug (
1005
1010
"%s: No zebra instance to talk to, not installing remote vtep" ,
1006
1011
__func__ );
1007
- return 0 ;
1012
+ return ZCLIENT_SEND_SUCCESS ;
1008
1013
}
1009
1014
1010
1015
s = zclient -> obuf ;
@@ -1021,7 +1026,7 @@ static int bgp_zebra_send_remote_vtep(struct bgp *bgp, struct bgpevpn *vpn,
1021
1026
EC_BGP_VTEP_INVALID ,
1022
1027
"Bad remote IP when trying to %s remote VTEP for VNI %u" ,
1023
1028
add ? "ADD" : "DEL" , (vpn ? vpn -> vni : 0 ));
1024
- return -1 ;
1029
+ return ZCLIENT_SEND_FAILURE ;
1025
1030
}
1026
1031
stream_putl (s , flood_control );
1027
1032
@@ -1034,10 +1039,7 @@ static int bgp_zebra_send_remote_vtep(struct bgp *bgp, struct bgpevpn *vpn,
1034
1039
1035
1040
frrtrace (3 , frr_bgp , evpn_bum_vtep_zsend , add , vpn , p );
1036
1041
1037
- if (zclient_send_message (zclient ) == ZCLIENT_SEND_FAILURE )
1038
- return -1 ;
1039
-
1040
- return 0 ;
1042
+ return zclient_send_message (zclient );
1041
1043
}
1042
1044
1043
1045
/*
@@ -1263,14 +1265,14 @@ static void add_mac_mobility_to_attr(uint32_t seq_num, struct attr *attr)
1263
1265
}
1264
1266
1265
1267
/* 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 )
1269
1271
{
1270
- int ret ;
1271
1272
uint8_t flags ;
1272
1273
int flood_control = VXLAN_FLOOD_DISABLED ;
1273
1274
uint32_t seq ;
1275
+ enum zclient_send_status ret = ZCLIENT_SEND_SUCCESS ;
1274
1276
1275
1277
if (p -> prefix .route_type == BGP_EVPN_MAC_IP_ROUTE ) {
1276
1278
flags = 0 ;
@@ -1348,18 +1350,21 @@ static int evpn_zebra_install(struct bgp *bgp, struct bgpevpn *vpn,
1348
1350
flood_control = VXLAN_FLOOD_DISABLED ;
1349
1351
break ;
1350
1352
}
1353
+
1351
1354
ret = bgp_zebra_send_remote_vtep (bgp , vpn , p , flood_control , 1 );
1352
1355
}
1353
1356
1354
1357
return ret ;
1355
1358
}
1356
1359
1357
1360
/* 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 )
1361
1366
{
1362
- int ret ;
1367
+ enum zclient_send_status ret = ZCLIENT_SEND_SUCCESS ;
1363
1368
1364
1369
if (p -> prefix .route_type == BGP_EVPN_MAC_IP_ROUTE )
1365
1370
ret = bgp_zebra_send_remote_macip (
@@ -1374,7 +1379,7 @@ static int evpn_zebra_uninstall(struct bgp *bgp, struct bgpevpn *vpn,
1374
1379
ret = bgp_evpn_remote_es_evi_del (bgp , vpn , p );
1375
1380
else
1376
1381
ret = bgp_zebra_send_remote_vtep (bgp , vpn , p ,
1377
- VXLAN_FLOOD_DISABLED , 0 );
1382
+ VXLAN_FLOOD_DISABLED , 0 );
1378
1383
1379
1384
return ret ;
1380
1385
}
@@ -1465,12 +1470,18 @@ int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,
1465
1470
&& !CHECK_FLAG (dest -> flags , BGP_NODE_USER_CLEAR )
1466
1471
&& !CHECK_FLAG (old_select -> flags , BGP_PATH_ATTR_CHANGED )
1467
1472
&& !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
+ evpn_zebra_install (bgp , vpn ,
1476
+ (const struct prefix_evpn * )
1477
+ bgp_dest_get_prefix (
1478
+ dest ),
1479
+ old_select );
1480
+ else
1481
+ bgp_zebra_route_install (dest , old_select , bgp ,
1482
+ true, vpn , false);
1483
+ }
1484
+
1474
1485
UNSET_FLAG (old_select -> flags , BGP_PATH_MULTIPATH_CHG );
1475
1486
UNSET_FLAG (old_select -> flags , BGP_PATH_LINK_BW_CHG );
1476
1487
bgp_zebra_clear_route_change_flags (dest );
@@ -1502,10 +1513,14 @@ int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,
1502
1513
if (new_select && new_select -> type == ZEBRA_ROUTE_BGP
1503
1514
&& (new_select -> sub_type == BGP_ROUTE_IMPORTED ||
1504
1515
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 );
1516
+ if (CHECK_FLAG (bgp -> flags , BGP_FLAG_DELETE_IN_PROGRESS ))
1517
+ evpn_zebra_install (bgp , vpn ,
1518
+ (const struct prefix_evpn * )
1519
+ bgp_dest_get_prefix (dest ),
1520
+ new_select );
1521
+ else
1522
+ bgp_zebra_route_install (dest , new_select , bgp , true,
1523
+ vpn , false);
1509
1524
1510
1525
/* If an old best existed and it was a "local" route, the only
1511
1526
* reason
@@ -1522,13 +1537,19 @@ int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,
1522
1537
evpn_delete_old_local_route (bgp , vpn , dest ,
1523
1538
old_select , new_select );
1524
1539
} 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);
1540
+ if (old_select && old_select -> type == ZEBRA_ROUTE_BGP &&
1541
+ old_select -> sub_type == BGP_ROUTE_IMPORTED ) {
1542
+ if (CHECK_FLAG (bgp -> flags , BGP_FLAG_DELETE_IN_PROGRESS ) ||
1543
+ CHECK_FLAG (bgp -> flags , BGP_FLAG_VNI_DOWN ))
1544
+ evpn_zebra_uninstall (bgp , vpn ,
1545
+ (const struct prefix_evpn * )
1546
+ bgp_dest_get_prefix (
1547
+ dest ),
1548
+ old_select , false);
1549
+ else
1550
+ bgp_zebra_route_install (dest , old_select , bgp ,
1551
+ false, vpn , false);
1552
+ }
1532
1553
}
1533
1554
1534
1555
/* Clear any route change flags. */
@@ -2062,9 +2083,19 @@ static void evpn_zebra_reinstall_best_route(struct bgp *bgp,
2062
2083
if (curr_select && curr_select -> type == ZEBRA_ROUTE_BGP
2063
2084
&& (curr_select -> sub_type == BGP_ROUTE_IMPORTED ||
2064
2085
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 );
2086
+ if (curr_select && curr_select -> type == ZEBRA_ROUTE_BGP &&
2087
+ (curr_select -> sub_type == BGP_ROUTE_IMPORTED ||
2088
+ bgp_evpn_attr_is_sync (curr_select -> attr ))) {
2089
+ if (CHECK_FLAG (bgp -> flags , BGP_FLAG_DELETE_IN_PROGRESS ))
2090
+ evpn_zebra_install (bgp , vpn ,
2091
+ (const struct prefix_evpn * )
2092
+ bgp_dest_get_prefix (
2093
+ dest ),
2094
+ curr_select );
2095
+ else
2096
+ bgp_zebra_route_install (dest , curr_select , bgp ,
2097
+ true, vpn , false);
2098
+ }
2068
2099
}
2069
2100
2070
2101
/*
@@ -2245,8 +2276,16 @@ static int update_evpn_route(struct bgp *bgp, struct bgpevpn *vpn,
2245
2276
* has been removed.
2246
2277
*/
2247
2278
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);
2279
+ if (!new_is_sync && old_is_sync ) {
2280
+ if (CHECK_FLAG (bgp -> flags ,
2281
+ BGP_FLAG_DELETE_IN_PROGRESS ))
2282
+ evpn_zebra_uninstall (bgp , vpn , p , pi ,
2283
+ true);
2284
+ else
2285
+ bgp_zebra_route_install (dest , pi , bgp ,
2286
+ false, vpn ,
2287
+ true);
2288
+ }
2250
2289
}
2251
2290
}
2252
2291
bgp_path_info_unlock (pi );
@@ -2512,8 +2551,17 @@ void bgp_evpn_update_type2_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
2512
2551
* has been removed.
2513
2552
*/
2514
2553
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);
2554
+ if (!new_is_sync && old_is_sync ) {
2555
+ if (CHECK_FLAG (bgp -> flags ,
2556
+ BGP_FLAG_DELETE_IN_PROGRESS ))
2557
+ (void )evpn_zebra_uninstall (bgp , vpn ,
2558
+ & evp , pi ,
2559
+ true);
2560
+ else
2561
+ bgp_zebra_route_install (dest , pi , bgp ,
2562
+ false, vpn ,
2563
+ true);
2564
+ }
2517
2565
}
2518
2566
}
2519
2567
@@ -2795,7 +2843,22 @@ static int delete_routes_for_vni(struct bgp *bgp, struct bgpevpn *vpn)
2795
2843
delete_all_type2_routes (bgp , vpn );
2796
2844
2797
2845
build_evpn_type3_prefix (& p , vpn -> originator_ip );
2846
+
2847
+ /*
2848
+ * To handle the following scenario:
2849
+ * - Say, the new zebra announce fifo list has few vni Evpn prefixes yet
2850
+ * to be sent to zebra.
2851
+ * - At this point if we have triggers like "no advertise-all-vni" or
2852
+ * "networking restart", where a vni is going down.
2853
+ *
2854
+ * Perform the below
2855
+ * 1) send withdraw routes to zebra immediately in case it is installed.
2856
+ * 2) before we blow up the vni table, we need to walk the list and
2857
+ * pop all the dest whose za_vpn points to this vni.
2858
+ */
2859
+ SET_FLAG (bgp -> flags , BGP_FLAG_VNI_DOWN );
2798
2860
ret = delete_evpn_route (bgp , vpn , & p );
2861
+ UNSET_FLAG (bgp -> flags , BGP_FLAG_VNI_DOWN );
2799
2862
if (ret )
2800
2863
return ret ;
2801
2864
@@ -6262,6 +6325,17 @@ struct bgpevpn *bgp_evpn_new(struct bgp *bgp, vni_t vni,
6262
6325
*/
6263
6326
void bgp_evpn_free (struct bgp * bgp , struct bgpevpn * vpn )
6264
6327
{
6328
+ struct bgp_dest * dest = NULL ;
6329
+
6330
+ while (zebra_announce_count (& bm -> zebra_announce_head )) {
6331
+ dest = zebra_announce_pop (& bm -> zebra_announce_head );
6332
+ if (dest -> za_vpn == vpn ) {
6333
+ bgp_path_info_unlock (dest -> za_bgp_pi );
6334
+ bgp_dest_unlock_node (dest );
6335
+ } else
6336
+ zebra_announce_add_tail (& bm -> zebra_announce_head , dest );
6337
+ }
6338
+
6265
6339
bgp_evpn_remote_ip_hash_destroy (vpn );
6266
6340
bgp_evpn_vni_es_cleanup (vpn );
6267
6341
bgpevpn_unlink_from_l3vni (vpn );
0 commit comments