summaryrefslogtreecommitdiffstats
path: root/ip6tables-save.c
diff options
context:
space:
mode:
authorJan Engelhardt <jengelh@medozas.de>2009-03-19 16:57:35 +0100
committerJan Engelhardt <jengelh@medozas.de>2009-03-19 16:57:35 +0100
commitfbb5639c02218acfd84c4f25f134efecb564fee1 (patch)
tree39b135a6d2937fcb8a732b68d901f6ea8132e2c2 /ip6tables-save.c
parent421157976351606bee0d2a33acee89178521f78a (diff)
iptables-save: module loading corrections
1. Ignore the absence of /proc/net/ip_tables_names, which happens when x_tables.ko is not loaded. This is equivalent to having x_tables.ko, but no tabe modules, loaded. As such, success should be returned. 2. Load table when explicitly requested by the -t option. Users might expect "*foo" etc. to be output when `iptables-save -t foo` is executed. So do autoload x_tables.ko and the table in this case. *. Do this for both iptables-save and ip6tables-save, and adjust the manpages for the new -M (modprobe program location) option that is introduced. Based upon a patch by Soren Hansen. Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Diffstat (limited to 'ip6tables-save.c')
-rw-r--r--ip6tables-save.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/ip6tables-save.c b/ip6tables-save.c
index 55010c44..97205c1c 100644
--- a/ip6tables-save.c
+++ b/ip6tables-save.c
@@ -29,6 +29,7 @@ static const struct option options[] = {
{.name = "counters", .has_arg = false, .val = 'c'},
{.name = "dump", .has_arg = false, .val = 'd'},
{.name = "table", .has_arg = true, .val = 't'},
+ {.name = "modprobe", .has_arg = true, .val = 'M'},
{NULL},
};
@@ -42,9 +43,7 @@ static int for_each_table(int (*func)(const char *tablename))
procfile = fopen("/proc/net/ip6_tables_names", "r");
if (!procfile)
- xtables_error(OTHER_PROBLEM,
- "Unable to open /proc/net/ip6_tables_names: %s\n",
- strerror(errno));
+ return ret;
while (fgets(tablename, sizeof(tablename), procfile)) {
if (tablename[strlen(tablename) - 1] != '\n')
@@ -68,6 +67,10 @@ static int do_output(const char *tablename)
return for_each_table(&do_output);
h = ip6tc_init(tablename);
+ if (h == NULL) {
+ xtables_load_ko(xtables_modprobe_program, false);
+ h = ip6tc_init(tablename);
+ }
if (!h)
xtables_error(OTHER_PROBLEM, "Cannot initialize: %s\n",
ip6tc_strerror(errno));
@@ -162,6 +165,9 @@ int main(int argc, char *argv[])
/* Select specific table. */
tablename = optarg;
break;
+ case 'M':
+ xtables_modprobe_program = optarg;
+ break;
case 'd':
do_output(tablename);
exit(0);