X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Flisp-cp%2Fgid_dictionary.c;h=c1b4adacf22cb76f554392f8eb681a577ad745d2;hb=d057625d499525625d60d2207665eaeb755e380e;hp=2d8fbc8040443dc6f93bbef7ddacff74f2fee435;hpb=b7b929931a07fbb27b43d5cd105f366c3e29807e;p=vpp.git diff --git a/src/vnet/lisp-cp/gid_dictionary.c b/src/vnet/lisp-cp/gid_dictionary.c index 2d8fbc80404..c1b4adacf22 100644 --- a/src/vnet/lisp-cp/gid_dictionary.c +++ b/src/vnet/lisp-cp/gid_dictionary.c @@ -31,7 +31,7 @@ static u32 ip4_lookup (gid_ip4_table_t * db, u32 vni, ip_prefix_t * key); static u32 ip6_lookup (gid_ip6_table_t * db, u32 vni, ip_prefix_t * key); -static void +static int foreach_sfib4_subprefix (BVT (clib_bihash_kv) * kvp, void *arg) { sfib_entry_arg_t *a = arg; @@ -51,6 +51,7 @@ foreach_sfib4_subprefix (BVT (clib_bihash_kv) * kvp, void *arg) /* found sub-prefix of src prefix */ (a->cb) (kvp->value, a->arg); } + return (BIHASH_WALK_CONTINUE); } static void @@ -77,7 +78,7 @@ gid_dict_foreach_ip4_subprefix (gid_dictionary_t * db, u32 vni, foreach_sfib4_subprefix, &a); } -static void +static int foreach_sfib6_subprefix (BVT (clib_bihash_kv) * kvp, void *arg) { sfib_entry_arg_t *a = arg; @@ -94,6 +95,7 @@ foreach_sfib6_subprefix (BVT (clib_bihash_kv) * kvp, void *arg) /* found sub-prefix of src prefix */ (a->cb) (kvp->value, a->arg); } + return (BIHASH_WALK_CONTINUE); } static void @@ -126,7 +128,7 @@ gid_dict_foreach_subprefix (gid_dictionary_t * db, gid_address_t * eid, { ip_prefix_t *ippref = &gid_address_sd_dst_ippref (eid); - if (IP4 == ip_prefix_version (ippref)) + if (AF_IP4 == ip_prefix_version (ippref)) gid_dict_foreach_ip4_subprefix (db, gid_address_vni (eid), &gid_address_sd_src_ippref (eid), &gid_address_sd_dst_ippref (eid), cb, @@ -139,9 +141,9 @@ gid_dict_foreach_subprefix (gid_dictionary_t * db, gid_address_t * eid, } void -gid_dict_foreach_l2_arp_ndp_entry (gid_dictionary_t * db, void (*cb) - (BVT (clib_bihash_kv) * kvp, void *arg), - void *ht) +gid_dict_foreach_l2_arp_ndp_entry (gid_dictionary_t * db, + BV (clib_bihash_foreach_key_value_pair_cb) + cb, void *ht) { gid_l2_arp_ndp_table_t *tab = &db->arp_ndp_table; BV (clib_bihash_foreach_key_value_pair) (&tab->arp_ndp_lookup_table, cb, @@ -295,7 +297,7 @@ ip_sd_lookup (gid_dictionary_t * db, u32 vni, ip_prefix_t * dst, switch (ip_prefix_version (dst)) { - case IP4: + case AF_IP4: sfi = ip4_lookup (&db->dst_ip4_table, vni, dst); if (GID_LOOKUP_MISS != sfi) sfib4 = pool_elt_at_index (db->src_ip4_table_pool, sfi); @@ -312,7 +314,7 @@ ip_sd_lookup (gid_dictionary_t * db, u32 vni, ip_prefix_t * dst, return ip4_lookup (sfib4, 0, src); break; - case IP6: + case AF_IP6: sfi = ip6_lookup (&db->dst_ip6_table, vni, dst); if (GID_LOOKUP_MISS != sfi) sfib6 = pool_elt_at_index (db->src_ip6_table_pool, sfi); @@ -323,7 +325,7 @@ ip_sd_lookup (gid_dictionary_t * db, u32 vni, ip_prefix_t * dst, { ip_prefix_t sp; clib_memset (&sp, 0, sizeof (sp)); - ip_prefix_version (&sp) = IP6; + ip_prefix_version (&sp) = AF_IP6; return ip6_lookup_exact_match (sfib6, 0, &sp); } else @@ -342,7 +344,7 @@ static void make_arp_ndp_key (BVT (clib_bihash_kv) * kv, u32 bd, ip_address_t * addr) { kv->key[0] = ((u64) bd << 32) | (u32) ip_addr_version (addr); - if (ip_addr_version (addr) == IP4) + if (ip_addr_version (addr) == AF_IP4) { kv->key[1] = (u64) addr->ip.v4.as_u32; kv->key[2] = (u64) 0; @@ -555,6 +557,7 @@ add_del_ip4_key (gid_ip4_table_t * db, u32 vni, ip_prefix_t * pref, u32 val, static void ip4_lookup_init (gid_ip4_table_t * db) { + BVT (clib_bihash_init2_args) _a, *a = &_a; uword i; clib_memset (db->ip4_prefix_len_refcount, 0, @@ -579,9 +582,18 @@ ip4_lookup_init (gid_ip4_table_t * db) if (db->ip4_lookup_table_size == 0) db->ip4_lookup_table_size = IP4_LOOKUP_DEFAULT_HASH_MEMORY_SIZE; - BV (clib_bihash_init) (&db->ip4_lookup_table, "ip4 lookup table", - db->ip4_lookup_table_nbuckets, - db->ip4_lookup_table_size); + /* + * Danger Will Robinson, Danger! gid_ip4_table_t's are allocated from + * a pool. They MUST NOT be listed on the clib_all_bihashes list... + */ + memset (a, 0, sizeof (*a)); + a->h = &db->ip4_lookup_table; + a->name = "LISP ip4 lookup table"; + a->nbuckets = db->ip4_lookup_table_nbuckets; + a->memory_size = db->ip4_lookup_table_size; + a->dont_add_to_all_bihash_list = 1; /* See comment above */ + + BV (clib_bihash_init2) (a); } static u32 @@ -754,6 +766,7 @@ static void ip6_lookup_init (gid_ip6_table_t * db) { uword i; + BVT (clib_bihash_init2_args) _a, *a = &_a; clib_memset (db->ip6_prefix_len_refcount, 0, sizeof (db->ip6_prefix_len_refcount)); @@ -782,9 +795,18 @@ ip6_lookup_init (gid_ip6_table_t * db) if (db->ip6_lookup_table_size == 0) db->ip6_lookup_table_size = IP6_LOOKUP_DEFAULT_HASH_MEMORY_SIZE; - BV (clib_bihash_init) (&db->ip6_lookup_table, "ip6 lookup table", - db->ip6_lookup_table_nbuckets, - db->ip6_lookup_table_size); + /* + * Danger Will Robinson, Danger! gid_ip6_table_t's are allocated from + * a pool. They MUST NOT be listed on the clib_all_bihashes list... + */ + memset (a, 0, sizeof (*a)); + a->h = &db->ip6_lookup_table; + a->name = "LISP ip6 lookup table"; + a->nbuckets = db->ip6_lookup_table_nbuckets; + a->memory_size = db->ip6_lookup_table_size; + a->dont_add_to_all_bihash_list = 1; /* See comment above */ + + BV (clib_bihash_init2) (a); } static u32 @@ -810,7 +832,7 @@ add_del_sd_ip6_key (gid_dictionary_t * db, u32 vni, ip_prefix_t * dst_pref, { ip_prefix_t sp; clib_memset (&sp, 0, sizeof (sp)); - ip_prefix_version (&sp) = IP6; + ip_prefix_version (&sp) = AF_IP6; add_del_ip6_key (sfib, 0 /* vni */ , &sp, val, is_add); } } @@ -827,7 +849,7 @@ add_del_sd_ip6_key (gid_dictionary_t * db, u32 vni, ip_prefix_t * dst_pref, { ip_prefix_t sp; clib_memset (&sp, 0, sizeof (sp)); - ip_prefix_version (&sp) = IP6; + ip_prefix_version (&sp) = AF_IP6; old_val = add_del_ip6_key (sfib, 0 /* vni */ , &sp, val, is_add); } @@ -844,7 +866,7 @@ add_del_sd_ip6_key (gid_dictionary_t * db, u32 vni, ip_prefix_t * dst_pref, { ip_prefix_t sp; clib_memset (&sp, 0, sizeof (sp)); - ip_prefix_version (&sp) = IP6; + ip_prefix_version (&sp) = AF_IP6; old_val = add_del_ip6_key (sfib, 0, &sp, 0, is_add); } @@ -864,10 +886,10 @@ add_del_ip (gid_dictionary_t * db, u32 vni, ip_prefix_t * dst_key, { switch (ip_prefix_version (dst_key)) { - case IP4: + case AF_IP4: return add_del_sd_ip4_key (db, vni, dst_key, src_key, value, is_add); break; - case IP6: + case AF_IP6: return add_del_sd_ip6_key (db, vni, dst_key, src_key, value, is_add); break; default: