From 6f60f22c488675ef9c9e02ca4abc9dc0b210f6a6 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Thu, 19 Jul 2018 18:32:06 +0200 Subject: xtables: pass format to nft_rule_save() 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 Signed-off-by: Florian Westphal --- 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 9f650f5a..07e15c7a 100644 --- a/iptables/nft.c +++ b/iptables/nft.c @@ -1373,7 +1373,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; @@ -1395,8 +1395,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 a3f5c202..17031871 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 c19c9991..e6bad32f 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"); -- cgit v1.2.3