From patchwork Wed Jul 10 18:25:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Zintakis X-Patchwork-Id: 258216 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 2B3092C02EB for ; Thu, 11 Jul 2013 04:27:00 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755041Ab3GJS06 (ORCPT ); Wed, 10 Jul 2013 14:26:58 -0400 Received: from mail-lb0-f179.google.com ([209.85.217.179]:44308 "EHLO mail-lb0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755028Ab3GJS06 (ORCPT ); Wed, 10 Jul 2013 14:26:58 -0400 Received: by mail-lb0-f179.google.com with SMTP id w20so5931780lbh.38 for ; Wed, 10 Jul 2013 11:26:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=MgdBfeMz6jrPl9dhXAk5V1ExtuaowTk59Y8lAL+tyME=; b=wmIURP6dC4VSAZJRORwjLz41iH28cNRtr4msYXyLvYdz4q3jxmEPAsKGHZKVKgNd9n WBkLrXHJbP4h5mvpFA7C932OWUcYS0xQmRq0/CPoCvW04+6QZi4ntw/S9E6yWGi785cR XBomMak+W++OI8teZhos0ZHRH3c13S7dKQZ3fjMDQ/KrZxylP3TcXogyUlM1PUnv3pVc ak0m/v36VCre9qfs8Iwp82dsKhgj7nP2ugPI+tVJpXP5JqcHtR/qoQUY/LFc6I/zNrBX jUFYwPopH4ScxyRKyuxj8JmdsFr5rC4fnrY0PFH/+zEJZOuI6Pxz8yHaiy7syL8z40J0 HH5Q== X-Received: by 10.152.27.169 with SMTP id u9mr15209785lag.8.1373480816970; Wed, 10 Jul 2013 11:26:56 -0700 (PDT) Received: from xp1.wyse.network (assk.torservers.net. [78.108.63.46]) by mx.google.com with ESMTPSA id g7sm11472544lae.6.2013.07.10.11.26.54 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 10 Jul 2013 11:26:56 -0700 (PDT) From: Michael Zintakis To: netfilter-devel@vger.kernel.org Cc: pablo@netfilter.org Subject: [PATCH v3 nfacct 28/29] add "show marks" option to "list" and "get" commands Date: Wed, 10 Jul 2013 19:25:26 +0100 Message-Id: <1373480727-11254-29-git-send-email-michael.zintakis@googlemail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1373480727-11254-1-git-send-email-michael.zintakis@googlemail.com> References: <1373480727-11254-1-git-send-email-michael.zintakis@googlemail.com> Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org * add "show marks" option to "list" and "get" commands, allwoing only mark-specific nfacct object properties to be shown - pmark (the amount of packets passed through the accounting object since a "mark" was set), bmark (the amount of bytes passed through the accounting object since a "mark" was set) and name. The formatting used for showing pmark and bmark is the same as pkts and bytes properties respectively, unless overwritten with the "format" option. Signed-off-by: Michael Zintakis --- src/nfacct.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/nfacct.c b/src/nfacct.c index 2cb0256..4ce6854 100644 --- a/src/nfacct.c +++ b/src/nfacct.c @@ -305,6 +305,8 @@ static int nfacct_cmd_list(int argc, char *argv[]) NFACCT_GET_NEXT_ARG(); if (nfacct_matches(argv[0],"bytes")) { flags = NFACCT_SNPRINTF_F_BONLY; + } else if (nfacct_matches(argv[0],"marks")) { + flags = NFACCT_SNPRINTF_F_MONLY; } else if (nfacct_matches(argv[0],"extended")) { flags = NFACCT_SNPRINTF_F_EXTENDED; } else { @@ -645,6 +647,8 @@ static int nfacct_cmd_get(int argc, char *argv[]) NFACCT_GET_NEXT_ARG(); if (nfacct_matches(argv[0],"bytes")) { flags = NFACCT_SNPRINTF_F_BONLY; + } else if (nfacct_matches(argv[0],"marks")) { + flags = NFACCT_SNPRINTF_F_MONLY; } else if (nfacct_matches(argv[0],"extended")) { flags = NFACCT_SNPRINTF_F_EXTENDED; } else { @@ -825,7 +829,7 @@ static const char help_msg[] = " GET_PARAMS := [ reset | setmark | clrmark ] [ show SHOW_SPEC ]\n" "\t\t[ format FMT_SPEC ] [ xml ]\n" " RST_PARAMS := [ flush ] [ replace ]\n" - " SHOW_SPEC := { bytes | extended }\n" + " SHOW_SPEC := { bytes | marks | extended }\n" " FMT_SPEC := { [FMT] | [,] | [FMT] ... }\n" " SORT_SPEC := { none | name | packets | pmark | bytes | bmark |" " threshold }\n"