iptables: Adding capability to load necessary modules
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Fri, 23 Sep 2011 11:43:46 +0000 (14:43 +0300)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 29 Sep 2011 15:52:59 +0000 (17:52 +0200)
src/iptables.c

index d97efea..142d277 100644 (file)
@@ -1138,11 +1138,25 @@ static void table_cleanup(struct connman_iptables *table)
 
 static struct connman_iptables *iptables_init(char *table_name)
 {
-       struct connman_iptables *table;
+       struct connman_iptables *table = NULL;
+       char *module = NULL;
        socklen_t s;
 
        DBG("%s", table_name);
 
+       if (xtables_insmod("ip_tables", NULL, TRUE) != 0)
+               goto err;
+
+       module = g_strconcat("iptable_", table_name, NULL);
+       if (module == NULL)
+               goto err;
+
+       if (xtables_insmod(module, NULL, TRUE) != 0)
+               goto err;
+
+       g_free(module);
+       module = NULL;
+
        table = g_hash_table_lookup(table_hash, table_name);
        if (table != NULL)
                return table;
@@ -1194,6 +1208,7 @@ static struct connman_iptables *iptables_init(char *table_name)
        return table;
 
 err:
+       g_free(module);
 
        table_cleanup(table);