Merge pull request #2846 from donaldsharp/backet_data

Backet data
This commit is contained in:
Russ White 2018-08-16 11:32:41 -04:00 committed by GitHub
commit 4b0d7894cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 22 additions and 94 deletions

View File

@ -3540,14 +3540,7 @@ static int delete_withdraw_vni_routes(struct bgp *bgp, struct bgpevpn *vpn)
*/ */
static void update_router_id_vni(struct hash_backet *backet, struct bgp *bgp) static void update_router_id_vni(struct hash_backet *backet, struct bgp *bgp)
{ {
struct bgpevpn *vpn; struct bgpevpn *vpn = (struct bgpevpn *)backet->data;
vpn = (struct bgpevpn *)backet->data;
if (!vpn) {
zlog_warn("%s: VNI hash entry for VNI not found", __FUNCTION__);
return;
}
/* Skip VNIs with configured RD. */ /* Skip VNIs with configured RD. */
if (is_rd_configured(vpn)) if (is_rd_configured(vpn))
@ -3565,14 +3558,7 @@ static void update_router_id_vni(struct hash_backet *backet, struct bgp *bgp)
*/ */
static void withdraw_router_id_vni(struct hash_backet *backet, struct bgp *bgp) static void withdraw_router_id_vni(struct hash_backet *backet, struct bgp *bgp)
{ {
struct bgpevpn *vpn; struct bgpevpn *vpn = (struct bgpevpn *)backet->data;
vpn = (struct bgpevpn *)backet->data;
if (!vpn) {
zlog_warn("%s: VNI hash entry for VNI not found", __FUNCTION__);
return;
}
/* Skip VNIs with configured RD. */ /* Skip VNIs with configured RD. */
if (is_rd_configured(vpn)) if (is_rd_configured(vpn))
@ -4016,9 +4002,8 @@ static void cleanup_vni_on_disable(struct hash_backet *backet, struct bgp *bgp)
*/ */
static void free_vni_entry(struct hash_backet *backet, struct bgp *bgp) static void free_vni_entry(struct hash_backet *backet, struct bgp *bgp)
{ {
struct bgpevpn *vpn; struct bgpevpn *vpn = (struct bgpevpn *)backet->data;
vpn = (struct bgpevpn *)backet->data;
delete_all_vni_routes(bgp, vpn); delete_all_vni_routes(bgp, vpn);
bgp_evpn_free(bgp, vpn); bgp_evpn_free(bgp, vpn);
} }
@ -4090,11 +4075,6 @@ static void update_autort_vni(struct hash_backet *backet, struct bgp *bgp)
{ {
struct bgpevpn *vpn = backet->data; struct bgpevpn *vpn = backet->data;
if (!vpn) {
zlog_warn("%s: VNI hash entry for VNI not found", __PRETTY_FUNCTION__);
return;
}
if (!is_import_rt_configured(vpn)) { if (!is_import_rt_configured(vpn)) {
if (is_vni_live(vpn)) if (is_vni_live(vpn))
bgp_evpn_uninstall_routes(bgp, vpn); bgp_evpn_uninstall_routes(bgp, vpn);
@ -5251,13 +5231,12 @@ int bgp_evpn_local_macip_add(struct bgp *bgp, vni_t vni, struct ethaddr *mac,
static void link_l2vni_hash_to_l3vni(struct hash_backet *backet, static void link_l2vni_hash_to_l3vni(struct hash_backet *backet,
struct bgp *bgp_vrf) struct bgp *bgp_vrf)
{ {
struct bgpevpn *vpn = NULL; struct bgpevpn *vpn = (struct bgpevpn *)backet->data;
struct bgp *bgp_def = NULL; struct bgp *bgp_def = NULL;
bgp_def = bgp_get_default(); bgp_def = bgp_get_default();
assert(bgp_def); assert(bgp_def);
vpn = (struct bgpevpn *)backet->data;
if (vpn->tenant_vrf_id == bgp_vrf->vrf_id) if (vpn->tenant_vrf_id == bgp_vrf->vrf_id)
bgpevpn_link_to_l3vni(vpn); bgpevpn_link_to_l3vni(vpn);
} }

View File

@ -167,7 +167,9 @@ hash_create_size(unsigned int size, unsigned int (*hash_key)(void *),
* hash table to operate on * hash table to operate on
* *
* data * data
* data to insert or retrieve * data to insert or retrieve - A hash backet will not be created if
* the alloc_func returns a NULL pointer and nothing will be added to
* the hash. As such backet->data will always be non-NULL.
* *
* alloc_func * alloc_func
* function to call if the item is not found in the hash table. This * function to call if the item is not found in the hash table. This
@ -236,6 +238,8 @@ extern void *hash_release(struct hash *hash, void *data);
* during the walk will cause undefined behavior in that some new entries * during the walk will cause undefined behavior in that some new entries
* will be walked and some will not. So do not do this. * will be walked and some will not. So do not do this.
* *
* The backet passed to func will have a non-NULL data pointer.
*
* hash * hash
* hash table to operate on * hash table to operate on
* *
@ -256,6 +260,8 @@ extern void hash_iterate(struct hash *hash,
* during the walk will cause undefined behavior in that some new entries * during the walk will cause undefined behavior in that some new entries
* will be walked and some will not. So do not do this. * will be walked and some will not. So do not do this.
* *
* The backet passed to func will have a non-NULL data pointer.
*
* hash * hash
* hash table to operate on * hash table to operate on
* *

View File

@ -1545,7 +1545,7 @@ static void route_map_clear_reference(struct hash_backet *backet, void *arg)
struct route_map_dep *dep = (struct route_map_dep *)backet->data; struct route_map_dep *dep = (struct route_map_dep *)backet->data;
char *rmap_name; char *rmap_name;
if (dep && arg) { if (arg) {
rmap_name = rmap_name =
(char *)hash_release(dep->dep_rmap_hash, (void *)arg); (char *)hash_release(dep->dep_rmap_hash, (void *)arg);
if (rmap_name) { if (rmap_name) {
@ -1601,7 +1601,6 @@ static void route_map_print_dependency(struct hash_backet *backet, void *data)
char *rmap_name = (char *)backet->data; char *rmap_name = (char *)backet->data;
char *dep_name = (char *)data; char *dep_name = (char *)data;
if (rmap_name)
zlog_debug("%s: Dependency for %s: %s", __FUNCTION__, dep_name, zlog_debug("%s: Dependency for %s: %s", __FUNCTION__, dep_name,
rmap_name); rmap_name);
} }
@ -1725,18 +1724,14 @@ static struct hash *route_map_get_dep_hash(route_map_event_t event)
static void route_map_process_dependency(struct hash_backet *backet, void *data) static void route_map_process_dependency(struct hash_backet *backet, void *data)
{ {
char *rmap_name; char *rmap_name = (char *)backet->data;
route_map_event_t type = (route_map_event_t)(ptrdiff_t)data; route_map_event_t type = (route_map_event_t)(ptrdiff_t)data;
rmap_name = (char *)backet->data;
if (rmap_name) {
if (rmap_debug) if (rmap_debug)
zlog_debug("%s: Notifying %s of dependency", zlog_debug("%s: Notifying %s of dependency",
__FUNCTION__, rmap_name); __FUNCTION__, rmap_name);
if (route_map_master.event_hook) if (route_map_master.event_hook)
(*route_map_master.event_hook)(type, rmap_name); (*route_map_master.event_hook)(type, rmap_name);
}
} }
void route_map_upd8_dependency(route_map_event_t type, const char *arg, void route_map_upd8_dependency(route_map_event_t type, const char *arg,

View File

@ -1538,10 +1538,6 @@ static void ospf_sr_nhlfe_update(struct hash_backet *backet, void *args)
struct sr_nhlfe old; struct sr_nhlfe old;
int rc; int rc;
/* Sanity Check */
if (srn == NULL)
return;
if (IS_DEBUG_OSPF_SR) if (IS_DEBUG_OSPF_SR)
zlog_debug(" |- Update Prefix for SR Node %s", zlog_debug(" |- Update Prefix for SR Node %s",
inet_ntoa(srn->adv_router)); inet_ntoa(srn->adv_router));

View File

@ -2795,9 +2795,6 @@ static int pim_print_pnc_cache_walkcb(struct hash_backet *backet, void *arg)
ifindex_t first_ifindex; ifindex_t first_ifindex;
struct interface *ifp = NULL; struct interface *ifp = NULL;
if (!pnc)
return CMD_SUCCESS;
for (nh_node = pnc->nexthop; nh_node; nh_node = nh_node->next) { for (nh_node = pnc->nexthop; nh_node; nh_node = nh_node->next) {
first_ifindex = nh_node->ifindex; first_ifindex = nh_node->ifindex;
ifp = if_lookup_by_index(first_ifindex, pim->vrf_id); ifp = if_lookup_by_index(first_ifindex, pim->vrf_id);

View File

@ -2446,7 +2446,7 @@ void mpls_ldp_lsp_uninstall_all(struct hash_backet *backet, void *ctxt)
struct hash *lsp_table; struct hash *lsp_table;
lsp = (zebra_lsp_t *)backet->data; lsp = (zebra_lsp_t *)backet->data;
if (!lsp || !lsp->nhlfe_list) if (!lsp->nhlfe_list)
return; return;
lsp_table = ctxt; lsp_table = ctxt;

View File

@ -281,8 +281,6 @@ static void zvni_find_neigh_addr_width(struct hash_backet *backet, void *ctxt)
int width; int width;
n = (zebra_neigh_t *)backet->data; n = (zebra_neigh_t *)backet->data;
if (!n)
return;
ipaddr2str(&n->ip, buf, sizeof(buf)), width = strlen(buf); ipaddr2str(&n->ip, buf, sizeof(buf)), width = strlen(buf);
if (width > wctx->addr_width) if (width > wctx->addr_width)
@ -356,8 +354,6 @@ static void zvni_print_neigh_hash(struct hash_backet *backet, void *ctxt)
vty = wctx->vty; vty = wctx->vty;
json_vni = wctx->json; json_vni = wctx->json;
n = (zebra_neigh_t *)backet->data; n = (zebra_neigh_t *)backet->data;
if (!n)
return;
if (json_vni) if (json_vni)
json_row = json_object_new_object(); json_row = json_object_new_object();
@ -436,11 +432,7 @@ static void zvni_print_neigh_hash_all_vni(struct hash_backet *backet,
json = (json_object *)args[1]; json = (json_object *)args[1];
zvni = (zebra_vni_t *)backet->data; zvni = (zebra_vni_t *)backet->data;
if (!zvni) {
if (json)
vty_out(vty, "{}\n");
return;
}
num_neigh = hashcount(zvni->neigh_table); num_neigh = hashcount(zvni->neigh_table);
if (json == NULL) { if (json == NULL) {
vty_out(vty, vty_out(vty,
@ -629,8 +621,6 @@ static void zvni_print_mac_hash(struct hash_backet *backet, void *ctxt)
vty = wctx->vty; vty = wctx->vty;
json_mac_hdr = wctx->json; json_mac_hdr = wctx->json;
mac = (zebra_mac_t *)backet->data; mac = (zebra_mac_t *)backet->data;
if (!mac)
return;
prefix_mac2str(&mac->macaddr, buf1, sizeof(buf1)); prefix_mac2str(&mac->macaddr, buf1, sizeof(buf1));
@ -736,11 +726,6 @@ static void zvni_print_mac_hash_all_vni(struct hash_backet *backet, void *ctxt)
json = (struct json_object *)wctx->json; json = (struct json_object *)wctx->json;
zvni = (zebra_vni_t *)backet->data; zvni = (zebra_vni_t *)backet->data;
if (!zvni) {
if (json)
vty_out(vty, "{}\n");
return;
}
wctx->zvni = zvni; wctx->zvni = zvni;
/*We are iterating over a new VNI, set the count to 0*/ /*We are iterating over a new VNI, set the count to 0*/
@ -795,8 +780,6 @@ static void zl3vni_print_nh_hash(struct hash_backet *backet, void *ctx)
if (json_vni) if (json_vni)
json_nh = json_object_new_object(); json_nh = json_object_new_object();
n = (zebra_neigh_t *)backet->data; n = (zebra_neigh_t *)backet->data;
if (!n)
return;
if (!json_vni) { if (!json_vni) {
vty_out(vty, "%-15s %-17s\n", vty_out(vty, "%-15s %-17s\n",
@ -829,11 +812,6 @@ static void zl3vni_print_nh_hash_all_vni(struct hash_backet *backet,
json = (struct json_object *)args[1]; json = (struct json_object *)args[1];
zl3vni = (zebra_l3vni_t *)backet->data; zl3vni = (zebra_l3vni_t *)backet->data;
if (!zl3vni) {
if (json)
vty_out(vty, "{}\n");
return;
}
num_nh = hashcount(zl3vni->nh_table); num_nh = hashcount(zl3vni->nh_table);
if (!num_nh) if (!num_nh)
@ -873,11 +851,6 @@ static void zl3vni_print_rmac_hash_all_vni(struct hash_backet *backet,
json = (struct json_object *)args[1]; json = (struct json_object *)args[1];
zl3vni = (zebra_l3vni_t *)backet->data; zl3vni = (zebra_l3vni_t *)backet->data;
if (!zl3vni) {
if (json)
vty_out(vty, "{}\n");
return;
}
num_rmacs = hashcount(zl3vni->rmac_table); num_rmacs = hashcount(zl3vni->rmac_table);
if (!num_rmacs) if (!num_rmacs)
@ -921,8 +894,6 @@ static void zl3vni_print_rmac_hash(struct hash_backet *backet, void *ctx)
if (json) if (json)
json_rmac = json_object_new_object(); json_rmac = json_object_new_object();
zrmac = (zebra_mac_t *)backet->data; zrmac = (zebra_mac_t *)backet->data;
if (!zrmac)
return;
if (!json) { if (!json) {
vty_out(vty, "%-17s %-21s\n", vty_out(vty, "%-17s %-21s\n",
@ -1099,8 +1070,6 @@ static void zl3vni_print_hash(struct hash_backet *backet, void *ctx[])
json = (json_object *)ctx[1]; json = (json_object *)ctx[1];
zl3vni = (zebra_l3vni_t *)backet->data; zl3vni = (zebra_l3vni_t *)backet->data;
if (!zl3vni)
return;
if (!json) { if (!json) {
vty_out(vty, "%-10u %-4s %-21s %-8lu %-8lu %-15s %-37s\n", vty_out(vty, "%-10u %-4s %-21s %-8lu %-8lu %-15s %-37s\n",
@ -1148,8 +1117,6 @@ static void zvni_print_hash(struct hash_backet *backet, void *ctxt[])
json = ctxt[1]; json = ctxt[1];
zvni = (zebra_vni_t *)backet->data; zvni = (zebra_vni_t *)backet->data;
if (!zvni)
return;
zvtep = zvni->vteps; zvtep = zvni->vteps;
while (zvtep) { while (zvtep) {
@ -1652,8 +1619,6 @@ static void zvni_install_neigh_hash(struct hash_backet *backet, void *ctxt)
struct neigh_walk_ctx *wctx = ctxt; struct neigh_walk_ctx *wctx = ctxt;
n = (zebra_neigh_t *)backet->data; n = (zebra_neigh_t *)backet->data;
if (!n)
return;
if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_REMOTE)) if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_REMOTE))
zvni_neigh_install(wctx->zvni, n); zvni_neigh_install(wctx->zvni, n);
@ -1920,8 +1885,6 @@ static void zvni_gw_macip_del_for_vni_hash(struct hash_backet *backet,
/* Add primary SVI MAC*/ /* Add primary SVI MAC*/
zvni = (zebra_vni_t *)backet->data; zvni = (zebra_vni_t *)backet->data;
if (!zvni)
return;
ifp = zvni->vxlan_if; ifp = zvni->vxlan_if;
if (!ifp) if (!ifp)
@ -1961,8 +1924,6 @@ static void zvni_gw_macip_add_for_vni_hash(struct hash_backet *backet,
struct interface *ifp = NULL; struct interface *ifp = NULL;
zvni = (zebra_vni_t *)backet->data; zvni = (zebra_vni_t *)backet->data;
if (!zvni)
return;
ifp = zvni->vxlan_if; ifp = zvni->vxlan_if;
if (!ifp) if (!ifp)
@ -2625,8 +2586,6 @@ static void zvni_install_mac_hash(struct hash_backet *backet, void *ctxt)
struct mac_walk_ctx *wctx = ctxt; struct mac_walk_ctx *wctx = ctxt;
mac = (zebra_mac_t *)backet->data; mac = (zebra_mac_t *)backet->data;
if (!mac)
return;
if (CHECK_FLAG(mac->flags, ZEBRA_MAC_REMOTE)) if (CHECK_FLAG(mac->flags, ZEBRA_MAC_REMOTE))
zvni_mac_install(wctx->zvni, mac); zvni_mac_install(wctx->zvni, mac);
@ -3070,8 +3029,6 @@ static void zvni_cleanup_all(struct hash_backet *backet, void *arg)
struct zebra_vrf *zvrf = (struct zebra_vrf *)arg; struct zebra_vrf *zvrf = (struct zebra_vrf *)arg;
zvni = (zebra_vni_t *)backet->data; zvni = (zebra_vni_t *)backet->data;
if (!zvni)
return;
/* remove from l3-vni list */ /* remove from l3-vni list */
if (zvrf->l3vni) if (zvrf->l3vni)
@ -3096,8 +3053,6 @@ static void zl3vni_cleanup_all(struct hash_backet *backet, void *args)
zebra_l3vni_t *zl3vni = NULL; zebra_l3vni_t *zl3vni = NULL;
zl3vni = (zebra_l3vni_t *)backet->data; zl3vni = (zebra_l3vni_t *)backet->data;
if (!zl3vni)
return;
zebra_vxlan_process_l3vni_oper_down(zl3vni); zebra_vxlan_process_l3vni_oper_down(zl3vni);
} }