From patchwork Tue Jun 25 07:46:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuseppe Longo X-Patchwork-Id: 254048 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id B70452C00A7 for ; Tue, 25 Jun 2013 17:46:13 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751326Ab3FYHqM (ORCPT ); Tue, 25 Jun 2013 03:46:12 -0400 Received: from mail-ea0-f177.google.com ([209.85.215.177]:58580 "EHLO mail-ea0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751211Ab3FYHqL (ORCPT ); Tue, 25 Jun 2013 03:46:11 -0400 Received: by mail-ea0-f177.google.com with SMTP id j14so6542762eak.36 for ; Tue, 25 Jun 2013 00:46:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:from:date:message-id:user-agent:mime-version :content-type:content-transfer-encoding; bh=dyMTP0OtHcGi2pWKQBKuo9TDerPGBLc+kubFoRMdSp8=; b=QrHJuMDOOKE0ZPZh59J+J8h8i9z2jHnsQM7FF63naROf6rqFClWvQaEalqcUZTW8zk GM34b6u1ucHIKWJWvA5Fh4W2DncJWBV2Owl+TTd/GujGjrY1pf8CFD23TZbS4W4qxcQp 2dsHSqbHMdOubivd1phJPEtfmvoRkftA1HGnbAE4fN7sPFjPLowkxDTn5DhAPJz2A4I0 aF3ABImhutldUMfhCvBI5jnVerqlpA5BMkNjKQcGOsd9i+mYu3blfO8GuM9uRg4p6VWL eNl3pNu3Ahu7PTuXLFz8YL/eg4DDQ662dwZO4ndKaU6iEO/ysnRnmXpMsBSQ0cTISK16 opoA== X-Received: by 10.15.31.198 with SMTP id y46mr28532984eeu.135.1372146370252; Tue, 25 Jun 2013 00:46:10 -0700 (PDT) Received: from [127.0.0.1] ([46.182.89.105]) by mx.google.com with ESMTPSA id n5sm33912093eed.9.2013.06.25.00.46.08 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 25 Jun 2013 00:46:09 -0700 (PDT) Subject: [PATCH 1/2] nft: print counter issues To: netfilter-devel@vger.kernel.org From: Giuseppe Longo Date: Tue, 25 Jun 2013 09:46:06 +0200 Message-ID: <20130625074606.4665.80766.stgit@localhost> User-Agent: StGit/0.16 MIME-Version: 1.0 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org The patch fixes the counter print, missing line, and delete warnings. Signed-off-by: Giuseppe Longo --- iptables/nft.c | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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 /* getprotobynumber */ #include #include +#include #include #include @@ -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