/*
* Uninstall remote MAC from the forwarding plane.
*/
-int zebra_evpn_rem_mac_uninstall(zebra_evpn_t *zevpn, zebra_mac_t *mac)
+int zebra_evpn_rem_mac_uninstall(zebra_evpn_t *zevpn, zebra_mac_t *mac,
+ bool force)
{
const struct zebra_if *zif, *br_zif;
const struct zebra_l2info_vxlan *vxl;
if (!(mac->flags & ZEBRA_MAC_REMOTE))
return 0;
+ /* If the MAC was not installed there is no need to uninstall it */
+ if (!force && mac->es && !(mac->es->flags & ZEBRA_EVPNES_NHG_ACTIVE))
+ return -1;
+
if (!zevpn->vxlan_if) {
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
*/
if (CHECK_FLAG(mac->flags, ZEBRA_MAC_REMOTE)
&& remote_neigh_count(mac) == 0) {
- zebra_evpn_rem_mac_uninstall(zevpn, mac);
+ zebra_evpn_rem_mac_uninstall(zevpn, mac, false /*force*/);
zebra_evpn_es_mac_deref_entry(mac);
UNSET_FLAG(mac->flags, ZEBRA_MAC_REMOTE);
}
__func__);
if (mac->flags & ZEBRA_MAC_REMOTE)
- zebra_evpn_rem_mac_uninstall(wctx->zevpn, mac);
+ zebra_evpn_rem_mac_uninstall(wctx->zevpn, mac,
+ false /*force*/);
}
zebra_evpn_mac_del(wctx->zevpn, mac);
* go away, we need to uninstall the MAC.
*/
if (remote_neigh_count(mac) == 0) {
- zebra_evpn_rem_mac_uninstall(zevpn, mac);
+ zebra_evpn_rem_mac_uninstall(zevpn, mac, false /*force*/);
zebra_evpn_es_mac_deref_entry(mac);
UNSET_FLAG(mac->flags, ZEBRA_MAC_REMOTE);
}
struct hash *zebra_mac_db_create(const char *desc);
uint32_t num_valid_macs(zebra_evpn_t *zevi);
uint32_t num_dup_detected_macs(zebra_evpn_t *zevi);
-int zebra_evpn_rem_mac_uninstall(zebra_evpn_t *zevi, zebra_mac_t *mac);
+int zebra_evpn_rem_mac_uninstall(zebra_evpn_t *zevi, zebra_mac_t *mac,
+ bool force);
int zebra_evpn_rem_mac_install(zebra_evpn_t *zevi, zebra_mac_t *mac,
bool was_static);
void zebra_evpn_deref_ip2mac(zebra_evpn_t *zevi, zebra_mac_t *mac);
bf_release_index(zmh_info->nh_id_bitmap, id);
}
+/* update remote macs associated with the ES */
+static void zebra_evpn_nhg_mac_update(struct zebra_evpn_es *es)
+{
+ zebra_mac_t *mac;
+ struct listnode *node;
+
+ for (ALL_LIST_ELEMENTS_RO(es->mac_list, node, mac)) {
+ if (!CHECK_FLAG(mac->flags, ZEBRA_MAC_REMOTE))
+ continue;
+
+ if (es->flags & ZEBRA_EVPNES_NHG_ACTIVE)
+ zebra_evpn_rem_mac_install(mac->zevpn, mac,
+ false /*was_static*/);
+ else
+ zebra_evpn_rem_mac_uninstall(mac->zevpn, mac,
+ true /*force*/);
+ }
+}
+
/* The MAC ECMP group is activated on the first VTEP */
static void zebra_evpn_nhg_update(struct zebra_evpn_es *es)
{
es->nhg_id, nh_str);
}
- es->flags |= ZEBRA_EVPNES_NHG_ACTIVE;
kernel_upd_mac_nhg(es->nhg_id, nh_cnt, nh_ids);
if (!(es->flags & ZEBRA_EVPNES_NHG_ACTIVE)) {
es->flags |= ZEBRA_EVPNES_NHG_ACTIVE;
if ((es->flags & ZEBRA_EVPNES_LOCAL))
zebra_evpn_es_br_port_dplane_update(es,
__func__);
+ zebra_evpn_nhg_mac_update(es);
}
} else {
if (es->flags & ZEBRA_EVPNES_NHG_ACTIVE) {
if ((es->flags & ZEBRA_EVPNES_LOCAL))
zebra_evpn_es_br_port_dplane_update(es,
__func__);
+ zebra_evpn_nhg_mac_update(es);
kernel_del_mac_nhg(es->nhg_id);
}
}
- /* XXX - update remote macs associated with the ES */
}
static void zebra_evpn_nh_add(struct zebra_evpn_es_vtep *es_vtep)