Committer: Miika Komu <miika@xxxxxx> Date: Fri Feb 26 16:18:41 2010 +0200 Revision: 3716 Revision-id: miika@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Branch nick: trunk Log: A bug fix to cache data base (#1130) and some clean ups. Hipfw was crashing on "hipconf rst". This commit fixes the problem. Includes some other clean ups for related functions (doxygen, comment styling). Modified: M firewall/cache.c M firewall/cache.h M firewall/firewall.c M firewall/firewall_control.c M firewall/lsi.c === modified file 'firewall/cache.c' --- firewall/cache.c 2010-02-18 11:40:11 +0000 +++ firewall/cache.c 2010-02-26 14:18:41 +0000 @@ -276,8 +276,11 @@ /** * Uninitialize cache database + * + * @param exit 1 if the firewall is exiting and the hashtable should be + * freed or zero otherwise */ -void hip_firewall_cache_delete_hldb(void) +void hip_firewall_cache_delete_hldb(int exit) { int i; firewall_cache_hl_t *this = NULL; @@ -290,13 +293,16 @@ list_for_each_safe(item, tmp, firewall_cache_db, i) { this = (firewall_cache_hl_t *) list_entry(item); - // delete this hip_ht_delete(firewall_cache_db, this); - // free this free(this); } + /* Note: this function is also reached by "hipconf rst all" + * so we don't want to uninitialize hash table here. Instead, + * we handle it in firewall_exit(). */ + HIP_UNLOCK_HT(&firewall_cache_db); - hip_ht_uninit(firewall_cache_db); + if (exit) + hip_ht_uninit(firewall_cache_db); HIP_DEBUG("End hldbdb delete\n"); } === modified file 'firewall/cache.h' --- firewall/cache.h 2010-02-17 13:08:39 +0000 +++ firewall/cache.h 2010-02-26 14:18:41 +0000 @@ -16,7 +16,7 @@ //int hip_firewall_cache_match_ip_peer(const void *ptr1, const void *ptr2); -void hip_firewall_cache_delete_hldb(void); +void hip_firewall_cache_delete_hldb(int); === modified file 'firewall/firewall.c' --- firewall/firewall.c 2010-02-24 17:44:04 +0000 +++ firewall/firewall.c 2010-02-26 14:18:41 +0000 @@ -938,7 +938,6 @@ } free(msg); - hip_firewall_port_cache_uninit_hldb(); hip_fw_uninit_system_based_opp_mode(); hip_fw_flush_iptables(); /* rules have to be removed first, otherwise HIP packets won't pass through === modified file 'firewall/firewall_control.c' --- firewall/firewall_control.c 2010-02-17 13:55:23 +0000 +++ firewall/firewall_control.c 2010-02-26 14:18:41 +0000 @@ -169,7 +169,7 @@ // save to database break; case SO_HIP_RESET_FIREWALL_DB: - hip_firewall_cache_delete_hldb(); + hip_firewall_cache_delete_hldb(0); hip_firewall_delete_hldb(); break; case SO_HIP_OFFER_FULLRELAY: === modified file 'firewall/lsi.c' --- firewall/lsi.c 2010-02-17 13:55:23 +0000 +++ firewall/lsi.c 2010-02-26 14:18:41 +0000 @@ -458,15 +458,20 @@ return err; } +/** + * Uninitialize LSI database + * + * @return zero + */ int uninit_lsi() { int err = 0; - //empty the firewall db + /* empty the firewall db */ hip_firewall_delete_hldb(); - //empty tha firewall cache - hip_firewall_cache_delete_hldb(); + /* empty tha firewall cache */ + hip_firewall_cache_delete_hldb(1); return err; }