From 8efec49e8684e8102cb69dc19c5ba07270b0f435 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Mon, 22 Jul 2019 12:16:20 +0200 Subject: xtables-save: Unify *-save header/footer comments Make eb- and arptables-save print both header and footer comments, too. Also print them for each table separately - the timing information is worth the extra lines in output. Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso --- iptables/xtables-save.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'iptables/xtables-save.c') diff --git a/iptables/xtables-save.c b/iptables/xtables-save.c index 491122f3..0cf11f99 100644 --- a/iptables/xtables-save.c +++ b/iptables/xtables-save.c @@ -250,7 +250,6 @@ static int __ebt_save(struct nft_handle *h, const char *tablename, bool counters { struct nftnl_chain_list *chain_list; unsigned int format = FMT_NOCOUNTS; - static bool first = true; time_t now; if (!nft_table_find(h, tablename)) { @@ -265,12 +264,9 @@ static int __ebt_save(struct nft_handle *h, const char *tablename, bool counters chain_list = nft_chain_list_get(h, tablename); - if (first) { - now = time(NULL); - printf("# Generated by %s v%s on %s", prog_name, - prog_vers, ctime(&now)); - first = false; - } + now = time(NULL); + printf("# Generated by %s v%s on %s", prog_name, + prog_vers, ctime(&now)); printf("*%s\n", tablename); if (counters) @@ -281,7 +277,8 @@ static int __ebt_save(struct nft_handle *h, const char *tablename, bool counters * thereby preventing dependency conflicts */ nft_chain_save(h, chain_list); nft_rule_save(h, tablename, format); - printf("\n"); + now = time(NULL); + printf("# Completed on %s", ctime(&now)); return 0; } @@ -361,6 +358,7 @@ 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);; @@ -407,10 +405,13 @@ int xtables_arp_save_main(int argc, char **argv) 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); - printf("\n"); + now = time(NULL); + printf("# Completed on %s", ctime(&now)); nft_fini(&h); return 0; } -- cgit v1.2.3