static void zl3vni_print_rmac(struct zebra_mac *zrmac, struct vty *vty,
json_object *json)
{
- char buf[INET6_ADDRSTRLEN];
- char buf1[ETHER_ADDR_STRLEN];
- char buf2[PREFIX_STRLEN];
struct listnode *node = NULL;
struct ipaddr *vtep = NULL;
json_object *json_nhs = NULL;
- json_object *json_hosts = NULL;
- struct host_rb_entry *hle;
if (!json) {
- vty_out(vty, "MAC: %s\n",
- prefix_mac2str(&zrmac->macaddr, buf1, sizeof(buf1)));
+ vty_out(vty, "MAC: %pEA\n", &zrmac->macaddr);
vty_out(vty, " Remote VTEP: %pI4\n",
&zrmac->fwd_info.r_vtep_ip);
- vty_out(vty, " Refcount: %d\n", rb_host_count(&zrmac->host_rb));
- vty_out(vty, " Prefixes:\n");
- RB_FOREACH (hle, host_rb_tree_entry, &zrmac->host_rb)
- vty_out(vty, " %pFX\n", &hle->p);
} else {
- json_hosts = json_object_new_array();
json_nhs = json_object_new_array();
- json_object_string_add(
- json, "routerMac",
- prefix_mac2str(&zrmac->macaddr, buf1, sizeof(buf1)));
+ json_object_string_addf(json, "routerMac", "%pEA",
+ &zrmac->macaddr);
json_object_string_addf(json, "vtepIp", "%pI4",
&zrmac->fwd_info.r_vtep_ip);
for (ALL_LIST_ELEMENTS_RO(zrmac->nh_list, node, vtep)) {
- json_object_array_add(json_nhs,
- json_object_new_string(ipaddr2str(
- vtep, buf, sizeof(buf))));
+ json_object_array_add(json_nhs, json_object_new_stringf(
+ "%pIA", vtep));
}
json_object_object_add(json, "nexthops", json_nhs);
- json_object_int_add(json, "refCount",
- rb_host_count(&zrmac->host_rb));
- RB_FOREACH (hle, host_rb_tree_entry, &zrmac->host_rb)
- json_object_array_add(
- json_hosts,
- json_object_new_string(prefix2str(
- &hle->p, buf2, sizeof(buf2))));
- json_object_object_add(json, "prefixList", json_hosts);
}
}
zrmac = hash_get(zl3vni->rmac_table, &tmp_rmac, zl3vni_rmac_alloc);
assert(zrmac);
- RB_INIT(host_rb_tree_entry, &zrmac->host_rb);
zrmac->nh_list = list_new();
zrmac->nh_list->cmp = (int (*)(void *, void *))l3vni_rmac_nh_list_cmp;
zrmac->nh_list->del = (void (*)(void *))l3vni_rmac_nh_free;
static int zl3vni_rmac_del(struct zebra_l3vni *zl3vni, struct zebra_mac *zrmac)
{
struct zebra_mac *tmp_rmac;
- struct host_rb_entry *hle;
- while (!RB_EMPTY(host_rb_tree_entry, &zrmac->host_rb)) {
- hle = RB_ROOT(host_rb_tree_entry, &zrmac->host_rb);
-
- RB_REMOVE(host_rb_tree_entry, &zrmac->host_rb, hle);
- XFREE(MTYPE_HOST_PREFIX, hle);
- }
/* free the list of nh list*/
list_delete(&zrmac->nh_list);
/* handle rmac add */
static int zl3vni_remote_rmac_add(struct zebra_l3vni *zl3vni,
const struct ethaddr *rmac,
- const struct ipaddr *vtep_ip,
- const struct prefix *host_prefix)
+ const struct ipaddr *vtep_ip)
{
struct zebra_mac *zrmac = NULL;
struct ipaddr *vtep = NULL;
zrmac = zl3vni_rmac_add(zl3vni, rmac);
if (!zrmac) {
zlog_debug(
- "Failed to add RMAC %pEA L3VNI %u Remote VTEP %pIA, prefix %pFX",
- rmac, zl3vni->vni, vtep_ip, host_prefix);
+ "Failed to add RMAC %pEA L3VNI %u Remote VTEP %pIA",
+ rmac, zl3vni->vni, vtep_ip);
return -1;
}
memset(&zrmac->fwd_info, 0, sizeof(zrmac->fwd_info));
&vtep_ip->ipaddr_v4)) {
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
- "L3VNI %u Remote VTEP change(%pI4 -> %pIA) for RMAC %pEA, prefix %pFX",
+ "L3VNI %u Remote VTEP change(%pI4 -> %pIA) for RMAC %pEA",
zl3vni->vni, &zrmac->fwd_info.r_vtep_ip,
- vtep_ip, rmac, host_prefix);
+ vtep_ip, rmac);
zrmac->fwd_info.r_vtep_ip = vtep_ip->ipaddr_v4;
/* handle rmac delete */
static void zl3vni_remote_rmac_del(struct zebra_l3vni *zl3vni,
struct zebra_mac *zrmac,
- struct ipaddr *vtep_ip,
- struct prefix *host_prefix)
+ struct ipaddr *vtep_ip)
{
struct ipaddr ipv4_vtep;
zrmac->fwd_info.r_vtep_ip = vtep->ipaddr_v4;
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
- "L3VNI %u Remote VTEP nh change(%pIA -> %pI4) for RMAC %pEA, prefix %pFX",
+ "L3VNI %u Remote VTEP nh change(%pIA -> %pI4) for RMAC %pEA",
zl3vni->vni, &ipv4_vtep,
&zrmac->fwd_info.r_vtep_ip,
- &zrmac->macaddr, host_prefix);
+ &zrmac->macaddr);
/* install rmac in kernel */
zl3vni_rmac_install(zl3vni, zrmac);
* add the rmac - remote rmac to be installed is against the ipv4
* nexthop address
*/
- zl3vni_remote_rmac_add(zl3vni, rmac, &ipv4_vtep, host_prefix);
+ zl3vni_remote_rmac_add(zl3vni, rmac, &ipv4_vtep);
}
/* handle evpn vrf route delete */
/* delete the rmac entry */
if (zrmac)
- zl3vni_remote_rmac_del(zl3vni, zrmac, vtep_ip, host_prefix);
+ zl3vni_remote_rmac_del(zl3vni, zrmac, vtep_ip);
}
void zebra_vxlan_print_specific_rmac_l3vni(struct vty *vty, vni_t l3vni,