From patchwork Sat Jul 20 16:30:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 1134401 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netfilter-devel-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nwl.cc Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45rYJy1J1Dz9sNC for ; Sun, 21 Jul 2019 02:30:58 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726455AbfGTQa5 (ORCPT ); Sat, 20 Jul 2019 12:30:57 -0400 Received: from orbyte.nwl.cc ([151.80.46.58]:40898 "EHLO orbyte.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726300AbfGTQa5 (ORCPT ); Sat, 20 Jul 2019 12:30:57 -0400 Received: from localhost ([::1]:53988 helo=tatos) by orbyte.nwl.cc with esmtp (Exim 4.91) (envelope-from ) id 1hosG8-0005Sd-0Z; Sat, 20 Jul 2019 18:30:56 +0200 From: Phil Sutter To: Pablo Neira Ayuso Cc: netfilter-devel@vger.kernel.org Subject: [iptables PATCH 11/12] arptables-save: Merge into xtables_save_main() Date: Sat, 20 Jul 2019 18:30:25 +0200 Message-Id: <20190720163026.15410-12-phil@nwl.cc> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190720163026.15410-1-phil@nwl.cc> References: <20190720163026.15410-1-phil@nwl.cc> MIME-Version: 1.0 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org With all preparations in place, xtables_save_main() can replace it with not further changes. Signed-off-by: Phil Sutter --- 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); }