netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Giuseppe Longo <giuseppelng@gmail.com>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH 1/2] nft: print counter issues
Date: Tue, 25 Jun 2013 09:46:06 +0200	[thread overview]
Message-ID: <20130625074606.4665.80766.stgit@localhost> (raw)

The patch fixes the counter print, missing line,
and delete warnings.

Signed-off-by: Giuseppe Longo <giuseppelng@gmail.com>
---
 iptables/nft.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/iptables/nft.c b/iptables/nft.c
index 42bf50f..680b2f0 100644
--- a/iptables/nft.c
+++ b/iptables/nft.c
@@ -18,6 +18,7 @@
 #include <netdb.h>	/* getprotobynumber */
 #include <time.h>
 #include <stdarg.h>
+#include <inttypes.h>
 
 #include <xtables.h>
 #include <libiptc/libxtc.h>
@@ -951,7 +952,7 @@ nft_print_counters(struct nft_rule_expr *e, struct nft_rule_expr_iter *iter,
 		   bool counters)
 {
 	if (counters) {
-		printf("-c %lu %lu ",
+		printf("-c %"PRIu64" %"PRIu64" ",
 			nft_rule_expr_get_u64(e, NFT_EXPR_CTR_PACKETS),
 			nft_rule_expr_get_u64(e, NFT_EXPR_CTR_BYTES));
 	}
@@ -1077,10 +1078,10 @@ static void nft_chain_print_save(struct nft_chain *c, bool basechain)
 		if (nft_chain_attr_get(c, NFT_CHAIN_ATTR_POLICY))
 			pol = nft_chain_attr_get_u32(c, NFT_CHAIN_ATTR_POLICY);
 
-		printf(":%s %s [%lu:%lu]\n", chain, policy_name[pol],
+		printf(":%s %s [%"PRIu64":%"PRIu64"]\n", chain, policy_name[pol],
 					     pkts, bytes);
 	} else
-		printf(":%s - [%lu:%lu]\n", chain, pkts, bytes);
+		printf(":%s - [%"PRIu64":%"PRIu64"]\n", chain, pkts, bytes);
 }
 
 int nft_chain_save(struct nft_handle *h, struct nft_chain_list *list,
@@ -2480,6 +2481,7 @@ int nft_rule_list(struct nft_handle *h, const char *chain, const char *table,
 	struct nft_chain_list *list;
 	struct nft_chain_list_iter *iter;
 	struct nft_chain *c;
+	bool found = false;
 
 	/* If built-in chains don't exist for this table, create them */
 	if (nft_xtables_config_load(h, XTABLES_CONFIG_DEFAULT, 0) < 0)
@@ -2517,10 +2519,15 @@ int nft_rule_list(struct nft_handle *h, const char *chain, const char *table,
 		if (chain && strcmp(chain, chain_name) != 0)
 			goto next;
 
+		if (found) printf("\n");
+
 		print_header(format, chain_name, policy_name[policy], &ctrs,
 			     basechain, refs);
 
 		__nft_rule_list(h, c, table, rulenum, format, print_firewall);
+
+		found = true;
+
 next:
 		c = nft_chain_list_iter_next(iter);
 	}
@@ -2567,7 +2574,7 @@ nft_rule_list_chain_save(struct nft_handle *h, const char *table,
 			printf("-P %s %s", chain_name, policy_name[policy]);
 
 			if (counters) {
-				printf(" -c %lu %lu\n",
+				printf(" -c %"PRIu64" %"PRIu64"\n",
 					nft_chain_attr_get_u64(c, NFT_CHAIN_ATTR_PACKETS),
 					nft_chain_attr_get_u64(c, NFT_CHAIN_ATTR_BYTES));
 			} else


             reply	other threads:[~2013-06-25  7:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-25  7:46 Giuseppe Longo [this message]
2013-06-25  7:46 ` [PATCH 2/2] nft: mem leak in nft_rule_list_cb Giuseppe Longo
2013-06-25 10:00   ` Pablo Neira Ayuso
2013-06-25 10:00 ` [PATCH 1/2] nft: print counter issues Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130625074606.4665.80766.stgit@localhost \
    --to=giuseppelng@gmail.com \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).