summaryrefslogtreecommitdiffstats
path: root/zebra/zebra_vxlan.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2018-05-17 14:10:41 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2018-05-17 14:10:41 +0200
commit41db76c235a5d2dda39fad66b57a28800fa53783 (patch)
tree9b504883efc4a0352aa771c6bee0388b246960f5 /zebra/zebra_vxlan.c
parentzebra: Convert zrmac->host_list list to a RB Tree (diff)
downloadfrr-41db76c235a5d2dda39fad66b57a28800fa53783.tar.xz
frr-41db76c235a5d2dda39fad66b57a28800fa53783.zip
zebra: Rename some functions to allow reuse
We are going to modify more host_list's to host_rb's so let's rename some functions to take advantage of what is there. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to '')
-rw-r--r--zebra/zebra_vxlan.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c
index 7cdb79035..30811e425 100644
--- a/zebra/zebra_vxlan.c
+++ b/zebra/zebra_vxlan.c
@@ -214,12 +214,12 @@ static int host_rb_entry_compare(const struct host_rb_entry *hle1,
RB_GENERATE(host_rb_entry_rb, host_rb_entry, hl_entry,
host_rb_entry_compare);
-static uint32_t zrmac_host_count(zebra_mac_t *zrmac)
+static uint32_t rb_host_count(struct host_rb_entry_rb *hrbe)
{
struct host_rb_entry *hle;
uint32_t count = 0;
- RB_FOREACH (hle, host_rb_entry_rb, &zrmac->host_rb)
+ RB_FOREACH (hle, host_rb_entry_rb, hrbe)
count++;
return count;
@@ -520,7 +520,7 @@ static void zl3vni_print_rmac(zebra_mac_t *zrmac, struct vty *vty,
prefix_mac2str(&zrmac->macaddr, buf1, sizeof(buf1)));
vty_out(vty, " Remote VTEP: %s\n",
inet_ntoa(zrmac->fwd_info.r_vtep_ip));
- vty_out(vty, " Refcount: %d\n", zrmac_host_count(zrmac));
+ vty_out(vty, " Refcount: %d\n", rb_host_count(&zrmac->host_rb));
vty_out(vty, " Prefixes:\n");
RB_FOREACH (hle, host_rb_entry_rb, &zrmac->host_rb)
vty_out(vty, " %s\n",
@@ -532,7 +532,8 @@ static void zl3vni_print_rmac(zebra_mac_t *zrmac, struct vty *vty,
prefix_mac2str(&zrmac->macaddr, buf1, sizeof(buf1)));
json_object_string_add(json, "vtepIp",
inet_ntoa(zrmac->fwd_info.r_vtep_ip));
- json_object_int_add(json, "refCount", zrmac_host_count(zrmac));
+ json_object_int_add(json, "refCount",
+ rb_host_count(&zrmac->host_rb));
RB_FOREACH (hle, host_rb_entry_rb, &zrmac->host_rb)
json_object_array_add(
json_hosts,
@@ -3082,7 +3083,8 @@ static void zl3vni_cleanup_all(struct hash_backet *backet, void *args)
zebra_vxlan_process_l3vni_oper_down(zl3vni);
}
-static void zrmac_find_or_add_host(zebra_mac_t *zrmac, struct prefix *host)
+static void rb_find_or_add_host(struct host_rb_entry_rb *hrbe,
+ struct prefix *host)
{
struct host_rb_entry lookup;
struct host_rb_entry *hle;
@@ -3090,17 +3092,17 @@ static void zrmac_find_or_add_host(zebra_mac_t *zrmac, struct prefix *host)
memset(&lookup, 0, sizeof(lookup));
memcpy(&lookup.p, host, sizeof(*host));
- hle = RB_FIND(host_rb_entry_rb, &zrmac->host_rb, &lookup);
+ hle = RB_FIND(host_rb_entry_rb, hrbe, &lookup);
if (hle)
return;
hle = XCALLOC(MTYPE_HOST_PREFIX, sizeof(struct host_rb_entry));
memcpy(hle, &lookup, sizeof(lookup));
- RB_INSERT(host_rb_entry_rb, &zrmac->host_rb, hle);
+ RB_INSERT(host_rb_entry_rb, hrbe, hle);
}
-static void zrmac_delete_host(zebra_mac_t *zrmac, struct prefix *host)
+static void rb_delete_host(struct host_rb_entry_rb *hrbe, struct prefix *host)
{
struct host_rb_entry lookup;
struct host_rb_entry *hle;
@@ -3108,9 +3110,9 @@ static void zrmac_delete_host(zebra_mac_t *zrmac, struct prefix *host)
memset(&lookup, 0, sizeof(lookup));
memcpy(&lookup.p, host, sizeof(*host));
- hle = RB_FIND(host_rb_entry_rb, &zrmac->host_rb, &lookup);
+ hle = RB_FIND(host_rb_entry_rb, hrbe, &lookup);
if (hle)
- RB_REMOVE(host_rb_entry_rb, &zrmac->host_rb, hle);
+ RB_REMOVE(host_rb_entry_rb, hrbe, hle);
return;
}
@@ -3307,7 +3309,7 @@ static int zl3vni_remote_rmac_add(zebra_l3vni_t *zl3vni, struct ethaddr *rmac,
zl3vni_rmac_install(zl3vni, zrmac);
}
- zrmac_find_or_add_host(zrmac, host_prefix);
+ rb_find_or_add_host(&zrmac->host_rb, host_prefix);
return 0;
}
@@ -3317,7 +3319,7 @@ static int zl3vni_remote_rmac_add(zebra_l3vni_t *zl3vni, struct ethaddr *rmac,
static void zl3vni_remote_rmac_del(zebra_l3vni_t *zl3vni, zebra_mac_t *zrmac,
struct prefix *host_prefix)
{
- zrmac_delete_host(zrmac, host_prefix);
+ rb_delete_host(&zrmac->host_rb, host_prefix);
if (RB_EMPTY(host_rb_entry_rb, &zrmac->host_rb)) {
/* uninstall from kernel */