/* Private functions */
+/*
+ * Return number of valid MACs in a VNI's MAC hash table - all
+ * remote MACs and non-internal (auto) local MACs count.
+ */
+static u_int32_t num_valid_macs(zebra_vni_t *zvni)
+{
+ unsigned int i;
+ u_int32_t num_macs = 0;
+ struct hash *hash;
+ struct hash_backet *hb;
+ zebra_mac_t *mac;
+
+ hash = zvni->mac_table;
+ if (!hash)
+ return num_macs;
+ for (i = 0; i < hash->size; i++) {
+ for (hb = hash->index[i]; hb; hb = hb->next) {
+ mac = (zebra_mac_t *)hb->data;
+ if (CHECK_FLAG(mac->flags, ZEBRA_MAC_REMOTE)
+ || !CHECK_FLAG(mac->flags, ZEBRA_MAC_AUTO))
+ num_macs++;
+ }
+ }
+
+ return num_macs;
+}
+
static int advertise_gw_macip_enabled(zebra_vni_t *zvni)
{
struct zebra_vrf *zvrf;
/*We are iterating over a new VNI, set the count to 0*/
wctx->count = 0;
- num_macs = hashcount(zvni->mac_table);
+ num_macs = num_valid_macs(zvni);
if (!num_macs)
return;
vty_out(vty, " VxLAN interface: unknown\n");
return;
}
- num_macs = hashcount(zvni->mac_table);
+ num_macs = num_valid_macs(zvni);
num_neigh = hashcount(zvni->neigh_table);
if (json == NULL)
vty_out(vty, " VxLAN interface: %s ifIndex: %u VTEP IP: %s\n",
zvtep = zvtep->next;
}
- num_macs = hashcount(zvni->mac_table);
+ num_macs = num_valid_macs(zvni);
num_neigh = hashcount(zvni->neigh_table);
if (json == NULL)
vty_out(vty, "%-10u %-21s %-15s %-8u %-8u %-15u\n", zvni->vni,
vty_out(vty, "%% VNI %u does not exist\n", vni);
return;
}
- num_macs = hashcount(zvni->mac_table);
+ num_macs = num_valid_macs(zvni);
if (!num_macs)
return;
vty_out(vty, "%% VNI %u does not exist\n", vni);
return;
}
- num_macs = hashcount(zvni->mac_table);
+ num_macs = num_valid_macs(zvni);
if (!num_macs)
return;