From 35eacc1b475ddd6b257015bb9877c3fd06e50930 Mon Sep 17 00:00:00 2001 From: Tomasz Bursztyka Date: Fri, 23 Sep 2011 14:43:46 +0300 Subject: [PATCH] iptables: Adding capability to load necessary modules --- src/iptables.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/iptables.c b/src/iptables.c index d97efea..142d277 100644 --- a/src/iptables.c +++ b/src/iptables.c @@ -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); -- 2.7.4