summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_evpn_mh.c
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/bgp_evpn_mh.c')
-rw-r--r--bgpd/bgp_evpn_mh.c199
1 files changed, 120 insertions, 79 deletions
diff --git a/bgpd/bgp_evpn_mh.c b/bgpd/bgp_evpn_mh.c
index d723a2b1..ad362524 100644
--- a/bgpd/bgp_evpn_mh.c
+++ b/bgpd/bgp_evpn_mh.c
@@ -770,8 +770,7 @@ int bgp_evpn_type4_route_process(struct peer *peer, afi_t afi, safi_t safi,
0, 0, NULL);
} else {
bgp_withdraw(peer, (struct prefix *)&p, addpath_id, afi, safi,
- ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL, 0,
- NULL);
+ ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL, 0);
}
return 0;
}
@@ -1239,8 +1238,7 @@ int bgp_evpn_type1_route_process(struct peer *peer, afi_t afi, safi_t safi,
0, 0, NULL);
} else {
bgp_withdraw(peer, (struct prefix *)&p, addpath_id, afi, safi,
- ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL, 0,
- NULL);
+ ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL, 0);
}
return 0;
}
@@ -1406,8 +1404,8 @@ bgp_zebra_send_remote_es_vtep(struct bgp *bgp, struct bgp_evpn_es_vtep *es_vtep,
return ZCLIENT_SEND_SUCCESS;
}
- if (es_vtep->flags & BGP_EVPNES_VTEP_ESR)
- flags |= ZAPI_ES_VTEP_FLAG_ESR_RXED;
+ if (CHECK_FLAG(es_vtep->flags, BGP_EVPNES_VTEP_ESR))
+ SET_FLAG(flags, ZAPI_ES_VTEP_FLAG_ESR_RXED);
s = zclient->obuf;
stream_reset(s);
@@ -1966,9 +1964,9 @@ static struct bgp_evpn_es *bgp_evpn_es_new(struct bgp *bgp, const esi_t *esi)
*/
static void bgp_evpn_es_free(struct bgp_evpn_es *es, const char *caller)
{
- if ((es->flags & (BGP_EVPNES_LOCAL | BGP_EVPNES_REMOTE))
- || listcount(es->macip_evi_path_list)
- || listcount(es->macip_global_path_list))
+ if (CHECK_FLAG(es->flags, (BGP_EVPNES_LOCAL | BGP_EVPNES_REMOTE)) ||
+ listcount(es->macip_evi_path_list) ||
+ listcount(es->macip_global_path_list))
return;
if (BGP_DEBUG(evpn_mh, EVPN_MH_ES))
@@ -1993,8 +1991,8 @@ static void bgp_evpn_es_free(struct bgp_evpn_es *es, const char *caller)
static inline bool bgp_evpn_is_es_local_and_non_bypass(struct bgp_evpn_es *es)
{
- return (es->flags & BGP_EVPNES_LOCAL)
- && !(es->flags & BGP_EVPNES_BYPASS);
+ return CHECK_FLAG(es->flags, BGP_EVPNES_LOCAL) &&
+ !CHECK_FLAG(es->flags, BGP_EVPNES_BYPASS);
}
/* init local info associated with the ES */
@@ -2076,8 +2074,8 @@ bool bgp_evpn_es_add_l3_ecomm_ok(esi_t *esi)
es = bgp_evpn_es_find(esi);
- return (!es || !(es->flags & BGP_EVPNES_LOCAL)
- || bgp_evpn_local_es_is_active(es));
+ return (!es || !CHECK_FLAG(es->flags, BGP_EVPNES_LOCAL) ||
+ bgp_evpn_local_es_is_active(es));
}
static bool bgp_evpn_is_valid_local_path(struct bgp_path_info *pi)
@@ -2177,9 +2175,9 @@ static void bgp_evpn_mac_update_on_es_local_chg(struct bgp_evpn_es *es,
attr_tmp = *pi->attr;
if (is_local)
- attr_tmp.es_flags |= ATTR_ES_IS_LOCAL;
+ SET_FLAG(attr_tmp.es_flags, ATTR_ES_IS_LOCAL);
else
- attr_tmp.es_flags &= ~ATTR_ES_IS_LOCAL;
+ UNSET_FLAG(attr_tmp.es_flags, ATTR_ES_IS_LOCAL);
attr_new = bgp_attr_intern(&attr_tmp);
bgp_attr_unintern(&pi->attr);
pi->attr = attr_new;
@@ -2473,9 +2471,9 @@ static char *bgp_evpn_es_vteps_str(char *vtep_str, struct bgp_evpn_es *es,
for (ALL_LIST_ELEMENTS_RO(es->es_vtep_list, node, es_vtep)) {
vtep_flag_str[0] = '\0';
- if (es_vtep->flags & BGP_EVPNES_VTEP_ESR)
+ if (CHECK_FLAG(es_vtep->flags, BGP_EVPNES_VTEP_ESR))
strlcat(vtep_flag_str, "E", sizeof(vtep_flag_str));
- if (es_vtep->flags & BGP_EVPNES_VTEP_ACTIVE)
+ if (CHECK_FLAG(es_vtep->flags, BGP_EVPNES_VTEP_ACTIVE))
strlcat(vtep_flag_str, "A", sizeof(vtep_flag_str));
if (!strlen(vtep_flag_str))
@@ -2507,15 +2505,15 @@ static void bgp_evpn_es_json_vtep_fill(json_object *json_vteps,
json_object_string_addf(json_vtep_entry, "vtep_ip", "%pI4",
&es_vtep->vtep_ip);
- if (es_vtep->flags & (BGP_EVPNES_VTEP_ESR |
- BGP_EVPNES_VTEP_ACTIVE)) {
+ if (CHECK_FLAG(es_vtep->flags,
+ (BGP_EVPNES_VTEP_ESR | BGP_EVPNES_VTEP_ACTIVE))) {
json_flags = json_object_new_array();
- if (es_vtep->flags & BGP_EVPNES_VTEP_ESR)
+ if (CHECK_FLAG(es_vtep->flags, BGP_EVPNES_VTEP_ESR))
json_array_string_add(json_flags, "esr");
- if (es_vtep->flags & BGP_EVPNES_VTEP_ACTIVE)
+ if (CHECK_FLAG(es_vtep->flags, BGP_EVPNES_VTEP_ACTIVE))
json_array_string_add(json_flags, "active");
json_object_object_add(json_vtep_entry, "flags", json_flags);
- if (es_vtep->flags & BGP_EVPNES_VTEP_ESR) {
+ if (CHECK_FLAG(es_vtep->flags, BGP_EVPNES_VTEP_ESR)) {
json_object_int_add(json_vtep_entry, "dfPreference",
es_vtep->df_pref);
json_object_string_add(
@@ -2539,9 +2537,9 @@ static void bgp_evpn_es_vteps_show_detail(struct vty *vty,
for (ALL_LIST_ELEMENTS_RO(es->es_vtep_list, node, es_vtep)) {
vtep_flag_str[0] = '\0';
- if (es_vtep->flags & BGP_EVPNES_VTEP_ESR)
+ if (CHECK_FLAG(es_vtep->flags, BGP_EVPNES_VTEP_ESR))
strlcat(vtep_flag_str, "E", sizeof(vtep_flag_str));
- if (es_vtep->flags & BGP_EVPNES_VTEP_ACTIVE)
+ if (CHECK_FLAG(es_vtep->flags, BGP_EVPNES_VTEP_ACTIVE))
strlcat(vtep_flag_str, "A", sizeof(vtep_flag_str));
if (!strlen(vtep_flag_str))
@@ -2550,7 +2548,7 @@ static void bgp_evpn_es_vteps_show_detail(struct vty *vty,
vty_out(vty, " %pI4 flags: %s", &es_vtep->vtep_ip,
vtep_flag_str);
- if (es_vtep->flags & BGP_EVPNES_VTEP_ESR)
+ if (CHECK_FLAG(es_vtep->flags, BGP_EVPNES_VTEP_ESR))
vty_out(vty, " df_alg: %s df_pref: %u\n",
evpn_es_df_alg2str(es_vtep->df_alg, alg_buf,
sizeof(alg_buf)),
@@ -2575,11 +2573,12 @@ static void bgp_evpn_es_show_entry(struct vty *vty,
json_object_string_addf(json, "rd", "%pRDP",
&es->es_base_frag->prd);
- if (es->flags & (BGP_EVPNES_LOCAL | BGP_EVPNES_REMOTE)) {
+ if (CHECK_FLAG(es->flags,
+ (BGP_EVPNES_LOCAL | BGP_EVPNES_REMOTE))) {
json_types = json_object_new_array();
- if (es->flags & BGP_EVPNES_LOCAL)
+ if (CHECK_FLAG(es->flags, BGP_EVPNES_LOCAL))
json_array_string_add(json_types, "local");
- if (es->flags & BGP_EVPNES_REMOTE)
+ if (CHECK_FLAG(es->flags, BGP_EVPNES_REMOTE))
json_array_string_add(json_types, "remote");
json_object_object_add(json, "type", json_types);
}
@@ -2599,11 +2598,11 @@ static void bgp_evpn_es_show_entry(struct vty *vty,
char vtep_str[ES_VTEP_LIST_STR_SZ + BGP_EVPN_VTEPS_FLAG_STR_SZ];
type_str[0] = '\0';
- if (es->flags & BGP_EVPNES_BYPASS)
+ if (CHECK_FLAG(es->flags, BGP_EVPNES_BYPASS))
strlcat(type_str, "B", sizeof(type_str));
- if (es->flags & BGP_EVPNES_LOCAL)
+ if (CHECK_FLAG(es->flags, BGP_EVPNES_LOCAL))
strlcat(type_str, "L", sizeof(type_str));
- if (es->flags & BGP_EVPNES_REMOTE)
+ if (CHECK_FLAG(es->flags, BGP_EVPNES_REMOTE))
strlcat(type_str, "R", sizeof(type_str));
if (es->inconsistencies)
strlcat(type_str, "I", sizeof(type_str));
@@ -2630,16 +2629,16 @@ static void bgp_evpn_es_show_entry_detail(struct vty *vty,
/* Add the "brief" info first */
bgp_evpn_es_show_entry(vty, es, json);
- if (es->flags
- & (BGP_EVPNES_OPER_UP | BGP_EVPNES_ADV_EVI
- | BGP_EVPNES_BYPASS)) {
+ if (CHECK_FLAG(es->flags,
+ (BGP_EVPNES_OPER_UP | BGP_EVPNES_ADV_EVI |
+ BGP_EVPNES_BYPASS))) {
json_flags = json_object_new_array();
- if (es->flags & BGP_EVPNES_OPER_UP)
+ if (CHECK_FLAG(es->flags, BGP_EVPNES_OPER_UP))
json_array_string_add(json_flags, "up");
- if (es->flags & BGP_EVPNES_ADV_EVI)
+ if (CHECK_FLAG(es->flags, BGP_EVPNES_ADV_EVI))
json_array_string_add(json_flags,
"advertiseEVI");
- if (es->flags & BGP_EVPNES_BYPASS)
+ if (CHECK_FLAG(es->flags, BGP_EVPNES_BYPASS))
json_array_string_add(json_flags, "bypass");
json_object_object_add(json, "flags", json_flags);
}
@@ -2655,7 +2654,7 @@ static void bgp_evpn_es_show_entry_detail(struct vty *vty,
listcount(es->macip_global_path_list));
json_object_int_add(json, "inconsistentVniVtepCount",
es->incons_evi_vtep_cnt);
- if (es->flags & BGP_EVPNES_LOCAL)
+ if (CHECK_FLAG(es->flags, BGP_EVPNES_LOCAL))
json_object_int_add(json, "localEsDfPreference",
es->df_pref);
if (listcount(es->es_vtep_list)) {
@@ -2673,7 +2672,8 @@ static void bgp_evpn_es_show_entry_detail(struct vty *vty,
}
if (es->inconsistencies) {
json_incons = json_object_new_array();
- if (es->inconsistencies & BGP_EVPNES_INCONS_VTEP_LIST)
+ if (CHECK_FLAG(es->inconsistencies,
+ BGP_EVPNES_INCONS_VTEP_LIST))
json_array_string_add(json_incons,
"vni-vtep-mismatch");
json_object_object_add(json, "inconsistencies",
@@ -2684,9 +2684,9 @@ static void bgp_evpn_es_show_entry_detail(struct vty *vty,
char type_str[4];
type_str[0] = '\0';
- if (es->flags & BGP_EVPNES_LOCAL)
+ if (CHECK_FLAG(es->flags, BGP_EVPNES_LOCAL))
strlcat(type_str, "L", sizeof(type_str));
- if (es->flags & BGP_EVPNES_REMOTE)
+ if (CHECK_FLAG(es->flags, BGP_EVPNES_REMOTE))
strlcat(type_str, "R", sizeof(type_str));
vty_out(vty, "ESI: %s\n", es->esi_str);
@@ -2694,10 +2694,10 @@ static void bgp_evpn_es_show_entry_detail(struct vty *vty,
vty_out(vty, " RD: %pRDP\n",
es->es_base_frag ? &es->es_base_frag->prd : NULL);
vty_out(vty, " Originator-IP: %pI4\n", &es->originator_ip);
- if (es->flags & BGP_EVPNES_LOCAL)
+ if (CHECK_FLAG(es->flags, BGP_EVPNES_LOCAL))
vty_out(vty, " Local ES DF preference: %u\n",
es->df_pref);
- if (es->flags & BGP_EVPNES_BYPASS)
+ if (CHECK_FLAG(es->flags, BGP_EVPNES_BYPASS))
vty_out(vty, " LACP bypass: on\n");
vty_out(vty, " VNI Count: %d\n", listcount(es->es_evi_list));
vty_out(vty, " Remote VNI Count: %d\n",
@@ -2711,7 +2711,8 @@ static void bgp_evpn_es_show_entry_detail(struct vty *vty,
es->incons_evi_vtep_cnt);
if (es->inconsistencies) {
incons_str[0] = '\0';
- if (es->inconsistencies & BGP_EVPNES_INCONS_VTEP_LIST)
+ if (CHECK_FLAG(es->inconsistencies,
+ BGP_EVPNES_INCONS_VTEP_LIST))
strlcat(incons_str, "vni-vtep-mismatch",
sizeof(incons_str));
} else {
@@ -2935,7 +2936,7 @@ static void bgp_evpn_l3nhg_zebra_del(struct bgp_evpn_es_vrf *es_vrf)
static void bgp_evpn_l3nhg_deactivate(struct bgp_evpn_es_vrf *es_vrf)
{
- if (!(es_vrf->flags & BGP_EVPNES_VRF_NHG_ACTIVE))
+ if (!CHECK_FLAG(es_vrf->flags, BGP_EVPNES_VRF_NHG_ACTIVE))
return;
if (BGP_DEBUG(evpn_mh, EVPN_MH_ES))
@@ -2943,7 +2944,7 @@ static void bgp_evpn_l3nhg_deactivate(struct bgp_evpn_es_vrf *es_vrf)
es_vrf->es->esi_str, es_vrf->bgp_vrf->vrf_id,
es_vrf->nhg_id);
bgp_evpn_l3nhg_zebra_del(es_vrf);
- es_vrf->flags &= ~BGP_EVPNES_VRF_NHG_ACTIVE;
+ UNSET_FLAG(es_vrf->flags, BGP_EVPNES_VRF_NHG_ACTIVE);
/* MAC-IPs can now be installed via the L3NHG */
bgp_evpn_es_path_update_on_es_vrf_chg(es_vrf, "l3nhg-deactivate");
}
@@ -2955,7 +2956,7 @@ static void bgp_evpn_l3nhg_activate(struct bgp_evpn_es_vrf *es_vrf, bool update)
return;
}
- if (es_vrf->flags & BGP_EVPNES_VRF_NHG_ACTIVE) {
+ if (CHECK_FLAG(es_vrf->flags, BGP_EVPNES_VRF_NHG_ACTIVE)) {
if (!update)
return;
} else {
@@ -2963,7 +2964,7 @@ static void bgp_evpn_l3nhg_activate(struct bgp_evpn_es_vrf *es_vrf, bool update)
zlog_debug("es %s vrf %u nhg %u activate",
es_vrf->es->esi_str, es_vrf->bgp_vrf->vrf_id,
es_vrf->nhg_id);
- es_vrf->flags |= BGP_EVPNES_VRF_NHG_ACTIVE;
+ SET_FLAG(es_vrf->flags, BGP_EVPNES_VRF_NHG_ACTIVE);
/* MAC-IPs can now be installed via the L3NHG */
bgp_evpn_es_path_update_on_es_vrf_chg(es_vrf, "l3nhg_activate");
}
@@ -3184,7 +3185,7 @@ void bgp_evpn_es_vrf_use_nhg(struct bgp *bgp_vrf, esi_t *esi, bool *use_l3nhg,
return;
*use_l3nhg = true;
- if (es_vrf->flags & BGP_EVPNES_VRF_NHG_ACTIVE)
+ if (CHECK_FLAG(es_vrf->flags, BGP_EVPNES_VRF_NHG_ACTIVE))
*is_l3nhg_active = true;
if (es_vrf_p)
*es_vrf_p = es_vrf;
@@ -3276,9 +3277,9 @@ static void bgp_evpn_es_vrf_show_entry(struct vty *vty,
json_object_string_add(json, "esi", es->esi_str);
json_object_string_add(json, "vrf", bgp_vrf->name_pretty);
- if (es_vrf->flags & (BGP_EVPNES_VRF_NHG_ACTIVE)) {
+ if (CHECK_FLAG(es_vrf->flags, (BGP_EVPNES_VRF_NHG_ACTIVE))) {
json_types = json_object_new_array();
- if (es_vrf->flags & BGP_EVPNES_VRF_NHG_ACTIVE)
+ if (CHECK_FLAG(es_vrf->flags, BGP_EVPNES_VRF_NHG_ACTIVE))
json_array_string_add(json_types, "active");
json_object_object_add(json, "flags", json_types);
}
@@ -3290,7 +3291,7 @@ static void bgp_evpn_es_vrf_show_entry(struct vty *vty,
char flags_str[4];
flags_str[0] = '\0';
- if (es_vrf->flags & BGP_EVPNES_VRF_NHG_ACTIVE)
+ if (CHECK_FLAG(es_vrf->flags, BGP_EVPNES_VRF_NHG_ACTIVE))
strlcat(flags_str, "A", sizeof(flags_str));
vty_out(vty, "%-30s %-15s %-5s %-8u %-8u %u\n", es->esi_str,
@@ -3400,7 +3401,7 @@ static void bgp_evpn_es_evi_vtep_free(struct bgp_evpn_es_evi_vtep *evi_vtep)
{
struct bgp_evpn_es_evi *es_evi = evi_vtep->es_evi;
- if (evi_vtep->flags & (BGP_EVPN_EVI_VTEP_EAD))
+ if (CHECK_FLAG(evi_vtep->flags, (BGP_EVPN_EVI_VTEP_EAD)))
/* as long as there is some reference we can't free it */
return;
@@ -3445,7 +3446,8 @@ bgp_evpn_es_evi_vtep_re_eval_active(struct bgp *bgp,
/* EAD-per-ES is sufficent to activate the PE */
ead_activity_flags = BGP_EVPN_EVI_VTEP_EAD_PER_ES;
- if ((evi_vtep->flags & ead_activity_flags) == ead_activity_flags)
+ if (CHECK_FLAG(evi_vtep->flags, ead_activity_flags) ==
+ ead_activity_flags)
SET_FLAG(evi_vtep->flags, BGP_EVPN_EVI_VTEP_ACTIVE);
else
UNSET_FLAG(evi_vtep->flags, BGP_EVPN_EVI_VTEP_ACTIVE);
@@ -3602,7 +3604,8 @@ bgp_evpn_es_evi_free(struct bgp_evpn_es_evi *es_evi)
/* cannot free the element as long as there is a local or remote
* reference
*/
- if (es_evi->flags & (BGP_EVPNES_EVI_LOCAL | BGP_EVPNES_EVI_REMOTE))
+ if (CHECK_FLAG(es_evi->flags,
+ (BGP_EVPNES_EVI_LOCAL | BGP_EVPNES_EVI_REMOTE)))
return es_evi;
bgp_evpn_es_frag_evi_del(es_evi, false);
bgp_evpn_es_vrf_deref(es_evi);
@@ -3804,6 +3807,7 @@ int bgp_evpn_local_es_evi_add(struct bgp *bgp, esi_t *esi, vni_t vni)
bgp_evpn_ead_evi_route_update(bgp, es, vpn, &p);
}
+ bgp_evpn_local_es_evi_unistall_local_routes_in_vrfs(es, es_evi);
/* update EAD-ES */
if (bgp_evpn_local_es_is_active(es))
bgp_evpn_ead_es_route_update(bgp, es);
@@ -3924,8 +3928,8 @@ static void bgp_evpn_remote_es_evi_flush(struct bgp_evpn_es_evi *es_evi)
/* delete all VTEPs */
for (ALL_LIST_ELEMENTS(es_evi->es_evi_vtep_list, node, nnode,
evi_vtep)) {
- evi_vtep->flags &= ~(BGP_EVPN_EVI_VTEP_EAD_PER_ES
- | BGP_EVPN_EVI_VTEP_EAD_PER_EVI);
+ UNSET_FLAG(evi_vtep->flags, (BGP_EVPN_EVI_VTEP_EAD_PER_ES |
+ BGP_EVPN_EVI_VTEP_EAD_PER_EVI));
bgp_evpn_es_evi_vtep_re_eval_active(bgp, evi_vtep);
bgp_evpn_es_evi_vtep_free(evi_vtep);
}
@@ -3973,9 +3977,9 @@ static char *bgp_evpn_es_evi_vteps_str(char *vtep_str,
vtep_str[0] = '\0';
for (ALL_LIST_ELEMENTS_RO(es_evi->es_evi_vtep_list, node, evi_vtep)) {
vtep_flag_str[0] = '\0';
- if (evi_vtep->flags & BGP_EVPN_EVI_VTEP_EAD_PER_ES)
+ if (CHECK_FLAG(evi_vtep->flags, BGP_EVPN_EVI_VTEP_EAD_PER_ES))
strlcat(vtep_flag_str, "E", sizeof(vtep_flag_str));
- if (evi_vtep->flags & BGP_EVPN_EVI_VTEP_EAD_PER_EVI)
+ if (CHECK_FLAG(evi_vtep->flags, BGP_EVPN_EVI_VTEP_EAD_PER_EVI))
strlcat(vtep_flag_str, "V", sizeof(vtep_flag_str));
if (!strnlen(vtep_flag_str, sizeof(vtep_flag_str)))
@@ -4006,12 +4010,12 @@ static void bgp_evpn_es_evi_json_vtep_fill(json_object *json_vteps,
json_object_string_addf(json_vtep_entry, "vtep_ip", "%pI4",
&evi_vtep->vtep_ip);
- if (evi_vtep->flags & (BGP_EVPN_EVI_VTEP_EAD_PER_ES |
- BGP_EVPN_EVI_VTEP_EAD_PER_EVI)) {
+ if (CHECK_FLAG(evi_vtep->flags, (BGP_EVPN_EVI_VTEP_EAD_PER_ES |
+ BGP_EVPN_EVI_VTEP_EAD_PER_EVI))) {
json_flags = json_object_new_array();
- if (evi_vtep->flags & BGP_EVPN_EVI_VTEP_EAD_PER_ES)
+ if (CHECK_FLAG(evi_vtep->flags, BGP_EVPN_EVI_VTEP_EAD_PER_ES))
json_array_string_add(json_flags, "ead-per-es");
- if (evi_vtep->flags & BGP_EVPN_EVI_VTEP_EAD_PER_EVI)
+ if (CHECK_FLAG(evi_vtep->flags, BGP_EVPN_EVI_VTEP_EAD_PER_EVI))
json_array_string_add(json_flags, "ead-per-evi");
json_object_object_add(json_vtep_entry,
"flags", json_flags);
@@ -4035,12 +4039,12 @@ static void bgp_evpn_es_evi_show_entry(struct vty *vty,
if (es_evi->vpn)
json_object_int_add(json, "vni", es_evi->vpn->vni);
- if (es_evi->flags & (BGP_EVPNES_EVI_LOCAL |
- BGP_EVPNES_EVI_REMOTE)) {
+ if (CHECK_FLAG(es_evi->flags, (BGP_EVPNES_EVI_LOCAL |
+ BGP_EVPNES_EVI_REMOTE))) {
json_types = json_object_new_array();
- if (es_evi->flags & BGP_EVPNES_EVI_LOCAL)
+ if (CHECK_FLAG(es_evi->flags, BGP_EVPNES_EVI_LOCAL))
json_array_string_add(json_types, "local");
- if (es_evi->flags & BGP_EVPNES_EVI_REMOTE)
+ if (CHECK_FLAG(es_evi->flags, BGP_EVPNES_EVI_REMOTE))
json_array_string_add(json_types, "remote");
json_object_object_add(json, "type", json_types);
}
@@ -4059,11 +4063,11 @@ static void bgp_evpn_es_evi_show_entry(struct vty *vty,
char vtep_str[ES_VTEP_LIST_STR_SZ + BGP_EVPN_VTEPS_FLAG_STR_SZ];
type_str[0] = '\0';
- if (es_evi->flags & BGP_EVPNES_EVI_LOCAL)
+ if (CHECK_FLAG(es_evi->flags, BGP_EVPNES_EVI_LOCAL))
strlcat(type_str, "L", sizeof(type_str));
- if (es_evi->flags & BGP_EVPNES_EVI_REMOTE)
+ if (CHECK_FLAG(es_evi->flags, BGP_EVPNES_EVI_REMOTE))
strlcat(type_str, "R", sizeof(type_str));
- if (es_evi->flags & BGP_EVPNES_EVI_INCONS_VTEP_LIST)
+ if (CHECK_FLAG(es_evi->flags, BGP_EVPNES_EVI_INCONS_VTEP_LIST))
strlcat(type_str, "I", sizeof(type_str));
bgp_evpn_es_evi_vteps_str(vtep_str, es_evi, sizeof(vtep_str));
@@ -4090,7 +4094,7 @@ static void bgp_evpn_es_evi_show_entry_detail(struct vty *vty,
json_object_string_addf(json, "esFragmentRd",
BGP_RD_AS_FORMAT(mode),
&es_evi->es_frag->prd);
- if (es_evi->flags & BGP_EVPNES_EVI_INCONS_VTEP_LIST) {
+ if (CHECK_FLAG(es_evi->flags, BGP_EVPNES_EVI_INCONS_VTEP_LIST)) {
json_flags = json_object_new_array();
json_array_string_add(json_flags, "es-vtep-mismatch");
json_object_object_add(json, "flags", json_flags);
@@ -4100,9 +4104,9 @@ static void bgp_evpn_es_evi_show_entry_detail(struct vty *vty,
char type_str[4];
type_str[0] = '\0';
- if (es_evi->flags & BGP_EVPNES_EVI_LOCAL)
+ if (CHECK_FLAG(es_evi->flags, BGP_EVPNES_EVI_LOCAL))
strlcat(type_str, "L", sizeof(type_str));
- if (es_evi->flags & BGP_EVPNES_EVI_REMOTE)
+ if (CHECK_FLAG(es_evi->flags, BGP_EVPNES_EVI_REMOTE))
strlcat(type_str, "R", sizeof(type_str));
bgp_evpn_es_evi_vteps_str(vtep_str, es_evi, sizeof(vtep_str));
@@ -4119,8 +4123,10 @@ static void bgp_evpn_es_evi_show_entry_detail(struct vty *vty,
vty_out(vty, "\n");
}
vty_out(vty, " Inconsistencies: %s\n",
- (es_evi->flags & BGP_EVPNES_EVI_INCONS_VTEP_LIST) ?
- "es-vtep-mismatch":"-");
+ CHECK_FLAG(es_evi->flags,
+ BGP_EVPNES_EVI_INCONS_VTEP_LIST)
+ ? "es-vtep-mismatch"
+ : "-");
vty_out(vty, " VTEPs: %s\n", vtep_str);
vty_out(vty, "\n");
}
@@ -4514,12 +4520,12 @@ static void bgp_evpn_nh_zebra_update_send(struct bgp_evpn_nh *nh, bool add)
static void bgp_evpn_nh_zebra_update(struct bgp_evpn_nh *nh, bool add)
{
if (add && !is_zero_mac(&nh->rmac)) {
- nh->flags |= BGP_EVPN_NH_READY_FOR_ZEBRA;
+ SET_FLAG(nh->flags, BGP_EVPN_NH_READY_FOR_ZEBRA);
bgp_evpn_nh_zebra_update_send(nh, true);
} else {
- if (!(nh->flags & BGP_EVPN_NH_READY_FOR_ZEBRA))
+ if (!CHECK_FLAG(nh->flags, BGP_EVPN_NH_READY_FOR_ZEBRA))
return;
- nh->flags &= ~BGP_EVPN_NH_READY_FOR_ZEBRA;
+ UNSET_FLAG(nh->flags, BGP_EVPN_NH_READY_FOR_ZEBRA);
bgp_evpn_nh_zebra_update_send(nh, false);
}
}
@@ -4811,7 +4817,7 @@ static void bgp_evpn_path_nh_link(struct bgp *bgp_vrf, struct bgp_path_info *pi)
/* if NHG is not being used for this path we don't need to manage the
* nexthops in bgp (they are managed by zebra instead)
*/
- if (!(pi->attr->es_flags & ATTR_ES_L3_NHG_USE)) {
+ if (!CHECK_FLAG(pi->attr->es_flags, ATTR_ES_L3_NHG_USE)) {
if (nh_info)
bgp_evpn_path_nh_unlink(nh_info);
return;
@@ -5053,3 +5059,38 @@ void bgp_evpn_switch_ead_evi_rx(void)
}
}
}
+
+void bgp_evpn_local_es_evi_unistall_local_routes_in_vrfs(struct bgp_evpn_es *es,
+ struct bgp_evpn_es_evi *es_evi)
+{
+ struct listnode *node;
+ struct bgp_path_es_info *es_info;
+ struct bgp_path_info *pi;
+ const struct prefix_evpn *evp;
+ struct bgp_evpn_es_vrf *es_vrf = es_evi->es_vrf;
+
+ if (!es_vrf)
+ return;
+
+ for (ALL_LIST_ELEMENTS_RO(es->macip_global_path_list, node, es_info)) {
+ pi = es_info->pi;
+
+ if (!bgp_evpn_is_macip_path(pi))
+ continue;
+
+ evp = (const struct prefix_evpn *)bgp_dest_get_prefix(pi->net);
+
+ if (!(CHECK_FLAG(pi->flags, BGP_PATH_VALID) && pi->type == ZEBRA_ROUTE_BGP &&
+ pi->sub_type == BGP_ROUTE_NORMAL))
+ continue;
+
+ if (BGP_DEBUG(evpn_mh, EVPN_MH_RT))
+ zlog_debug("route %pFX is matched on local esi %s, uninstall from %s route table",
+ evp, es->esi_str, es_vrf->bgp_vrf->name_pretty);
+
+ if (!bgp_evpn_skip_vrf_import_of_local_es(es_vrf->bgp_vrf, evp, pi, 0))
+ continue;
+
+ uninstall_evpn_route_entry_in_vrf(es_vrf->bgp_vrf, evp, pi);
+ }
+}