[PATCH] Fix overquota output result

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Current implementation shows "packet" for none byte quota type.
It means "packet" was used for overquota counter as well and it
wasn't so informative.

Signed-off-by: Alexey Perevalov <a.perevalov@xxxxxxxxxxx>
---
 src/libnetfilter_acct.c |   22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/libnetfilter_acct.c b/src/libnetfilter_acct.c
index 7f539b6..9ed50c9 100644
--- a/src/libnetfilter_acct.c
+++ b/src/libnetfilter_acct.c
@@ -266,15 +266,23 @@ nfacct_snprintf_plain(char *buf, size_t rem, struct nfacct *nfacct,
 		SNPRINTF_CHECK(ret, rem, offset, len);
 
 		if (nfacct->flags) {
-			uint32_t mode;
-
-			mode = nfacct_attr_get_u64(nfacct, NFACCT_ATTR_FLAGS);
-
+			const uint32_t mode = nfacct_attr_get_u64(nfacct,
+				NFACCT_ATTR_FLAGS);
+			char *mode_name = NULL, *overquota = NULL;
+			printf("mode %u", mode);
+			if (mode & NFACCT_F_QUOTA_PKTS)
+				mode_name = "packet";
+			else if (mode & NFACCT_F_QUOTA_BYTES)
+				mode_name = "byte";
+
+			if (mode & NFACCT_F_OVERQUOTA)
+				overquota = " overquota";
+			else
+				overquota = "";
 			ret = snprintf(buf + offset, rem,
-				", quota = %.20"PRIu64", mode = %s",
+				", quota = %.20"PRIu64", mode = %s%s",
 				nfacct_attr_get_u64(nfacct, NFACCT_ATTR_QUOTA),
-				mode == NFACCT_F_QUOTA_BYTES ?
-				"byte" : "packet");
+				mode_name, overquota);
 			SNPRINTF_CHECK(ret, rem, offset, len);
 		}
 
-- 
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




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux