With all preparations in place, xtables_save_main() can replace it with not further changes. Signed-off-by: Phil Sutter <phil@xxxxxx> --- iptables/xtables-save.c | 63 ++--------------------------------------- 1 file changed, 3 insertions(+), 60 deletions(-) diff --git a/iptables/xtables-save.c b/iptables/xtables-save.c index 980a80ff06f96..0c294e056c7b5 100644 --- a/iptables/xtables-save.c +++ b/iptables/xtables-save.c @@ -372,65 +372,8 @@ int xtables_eb_save_main(int argc_, char *argv_[]) return 0; } -int xtables_arp_save_main(int argc, char **argv) +int xtables_arp_save_main(int argc, char *argv[]) { - struct nft_handle h = { - .family = NFPROTO_ARP, - }; - time_t now; - int c; - - xtables_globals.program_name = basename(*argv);; - c = xtables_init_all(&xtables_globals, h.family); - if (c < 0) { - fprintf(stderr, "%s/%s Failed to initialize xtables\n", - xtables_globals.program_name, - xtables_globals.program_version); - exit(1); - } - - while ((c = getopt_long(argc, argv, arp_save_optstring, 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 `%s.8' for more information.\n", - prog_name); - exit(1); - } - } - - if (nft_init(&h, xtables_arp) < 0) { - fprintf(stderr, "%s/%s Failed to initialize nft: %s\n", - xtables_globals.program_name, - xtables_globals.program_version, - strerror(errno)); - exit(EXIT_FAILURE); - } - - if (!nft_table_find(&h, "filter")) - return 0; - - if (!nft_is_table_compatible(&h, "filter")) { - printf("# Table `filter' is incompatible, use 'nft' tool.\n"); - return 0; - } - - printf("# Generated by %s v%s on %s", prog_name, - prog_vers, ctime(&now)); - printf("*filter\n"); - nft_chain_save(&h, nft_chain_list_get(&h, "filter")); - nft_rule_save(&h, "filter", show_counters ? 0 : FMT_NOCOUNTS); - now = time(NULL); - printf("# Completed on %s", ctime(&now)); - nft_fini(&h); - return 0; + return xtables_save_main(NFPROTO_ARP, argc, argv, + arp_save_optstring, arp_save_options); } -- 2.22.0