summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChirag Shah <chirag@nvidia.com>2021-10-18 11:43:29 -0700
committerChirag Shah <chirag@nvidia.com>2022-03-10 17:27:15 -0800
commit3d43b95ce1a556e5fec35aa0e8f5e070bf3da2c2 (patch)
tree1d66a7c54b992900e36d9fcca38e769313b2a237
parent4a8e182a66faec2daaee134e70bde97085716b35 (diff)
zebra: cleanup host prefix from rmac
Ticket:#2798406 Testing Done: Signed-off-by: Chirag Shah <chirag@nvidia.com>
-rw-r--r--zebra/zebra_evpn_mac.h3
-rw-r--r--zebra/zebra_vxlan.c61
2 files changed, 15 insertions, 49 deletions
diff --git a/zebra/zebra_evpn_mac.h b/zebra/zebra_evpn_mac.h
index f327dc1625..a506bc0ee7 100644
--- a/zebra/zebra_evpn_mac.h
+++ b/zebra/zebra_evpn_mac.h
@@ -124,9 +124,6 @@ struct zebra_mac {
/* List of neigh associated with this mac */
struct list *neigh_list;
- /* list of hosts pointing to this remote RMAC */
- struct host_rb_tree_entry host_rb;
-
/* List of nexthop associated with this RMAC */
struct list *nh_list;
diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c
index 1d0c3850f6..9ee10a16bc 100644
--- a/zebra/zebra_vxlan.c
+++ b/zebra/zebra_vxlan.c
@@ -398,46 +398,25 @@ static void zl3vni_print_nh(struct zebra_neigh *n, struct vty *vty,
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);
}
}
@@ -1216,7 +1195,6 @@ static struct zebra_mac *zl3vni_rmac_add(struct zebra_l3vni *zl3vni,
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;
@@ -1233,14 +1211,7 @@ static struct zebra_mac *zl3vni_rmac_add(struct zebra_l3vni *zl3vni,
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);
@@ -1343,8 +1314,7 @@ static int zl3vni_rmac_uninstall(struct zebra_l3vni *zl3vni,
/* 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;
@@ -1356,8 +1326,8 @@ static int zl3vni_remote_rmac_add(struct zebra_l3vni *zl3vni,
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));
@@ -1378,9 +1348,9 @@ static int zl3vni_remote_rmac_add(struct zebra_l3vni *zl3vni,
&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;
@@ -1400,8 +1370,7 @@ static int zl3vni_remote_rmac_add(struct zebra_l3vni *zl3vni,
/* 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;
@@ -1429,10 +1398,10 @@ static void zl3vni_remote_rmac_del(struct zebra_l3vni *zl3vni,
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);
@@ -2343,7 +2312,7 @@ void zebra_vxlan_evpn_vrf_route_add(vrf_id_t vrf_id, const struct ethaddr *rmac,
* 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 */
@@ -2370,7 +2339,7 @@ void zebra_vxlan_evpn_vrf_route_del(vrf_id_t vrf_id,
/* 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,