Patchwork [v3,nfacct,28/29] add "show marks" option to "list" and "get" commands

login
register
mail settings
Submitter Michael Zintakis
Date July 10, 2013, 6:25 p.m.
Message ID <1373480727-11254-29-git-send-email-michael.zintakis@googlemail.com>
Download mbox | patch
Permalink /patch/258216/
State Not Applicable
Headers show

Comments

Michael Zintakis - July 10, 2013, 6:25 p.m.
* 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 <michael.zintakis@googlemail.com>
---
 src/nfacct.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Patch

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"