From patchwork Thu Jul 19 16:32:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 946498 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 41Wfh54pmCz9s4w for ; Fri, 20 Jul 2018 02:32:53 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732057AbeGSRQu (ORCPT ); Thu, 19 Jul 2018 13:16:50 -0400 Received: from orbyte.nwl.cc ([151.80.46.58]:49208 "EHLO orbyte.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731663AbeGSRQt (ORCPT ); Thu, 19 Jul 2018 13:16:49 -0400 Received: from localhost ([::1]:36252 helo=tatos) by orbyte.nwl.cc with esmtp (Exim 4.90_1) (envelope-from ) id 1fgBrH-0000OV-Mg; Thu, 19 Jul 2018 18:32:51 +0200 From: Phil Sutter To: Pablo Neira Ayuso Cc: Florian Westphal , netfilter-devel@vger.kernel.org Subject: [iptables PATCH 14/17] xtables: Pass format to nft_rule_save() Date: Thu, 19 Jul 2018 18:32:06 +0200 Message-Id: <20180719163209.7987-15-phil@nwl.cc> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180719163209.7987-1-phil@nwl.cc> References: <20180719163209.7987-1-phil@nwl.cc> Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org Preparing ebtables-save implementation, allow for callers to pass format bits to nft_rule_save() instead of just the 'counters' boolean. Signed-off-by: Phil Sutter --- iptables/nft.c | 5 ++--- iptables/nft.h | 2 +- iptables/xtables-save.c | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/iptables/nft.c b/iptables/nft.c index 7889822af87f1..b1516692361d1 100644 --- a/iptables/nft.c +++ b/iptables/nft.c @@ -1375,7 +1375,7 @@ retry: return list; } -int nft_rule_save(struct nft_handle *h, const char *table, bool counters) +int nft_rule_save(struct nft_handle *h, const char *table, unsigned int format) { struct nftnl_rule_list *list; struct nftnl_rule_list_iter *iter; @@ -1397,8 +1397,7 @@ int nft_rule_save(struct nft_handle *h, const char *table, bool counters) if (strcmp(table, rule_table) != 0) goto next; - nft_rule_print_save(r, NFT_RULE_APPEND, - counters ? 0 : FMT_NOCOUNTS); + nft_rule_print_save(r, NFT_RULE_APPEND, format); next: r = nftnl_rule_list_iter_next(iter); diff --git a/iptables/nft.h b/iptables/nft.h index a3f5c202d8f57..17031871c8e3d 100644 --- a/iptables/nft.h +++ b/iptables/nft.h @@ -98,7 +98,7 @@ int nft_rule_delete_num(struct nft_handle *h, const char *chain, const char *tab int nft_rule_replace(struct nft_handle *h, const char *chain, const char *table, void *data, int rulenum, bool verbose); int nft_rule_list(struct nft_handle *h, const char *chain, const char *table, int rulenum, unsigned int format); int nft_rule_list_save(struct nft_handle *h, const char *chain, const char *table, int rulenum, int counters); -int nft_rule_save(struct nft_handle *h, const char *table, bool counters); +int nft_rule_save(struct nft_handle *h, const char *table, unsigned int format); int nft_rule_flush(struct nft_handle *h, const char *chain, const char *table); int nft_rule_zero_counters(struct nft_handle *h, const char *chain, const char *table, int rulenum); diff --git a/iptables/xtables-save.c b/iptables/xtables-save.c index c19c9991e5a60..e6bad32fa0b81 100644 --- a/iptables/xtables-save.c +++ b/iptables/xtables-save.c @@ -70,7 +70,7 @@ __do_output(struct nft_handle *h, const char *tablename, bool counters) /* Dump out chain names first, * thereby preventing dependency conflicts */ nft_chain_save(h, chain_list, tablename); - nft_rule_save(h, tablename, counters); + nft_rule_save(h, tablename, counters ? 0 : FMT_NOCOUNTS); now = time(NULL); printf("COMMIT\n");