It was possible to specify several equal options for list operation. Signed-off-by: Alexey Perevalov <a.perevalov@xxxxxxxxxxx> --- src/nfacct.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/nfacct.c b/src/nfacct.c index 091a5c9..d77a57e 100644 --- a/src/nfacct.c +++ b/src/nfacct.c @@ -25,6 +25,13 @@ #include <linux/netfilter/nfnetlink_acct.h> #include <linux/netfilter/nfnetlink.h> +#define CHECK_OPT_PLURARITY(opt_name, msg) \ + opt_name += 1; \ + if (opt_name > 1) { \ + nfacct_perror(msg); \ + return -1; \ + } + enum { NFACCT_CMD_NONE = 0, NFACCT_CMD_LIST, @@ -166,6 +173,8 @@ err: return MNL_CB_OK; } +#define NFACCT_F_QUOTAS (NFACCT_F_QUOTA_BYTES | NFACCT_F_QUOTA_PKTS) + static int nfacct_cmd_list(int argc, char *argv[]) { bool zeroctr = false, xml = false; @@ -177,8 +186,14 @@ static int nfacct_cmd_list(int argc, char *argv[]) for (i=2; i<argc; i++) { if (strncmp(argv[i], "reset", strlen(argv[i])) == 0) { + static int opt_reset; + CHECK_OPT_PLURARITY(opt_reset, "reset couldn't be " + "defined more than once"); zeroctr = true; } else if (strncmp(argv[i], "xml", strlen(argv[i])) == 0) { + static int opt_xml; + CHECK_OPT_PLURARITY(opt_xml, "xml couldn't be defined " + "more than once"); xml = true; } else { nfacct_perror("unknown argument"); @@ -191,7 +206,6 @@ static int nfacct_cmd_list(int argc, char *argv[]) NFNL_MSG_ACCT_GET_CTRZERO : NFNL_MSG_ACCT_GET, NLM_F_DUMP, seq); - nl = mnl_socket_open(NETLINK_NETFILTER); if (nl == NULL) { nfacct_perror("mnl_socket_open"); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html