[hipl-commit] [trunk] Rev 3547: Port cache uninit function.

  • From: Miika Komu <miika@xxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Mon, 8 Feb 2010 13:52:50 +0200

Committer: Miika Komu <miika@xxxxxx>
Date: Mon Feb 08 13:52:49 2010 +0200
Revision: 3547
Revision-id: miika@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: trunk

Log:
  Port cache uninit function.

Modified:
  M  firewall/cache_port.c
  M  firewall/cache_port.h
  M  firewall/firewall.c

=== modified file 'firewall/cache_port.c'
--- firewall/cache_port.c       2010-02-08 11:46:21 +0000
+++ firewall/cache_port.c       2010-02-08 11:52:49 +0000
@@ -24,7 +24,7 @@
 #include "cache.h"
 #include "lib/core/misc.h"
 
-static HIP_HASHTABLE *firewall_port_cache_db;
+static HIP_HASHTABLE *firewall_port_cache_db = NULL;
 
 /**
  * add a default entry in the firewall port cache.
@@ -154,4 +154,27 @@
                                        hip_firewall_match_port_cache_key);
 }
 
+/**
+ * Initialize port cache database
+ * 
+ */
+void firewall_port_cache_uninit_hldb(void){
+       int i;
+       firewall_port_cache_hl_t *this = NULL;
+       hip_list_t *item, *tmp;
+       
+       HIP_DEBUG("Start hldb delete\n");
+       HIP_LOCK_HT(&firewall_port_cache_db);
+
+       list_for_each_safe(item, tmp, firewall_port_cache_db, i)
+       {
+               this = (firewall_port_cache_hl_t *)list_entry(item);
+               hip_ht_delete(firewall_port_cache_db, this);
+               free(this);
+       }
+       HIP_UNLOCK_HT(&firewall_port_cache_db);
+        hip_ht_uninit(&firewall_port_cache_db);
+       HIP_DEBUG("End hldbdb delete\n");
+}
+
 

=== modified file 'firewall/cache_port.h'
--- firewall/cache_port.h       2010-01-19 09:28:42 +0000
+++ firewall/cache_port.h       2010-02-08 11:52:49 +0000
@@ -6,6 +6,7 @@
 void firewall_port_cache_init_hldb(void);
 firewall_port_cache_hl_t *firewall_port_cache_db_match(in_port_t port, 
                                                        int proto);
+void firewall_port_cache_uninit_hldb(void);
 
 #endif /* HIP_CACHE_H */
 

=== modified file 'firewall/firewall.c'
--- firewall/firewall.c 2010-01-21 15:00:13 +0000
+++ firewall/firewall.c 2010-02-08 11:52:49 +0000
@@ -642,7 +642,6 @@
 #endif
 
        // Initializing local database for mapping LSI-HIT in the firewall
-       // FIXME never uninited -> memory leak
        firewall_init_hldb();
        // Initializing local cache database
        firewall_cache_init_hldb();
@@ -753,6 +752,7 @@
                HIP_DEBUG("Failed to notify hipd of firewall shutdown.\n");
        free(msg);
 
+       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

Other related posts:

  • » [hipl-commit] [trunk] Rev 3547: Port cache uninit function. - Miika Komu