diff options
author | Pablo Camarillo <pcamaril@cisco.com> | 2017-03-16 10:43:05 +0100 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2017-03-29 08:56:05 +0000 |
commit | 4521afa9a643983c789b6b3a77b14c0a95d5e0b2 (patch) | |
tree | 0902086700854c4b6f5597b2cd0bb6f47be77a62 /src/vnet/sr/sr_localsid.c | |
parent | 45ce3fbee5c1a7ad2a01f766c9b05059aa467b8f (diff) |
Bugfixing and documentation for SRv6
- Fixed three coverity issues
- Linked SRv6 docs
- Moved sample plugin to examples folder
- Fixed bug with hash. Now everything is using mhash. Potentially in the future we want to do bihash.
Change-Id: Ie03a13c8fecb1e315e67d0596cbd23220779aaf2
Signed-off-by: Pablo Camarillo <pcamaril@cisco.com>
Diffstat (limited to 'src/vnet/sr/sr_localsid.c')
-rwxr-xr-x | src/vnet/sr/sr_localsid.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/vnet/sr/sr_localsid.c b/src/vnet/sr/sr_localsid.c index 610bb7ffbea..2e3d56de80b 100755 --- a/src/vnet/sr/sr_localsid.c +++ b/src/vnet/sr/sr_localsid.c @@ -72,18 +72,16 @@ sr_cli_localsid (char is_del, ip6_address_t * localsid_addr, int rv; ip6_sr_localsid_t *ls = 0; - ip6_address_t *key_copy; dpo_id_t dpo = DPO_INVALID; /* Search for the item */ - p = hash_get_mem (sm->localsids_index_by_key, localsid_addr); + p = mhash_get (&sm->sr_localsids_index_hash, localsid_addr); if (p) { if (is_del) { - hash_pair_t *hp; /* Retrieve localsid */ ls = pool_elt_at_index (sm->localsids, p[0]); /* Delete FIB entry */ @@ -116,10 +114,7 @@ sr_cli_localsid (char is_del, ip6_address_t * localsid_addr, /* Delete localsid registry */ pool_put (sm->localsids, ls); - hp = hash_get_pair (sm->localsids_index_by_key, localsid_addr); - key_copy = (void *) (hp->key); - hash_unset_mem (sm->localsids_index_by_key, localsid_addr); - vec_free (key_copy); + mhash_unset (&sm->sr_localsids_index_hash, localsid_addr, NULL); return 1; } else /* create with function already existing; complain */ @@ -232,9 +227,8 @@ sr_cli_localsid (char is_del, ip6_address_t * localsid_addr, } /* Set hash key for searching localsid by address */ - key_copy = vec_new (ip6_address_t, 1); - clib_memcpy (key_copy, localsid_addr, sizeof (ip6_address_t)); - hash_set_mem (sm->localsids_index_by_key, key_copy, ls - sm->localsids); + mhash_set (&sm->sr_localsids_index_hash, localsid_addr, ls - sm->localsids, + NULL); fib_table_entry_special_dpo_add (fib_index, &pfx, FIB_SOURCE_SR, FIB_ENTRY_FLAG_EXCLUSIVE, &dpo); @@ -1476,8 +1470,8 @@ sr_localsids_init (vlib_main_t * vm) { /* Init memory for function keys */ ip6_sr_main_t *sm = &sr_main; - sm->localsids_index_by_key = - hash_create_mem (0, sizeof (ip6_address_t), sizeof (uword)); + mhash_init (&sm->sr_localsids_index_hash, sizeof (uword), + sizeof (ip6_address_t)); /* Init SR behaviors DPO type */ sr_localsid_dpo_type = dpo_register_new_type (&sr_loc_vft, sr_loc_nodes); /* Init SR behaviors DPO type */ |