}
static void zebra_evpn_mac_get_access_info(struct zebra_mac *mac,
- struct interface **ifpP,
+ struct interface **p_ifp,
vlanid_t *vid)
{
/* if the mac is associated with an ES we must get the access
struct zebra_if *zif;
/* get the access port from the es */
- *ifpP = mac->es->zif ? mac->es->zif->ifp : NULL;
+ *p_ifp = mac->es->zif ? mac->es->zif->ifp : NULL;
/* get the vlan from the EVPN */
if (mac->zevpn->vxlan_if) {
zif = mac->zevpn->vxlan_if->info;
*vid = mac->fwd_info.local.vid;
zns = zebra_ns_lookup(mac->fwd_info.local.ns_id);
- *ifpP = if_lookup_by_index_per_ns(zns,
- mac->fwd_info.local.ifindex);
+ *p_ifp = if_lookup_by_index_per_ns(zns,
+ mac->fwd_info.local.ifindex);
}
}
: "",
CHECK_FLAG(mac->flags, ZEBRA_MAC_DUPLICATE) ? "DUP " : "",
CHECK_FLAG(mac->flags, ZEBRA_MAC_FPM_SENT) ? "FPM " : "",
- CHECK_FLAG(mac->flags, ZEBRA_MAC_ES_PEER_ACTIVE) ? "LOC Active "
- : "",
+ CHECK_FLAG(mac->flags, ZEBRA_MAC_ES_PEER_ACTIVE)
+ ? "PEER Active "
+ : "",
CHECK_FLAG(mac->flags, ZEBRA_MAC_ES_PEER_PROXY) ? "PROXY " : "",
CHECK_FLAG(mac->flags, ZEBRA_MAC_LOCAL_INACTIVE)
? "LOC Inactive "
return 0;
}
+/*
+ * Add Auto MAC entry.
+ */
+struct zebra_mac *zebra_evpn_mac_add_auto(struct zebra_evpn *zevpn,
+ const struct ethaddr *macaddr)
+{
+ struct zebra_mac *mac;
+
+ mac = zebra_evpn_mac_add(zevpn, macaddr);
+ if (!mac)
+ return NULL;
+
+ zebra_evpn_mac_clear_fwd_info(mac);
+ memset(&mac->flags, 0, sizeof(uint32_t));
+ SET_FLAG(mac->flags, ZEBRA_MAC_AUTO);
+
+ return mac;
+}
+
static bool zebra_evpn_check_mac_del_from_db(struct mac_walk_ctx *wctx,
struct zebra_mac *mac)
{
static inline bool zebra_evpn_mac_is_bgp_seq_ok(struct zebra_evpn *zevpn,
struct zebra_mac *mac,
- uint32_t seq, uint16_t ipa_len,
- const struct ipaddr *ipaddr,
- bool sync)
+ uint32_t seq, bool sync)
{
- char ipbuf[INET6_ADDRSTRLEN];
+ char mac_buf[MAC_BUF_SIZE];
uint32_t tmp_seq;
const char *n_type;
+ bool is_local = false;
if (CHECK_FLAG(mac->flags, ZEBRA_MAC_LOCAL)) {
tmp_seq = mac->loc_seq;
n_type = "local";
+ is_local = true;
} else {
tmp_seq = mac->rem_seq;
n_type = "remote";
}
if (seq < tmp_seq) {
+
+ if (is_local && !zebra_evpn_mac_is_ready_for_bgp(mac->flags)) {
+ if (IS_ZEBRA_DEBUG_EVPN_MH_MAC || IS_ZEBRA_DEBUG_VXLAN)
+ zlog_debug(
+ "%s-macip not ready vni %u %s-mac %pEA lower seq %u f 0x%x",
+ sync ? "sync" : "rem", zevpn->vni,
+ n_type, &mac->macaddr, tmp_seq,
+ mac->flags);
+ return true;
+ }
+
/* if the mac was never advertised to bgp we must accept
* whatever sequence number bgp sends
- * XXX - check with Vivek
*/
- if (CHECK_FLAG(mac->flags, ZEBRA_MAC_LOCAL)
- && !zebra_evpn_mac_is_ready_for_bgp(mac->flags)) {
- if (IS_ZEBRA_DEBUG_EVPN_MH_MAC
- || IS_ZEBRA_DEBUG_VXLAN) {
- char mac_buf[MAC_BUF_SIZE];
-
+ if (!is_local && zebra_vxlan_get_accept_bgp_seq()) {
+ if (IS_ZEBRA_DEBUG_EVPN_MH_MAC ||
+ IS_ZEBRA_DEBUG_VXLAN) {
zlog_debug(
- "%s-macip accept vni %u %s-mac %pEA%s%s lower seq %u f %s",
+ "%s-macip accept vni %u %s-mac %pEA lower seq %u f %s",
sync ? "sync" : "rem", zevpn->vni,
- n_type,
- &mac->macaddr,
- ipa_len ? " IP " : "",
- ipa_len ? ipaddr2str(ipaddr, ipbuf,
- sizeof(ipbuf))
- : "",
- tmp_seq,
+ n_type, &mac->macaddr, tmp_seq,
zebra_evpn_zebra_mac_flag_dump(
mac, mac_buf, sizeof(mac_buf)));
}
}
if (IS_ZEBRA_DEBUG_EVPN_MH_MAC || IS_ZEBRA_DEBUG_VXLAN) {
- char mac_buf[MAC_BUF_SIZE];
-
zlog_debug(
- "%s-macip ignore vni %u %s-mac %pEA%s%s as existing has higher seq %u f %s",
+ "%s-macip ignore vni %u %s-mac %pEA as existing has higher seq %u f %s",
sync ? "sync" : "rem", zevpn->vni, n_type,
- &mac->macaddr,
- ipa_len ? " IP " : "",
- ipa_len ? ipaddr2str(ipaddr, ipbuf,
- sizeof(ipbuf))
- : "",
- tmp_seq,
+ &mac->macaddr, tmp_seq,
zebra_evpn_zebra_mac_flag_dump(
mac, mac_buf, sizeof(mac_buf)));
}
+
return false;
}
return true;
}
-struct zebra_mac *zebra_evpn_proc_sync_mac_update(
- struct zebra_evpn *zevpn, const struct ethaddr *macaddr,
- uint16_t ipa_len, const struct ipaddr *ipaddr, uint8_t flags,
- uint32_t seq, const esi_t *esi, struct sync_mac_ip_ctx *ctx)
+struct zebra_mac *zebra_evpn_proc_sync_mac_update(struct zebra_evpn *zevpn,
+ const struct ethaddr *macaddr,
+ uint16_t ipa_len,
+ const struct ipaddr *ipaddr,
+ uint8_t flags, uint32_t seq,
+ const esi_t *esi)
{
struct zebra_mac *mac;
bool inform_bgp = false;
bool old_local = false;
bool old_bgp_ready;
bool new_bgp_ready;
+ bool created = false;
mac = zebra_evpn_mac_lookup(zevpn, macaddr);
if (!mac) {
*/
inform_bgp = true;
inform_dataplane = true;
- ctx->mac_created = true;
- ctx->mac_inactive = true;
/* create the MAC and associate it with the dest ES */
mac = zebra_evpn_mac_add(zevpn, macaddr);
SET_FLAG(mac->flags, ZEBRA_MAC_LOCAL_INACTIVE);
old_bgp_ready = false;
new_bgp_ready = zebra_evpn_mac_is_ready_for_bgp(mac->flags);
+ created = true;
} else {
uint32_t old_flags;
uint32_t new_flags;
: "",
sticky ? " sticky" : "",
remote_gw ? " remote_gw" : "");
- ctx->ignore_macip = true;
return NULL;
}
- if (!zebra_evpn_mac_is_bgp_seq_ok(zevpn, mac, seq, ipa_len,
- ipaddr, true)) {
- ctx->ignore_macip = true;
+ if (!zebra_evpn_mac_is_bgp_seq_ok(zevpn, mac, seq, true))
return NULL;
- }
old_local = !!CHECK_FLAG(old_flags, ZEBRA_MAC_LOCAL);
old_static = zebra_evpn_mac_is_static(mac);
new_flags = 0;
SET_FLAG(new_flags, ZEBRA_MAC_LOCAL);
/* retain old local activity flag */
- if (old_flags & ZEBRA_MAC_LOCAL) {
+ if (old_flags & ZEBRA_MAC_LOCAL)
new_flags |= (old_flags & ZEBRA_MAC_LOCAL_INACTIVE);
- } else {
+ else
new_flags |= ZEBRA_MAC_LOCAL_INACTIVE;
- ctx->mac_inactive = true;
- }
+
if (ipa_len) {
/* if mac-ip route do NOT update the peer flags
* i.e. retain only flags as is
if (es_change) {
inform_bgp = true;
inform_dataplane = true;
- ctx->mac_inactive = true;
}
/* if peer-flag is being set notify dataplane that the
char mac_buf[MAC_BUF_SIZE];
zlog_debug("sync-mac %s vni %u mac %pEA es %s seq %d f %s%s%s",
- ctx->mac_created ? "created" : "updated",
- zevpn->vni, macaddr,
+ created ? "created" : "updated", zevpn->vni, macaddr,
mac->es ? mac->es->esi_str : "-", mac->loc_seq,
zebra_evpn_zebra_mac_flag_dump(mac, mac_buf,
sizeof(mac_buf)),
zebra_evpn_process_neigh_on_local_mac_change(
zevpn, mac, seq_change, es_change);
- if (inform_dataplane) {
- if (ipa_len)
- /* if the mac is being created as a part of MAC-IP
- * route wait for the neigh to be updated or
- * created before programming the mac
- */
- ctx->mac_dp_update_deferred = true;
- else
- /* program the local mac in the kernel. when the ES
- * change we need to force the dataplane to reset
- * the activity as we are yet to establish activity
- * locally
- */
- zebra_evpn_sync_mac_dp_install(
- mac, ctx->mac_inactive,
- false /* force_clear_static */, __func__);
+ if (inform_dataplane && !ipa_len) {
+ /* program the local mac in the kernel. when the ES
+ * change we need to force the dataplane to reset
+ * the activity as we are yet to establish activity
+ * locally
+ */
+ zebra_evpn_sync_mac_dp_install(mac, false /* set_inactive */,
+ false /* force_clear_static */,
+ __func__);
}
return mac;
zebra_evpn_print_mac_hash_detail(bucket, ctxt);
}
-int zebra_evpn_mac_remote_macip_add(
- struct zebra_evpn *zevpn, struct zebra_vrf *zvrf,
- const struct ethaddr *macaddr, uint16_t ipa_len,
- const struct ipaddr *ipaddr, struct zebra_mac **macp,
- struct in_addr vtep_ip, uint8_t flags, uint32_t seq, const esi_t *esi)
+int zebra_evpn_mac_remote_macip_add(struct zebra_evpn *zevpn,
+ struct zebra_vrf *zvrf,
+ const struct ethaddr *macaddr,
+ struct in_addr vtep_ip, uint8_t flags,
+ uint32_t seq, const esi_t *esi)
{
- char buf1[INET6_ADDRSTRLEN];
bool sticky;
bool remote_gw;
int update_mac = 0;
&& CHECK_FLAG(flags, ZEBRA_MACIP_TYPE_GW)) {
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
- "Ignore remote MACIP ADD VNI %u MAC %pEA%s%s as MAC is already configured as gateway MAC",
- zevpn->vni, macaddr,
- ipa_len ? " IP " : "",
- ipa_len ? ipaddr2str(ipaddr, buf1, sizeof(buf1))
- : "");
+ "Ignore remote MACIP ADD VNI %u MAC %pEA as MAC is already configured as gateway MAC",
+ zevpn->vni, macaddr);
return -1;
}
if (!mac) {
mac = zebra_evpn_mac_add(zevpn, macaddr);
zebra_evpn_es_mac_ref(mac, esi);
-
- /* Is this MAC created for a MACIP? */
- if (ipa_len)
- SET_FLAG(mac->flags, ZEBRA_MAC_AUTO);
} else {
/* When host moves but changes its (MAC,IP)
* binding, BGP may install a MACIP entry that
* the sequence number and ignore this update
* if appropriate.
*/
- if (!zebra_evpn_mac_is_bgp_seq_ok(
- zevpn, mac, seq, ipa_len, ipaddr, false))
+ if (!zebra_evpn_mac_is_bgp_seq_ok(zevpn, mac, seq,
+ false))
return -1;
old_es_present = !!mac->es;
/* Update seq number. */
mac->rem_seq = seq;
- /* If there is no IP, return after clearing AUTO flag of MAC. */
- if (!ipa_len) {
- UNSET_FLAG(mac->flags, ZEBRA_MAC_AUTO);
- return -1;
- }
- *macp = mac;
+ UNSET_FLAG(mac->flags, ZEBRA_MAC_AUTO);
return 0;
}