summaryrefslogtreecommitdiffstats
path: root/iptables/xtables-save.c
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2018-11-05 13:38:08 +0100
committerFlorian Westphal <fw@strlen.de>2018-11-12 14:53:24 +0100
commit50c2397af9b6cf7ed6e34e9a8cb7b928cee9f1bd (patch)
treeb539ed55ec4dfd73939a1363471c35e5bdd01f07 /iptables/xtables-save.c
parentd9a518ee22cf90ddeb56a9df687aef953fda0fa0 (diff)
arptables-save: add -c option, like xtables-save
arptables classic doesn't have arptables-save, it only has a perl script that attempts to emulate iptables-save. It supports no options, and thus has no way to dump counters. Add -c option, like iptables to enable this. Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'iptables/xtables-save.c')
-rw-r--r--iptables/xtables-save.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/iptables/xtables-save.c b/iptables/xtables-save.c
index 28711720..bed3ee03 100644
--- a/iptables/xtables-save.c
+++ b/iptables/xtables-save.c
@@ -43,6 +43,13 @@ static const struct option options[] = {
{NULL},
};
+static const struct option arp_save_options[] = {
+ {.name = "counters", .has_arg = false, .val = 'c'},
+ {.name = "version", .has_arg = false, .val = 'V'},
+ {.name = "modprobe", .has_arg = true, .val = 'M'},
+ {NULL},
+};
+
static const struct option ebt_save_options[] = {
{.name = "counters", .has_arg = false, .val = 'c'},
{.name = "version", .has_arg = false, .val = 'V'},
@@ -357,6 +364,24 @@ int xtables_arp_save_main(int argc, char **argv)
exit(1);
}
+ while ((c = getopt_long(argc, argv, "cM:V", arp_save_options, NULL)) != -1) {
+ switch (c) {
+ case 'c':
+ show_counters = true;
+ break;
+ case 'M':
+ xtables_modprobe_program = optarg;
+ break;
+ case 'V':
+ printf("%s v%s (nf_tables)\n", prog_name, prog_vers);
+ exit(0);
+ default:
+ fprintf(stderr,
+ "Look at manual page `xtables-save.8' for more information.\n");
+ exit(1);
+ }
+ }
+
if (nft_init(&h, xtables_arp) < 0) {
fprintf(stderr, "%s/%s Failed to initialize nft: %s\n",
xtables_globals.program_name,
@@ -375,7 +400,7 @@ int xtables_arp_save_main(int argc, char **argv)
printf("*filter\n");
nft_chain_save(&h, nft_chain_list_get(&h), "filter");
- nft_rule_save(&h, "filter", FMT_NOCOUNTS);
+ nft_rule_save(&h, "filter", show_counters ? 0 : FMT_NOCOUNTS);
printf("\n");
nft_fini(&h);
return 0;