vpp-dev / vpp

Working copy of vpp
http://www.fd.io
Apache License 2.0
46 stars 28 forks source link

hash_get_mem/hash_set_mem bugs #11

Closed flybeyond closed 6 years ago

flybeyond commented 7 years ago

These 2 functions are used to get/set with key is pointer, correct? From the code, it just converts the point to u64, then store the key. But same value many store in different pointer, this will cause hash doesn't work. eg. <key, value> <123, 0xabcd> u64 key1 = 123; u64 key2 = 123; hash_set_mem (xxx, key1); hash_get_mem(xxx, key2) will return NULL, but we thought key 123 is in hash table, because set hash_set_mem (xxx, key1, value); Even you use *key to refer the original key will fail, because the point may locate at stack, not available. l2tp.c have such issue in create_l2tpv3_ipv6_tunnel. If I inserted the same src address by another address, this check will pass. But not expected.

switch (lm->lookup_type) { case L2T_LOOKUP_SRC_ADDRESS: p = hash_get_mem (lm->session_by_src_address, client_address); ...}

dmarion commented 6 years ago

Please use jira.fd.io for reporting issues...