zebra: Cleanup some nits from Review Comments

1) Small formating mistake fixed
2) Rename of a variable to give it a slightly better name

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2018-05-21 07:18:18 -04:00
parent abceee4119
commit 85442b0959
2 changed files with 28 additions and 29 deletions

View File

@ -183,7 +183,7 @@ static void zvni_deref_ip2mac(zebra_vni_t *zvni, zebra_mac_t *mac,
/* Private functions */ /* Private functions */
static int host_rb_entry_compare(const struct host_rb_entry *hle1, static int host_rb_entry_compare(const struct host_rb_entry *hle1,
const struct host_rb_entry *hle2) const struct host_rb_entry *hle2)
{ {
if (hle1->p.family < hle2->p.family) if (hle1->p.family < hle2->p.family)
return -1; return -1;
@ -211,15 +211,14 @@ static int host_rb_entry_compare(const struct host_rb_entry *hle1,
return 0; return 0;
} }
} }
RB_GENERATE(host_rb_entry_rb, host_rb_entry, hl_entry, RB_GENERATE(host_rb_tree_entry, host_rb_entry, hl_entry, host_rb_entry_compare);
host_rb_entry_compare);
static uint32_t rb_host_count(struct host_rb_entry_rb *hrbe) static uint32_t rb_host_count(struct host_rb_tree_entry *hrbe)
{ {
struct host_rb_entry *hle; struct host_rb_entry *hle;
uint32_t count = 0; uint32_t count = 0;
RB_FOREACH (hle, host_rb_entry_rb, hrbe) RB_FOREACH (hle, host_rb_tree_entry, hrbe)
count++; count++;
return count; return count;
@ -487,7 +486,7 @@ static void zl3vni_print_nh(zebra_neigh_t *n, struct vty *vty,
vty_out(vty, " Refcount: %d\n", vty_out(vty, " Refcount: %d\n",
rb_host_count(&n->host_rb)); rb_host_count(&n->host_rb));
vty_out(vty, " Prefixes:\n"); vty_out(vty, " Prefixes:\n");
RB_FOREACH (hle, host_rb_entry_rb, &n->host_rb) RB_FOREACH (hle, host_rb_tree_entry, &n->host_rb)
vty_out(vty, " %s\n", vty_out(vty, " %s\n",
prefix2str(&hle->p, buf2, sizeof(buf2))); prefix2str(&hle->p, buf2, sizeof(buf2)));
} else { } else {
@ -499,7 +498,7 @@ static void zl3vni_print_nh(zebra_neigh_t *n, struct vty *vty,
prefix_mac2str(&n->emac, buf2, sizeof(buf2))); prefix_mac2str(&n->emac, buf2, sizeof(buf2)));
json_object_int_add(json, "refCount", json_object_int_add(json, "refCount",
rb_host_count(&n->host_rb)); rb_host_count(&n->host_rb));
RB_FOREACH (hle, host_rb_entry_rb, &n->host_rb) RB_FOREACH (hle, host_rb_tree_entry, &n->host_rb)
json_object_array_add(json_hosts, json_object_array_add(json_hosts,
json_object_new_string(prefix2str( json_object_new_string(prefix2str(
&hle->p, buf2, sizeof(buf2)))); &hle->p, buf2, sizeof(buf2))));
@ -523,7 +522,7 @@ static void zl3vni_print_rmac(zebra_mac_t *zrmac, struct vty *vty,
inet_ntoa(zrmac->fwd_info.r_vtep_ip)); inet_ntoa(zrmac->fwd_info.r_vtep_ip));
vty_out(vty, " Refcount: %d\n", rb_host_count(&zrmac->host_rb)); vty_out(vty, " Refcount: %d\n", rb_host_count(&zrmac->host_rb));
vty_out(vty, " Prefixes:\n"); vty_out(vty, " Prefixes:\n");
RB_FOREACH (hle, host_rb_entry_rb, &zrmac->host_rb) RB_FOREACH (hle, host_rb_tree_entry, &zrmac->host_rb)
vty_out(vty, " %s\n", vty_out(vty, " %s\n",
prefix2str(&hle->p, buf2, sizeof(buf2))); prefix2str(&hle->p, buf2, sizeof(buf2)));
} else { } else {
@ -535,7 +534,7 @@ static void zl3vni_print_rmac(zebra_mac_t *zrmac, struct vty *vty,
inet_ntoa(zrmac->fwd_info.r_vtep_ip)); inet_ntoa(zrmac->fwd_info.r_vtep_ip));
json_object_int_add(json, "refCount", json_object_int_add(json, "refCount",
rb_host_count(&zrmac->host_rb)); rb_host_count(&zrmac->host_rb));
RB_FOREACH (hle, host_rb_entry_rb, &zrmac->host_rb) RB_FOREACH (hle, host_rb_tree_entry, &zrmac->host_rb)
json_object_array_add( json_object_array_add(
json_hosts, json_hosts,
json_object_new_string(prefix2str( json_object_new_string(prefix2str(
@ -3084,7 +3083,7 @@ static void zl3vni_cleanup_all(struct hash_backet *backet, void *args)
zebra_vxlan_process_l3vni_oper_down(zl3vni); zebra_vxlan_process_l3vni_oper_down(zl3vni);
} }
static void rb_find_or_add_host(struct host_rb_entry_rb *hrbe, static void rb_find_or_add_host(struct host_rb_tree_entry *hrbe,
struct prefix *host) struct prefix *host)
{ {
struct host_rb_entry lookup; struct host_rb_entry lookup;
@ -3093,17 +3092,17 @@ static void rb_find_or_add_host(struct host_rb_entry_rb *hrbe,
memset(&lookup, 0, sizeof(lookup)); memset(&lookup, 0, sizeof(lookup));
memcpy(&lookup.p, host, sizeof(*host)); memcpy(&lookup.p, host, sizeof(*host));
hle = RB_FIND(host_rb_entry_rb, hrbe, &lookup); hle = RB_FIND(host_rb_tree_entry, hrbe, &lookup);
if (hle) if (hle)
return; return;
hle = XCALLOC(MTYPE_HOST_PREFIX, sizeof(struct host_rb_entry)); hle = XCALLOC(MTYPE_HOST_PREFIX, sizeof(struct host_rb_entry));
memcpy(hle, &lookup, sizeof(lookup)); memcpy(hle, &lookup, sizeof(lookup));
RB_INSERT(host_rb_entry_rb, hrbe, hle); RB_INSERT(host_rb_tree_entry, hrbe, hle);
} }
static void rb_delete_host(struct host_rb_entry_rb *hrbe, struct prefix *host) static void rb_delete_host(struct host_rb_tree_entry *hrbe, struct prefix *host)
{ {
struct host_rb_entry lookup; struct host_rb_entry lookup;
struct host_rb_entry *hle; struct host_rb_entry *hle;
@ -3111,9 +3110,9 @@ static void rb_delete_host(struct host_rb_entry_rb *hrbe, struct prefix *host)
memset(&lookup, 0, sizeof(lookup)); memset(&lookup, 0, sizeof(lookup));
memcpy(&lookup.p, host, sizeof(*host)); memcpy(&lookup.p, host, sizeof(*host));
hle = RB_FIND(host_rb_entry_rb, hrbe, &lookup); hle = RB_FIND(host_rb_tree_entry, hrbe, &lookup);
if (hle) if (hle)
RB_REMOVE(host_rb_entry_rb, hrbe, hle); RB_REMOVE(host_rb_tree_entry, hrbe, hle);
return; return;
} }
@ -3161,7 +3160,7 @@ static zebra_mac_t *zl3vni_rmac_add(zebra_l3vni_t *zl3vni, struct ethaddr *rmac)
zrmac = hash_get(zl3vni->rmac_table, &tmp_rmac, zl3vni_rmac_alloc); zrmac = hash_get(zl3vni->rmac_table, &tmp_rmac, zl3vni_rmac_alloc);
assert(zrmac); assert(zrmac);
RB_INIT(host_rb_entry_rb, &zrmac->host_rb); RB_INIT(host_rb_tree_entry, &zrmac->host_rb);
SET_FLAG(zrmac->flags, ZEBRA_MAC_REMOTE); SET_FLAG(zrmac->flags, ZEBRA_MAC_REMOTE);
SET_FLAG(zrmac->flags, ZEBRA_MAC_REMOTE_RMAC); SET_FLAG(zrmac->flags, ZEBRA_MAC_REMOTE_RMAC);
@ -3177,10 +3176,10 @@ static int zl3vni_rmac_del(zebra_l3vni_t *zl3vni, zebra_mac_t *zrmac)
zebra_mac_t *tmp_rmac; zebra_mac_t *tmp_rmac;
struct host_rb_entry *hle; struct host_rb_entry *hle;
while (!RB_EMPTY(host_rb_entry_rb, &zrmac->host_rb)) { while (!RB_EMPTY(host_rb_tree_entry, &zrmac->host_rb)) {
hle = RB_ROOT(host_rb_entry_rb, &zrmac->host_rb); hle = RB_ROOT(host_rb_tree_entry, &zrmac->host_rb);
RB_REMOVE(host_rb_entry_rb, &zrmac->host_rb, hle); RB_REMOVE(host_rb_tree_entry, &zrmac->host_rb, hle);
XFREE(MTYPE_HOST_PREFIX, hle); XFREE(MTYPE_HOST_PREFIX, hle);
} }
@ -3284,7 +3283,7 @@ static void zl3vni_remote_rmac_del(zebra_l3vni_t *zl3vni, zebra_mac_t *zrmac,
{ {
rb_delete_host(&zrmac->host_rb, host_prefix); rb_delete_host(&zrmac->host_rb, host_prefix);
if (RB_EMPTY(host_rb_entry_rb, &zrmac->host_rb)) { if (RB_EMPTY(host_rb_tree_entry, &zrmac->host_rb)) {
/* uninstall from kernel */ /* uninstall from kernel */
zl3vni_rmac_uninstall(zl3vni, zrmac); zl3vni_rmac_uninstall(zl3vni, zrmac);
@ -3337,7 +3336,7 @@ static zebra_neigh_t *zl3vni_nh_add(zebra_l3vni_t *zl3vni, struct ipaddr *ip,
n = hash_get(zl3vni->nh_table, &tmp_n, zl3vni_nh_alloc); n = hash_get(zl3vni->nh_table, &tmp_n, zl3vni_nh_alloc);
assert(n); assert(n);
RB_INIT(host_rb_entry_rb, &n->host_rb); RB_INIT(host_rb_tree_entry, &n->host_rb);
memcpy(&n->emac, mac, ETH_ALEN); memcpy(&n->emac, mac, ETH_ALEN);
SET_FLAG(n->flags, ZEBRA_NEIGH_REMOTE); SET_FLAG(n->flags, ZEBRA_NEIGH_REMOTE);
@ -3354,10 +3353,10 @@ static int zl3vni_nh_del(zebra_l3vni_t *zl3vni, zebra_neigh_t *n)
zebra_neigh_t *tmp_n; zebra_neigh_t *tmp_n;
struct host_rb_entry *hle; struct host_rb_entry *hle;
while (!RB_EMPTY(host_rb_entry_rb, &n->host_rb)) { while (!RB_EMPTY(host_rb_tree_entry, &n->host_rb)) {
hle = RB_ROOT(host_rb_entry_rb, &n->host_rb); hle = RB_ROOT(host_rb_tree_entry, &n->host_rb);
RB_REMOVE(host_rb_entry_rb, &n->host_rb, hle); RB_REMOVE(host_rb_tree_entry, &n->host_rb, hle);
XFREE(MTYPE_HOST_PREFIX, hle); XFREE(MTYPE_HOST_PREFIX, hle);
} }
@ -3435,7 +3434,7 @@ static void zl3vni_remote_nh_del(zebra_l3vni_t *zl3vni, zebra_neigh_t *nh,
{ {
rb_delete_host(&nh->host_rb, host_prefix); rb_delete_host(&nh->host_rb, host_prefix);
if (RB_EMPTY(host_rb_entry_rb, &nh->host_rb)) { if (RB_EMPTY(host_rb_tree_entry, &nh->host_rb)) {
/* uninstall from kernel */ /* uninstall from kernel */
zl3vni_nh_uninstall(zl3vni, nh); zl3vni_nh_uninstall(zl3vni, nh);

View File

@ -221,8 +221,8 @@ struct host_rb_entry {
struct prefix p; struct prefix p;
}; };
RB_HEAD(host_rb_entry_rb, host_rb_entry); RB_HEAD(host_rb_tree_entry, host_rb_entry);
RB_PROTOTYPE(host_rb_entry_rb, host_rb_entry, hl_entry, RB_PROTOTYPE(host_rb_tree_entry, host_rb_entry, hl_entry,
host_rb_entry_compare); host_rb_entry_compare);
/* /*
* MAC hash table. * MAC hash table.
@ -262,7 +262,7 @@ struct zebra_mac_t_ {
struct list *neigh_list; struct list *neigh_list;
/* list of hosts pointing to this remote RMAC */ /* list of hosts pointing to this remote RMAC */
struct host_rb_entry_rb host_rb; struct host_rb_tree_entry host_rb;
}; };
/* /*
@ -336,7 +336,7 @@ struct zebra_neigh_t_ {
struct in_addr r_vtep_ip; struct in_addr r_vtep_ip;
/* list of hosts pointing to this remote NH entry */ /* list of hosts pointing to this remote NH entry */
struct host_rb_entry_rb host_rb; struct host_rb_tree_entry host_rb;
}; };
/* /*