Skip to contentSkip to conversation

Fix packets and bytes inversion.

PATCH Applied Eric Leblond 1 participant 2 messages Dec 26, 2012 – Dec 27, 2012 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix packets and bytes inversion.

Pkts and bytes are inversed in some part of the code. This patch fixes most of the occurence of this problem.

---
 src/libnetfilter_acct.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
src/libnetfilter_acct.c +5 -5
index 6a3a839..0abaeac 100644
@@ -106,11 +106,11 @@ nfacct_attr_set(struct nfacct *nfacct, enum nfacct_attr_type type,
 		nfacct->bitset |= (1 << NFACCT_ATTR_NAME);
 		break;
 	case NFACCT_ATTR_PKTS:
-		nfacct->bytes = *((uint64_t *) data);
+		nfacct->pkts = *((uint64_t *) data);
 		nfacct->bitset |= (1 << NFACCT_ATTR_PKTS);
 		break;
 	case NFACCT_ATTR_BYTES:
-		nfacct->pkts = *((uint64_t *) data);
+		nfacct->bytes = *((uint64_t *) data);
 		nfacct->bitset |= (1 << NFACCT_ATTR_BYTES);
 		break;
 	}
@@ -237,9 +237,9 @@ nfacct_snprintf_plain(char *buf, size_t rem, struct nfacct *nfacct,
 		ret = snprintf(buf, rem,
 			"{ pkts = %.20llu, bytes = %.20llu } = %s;",
 			(unsigned long long)
-			nfacct_attr_get_u64(nfacct, NFACCT_ATTR_BYTES),
-			(unsigned long long)
 			nfacct_attr_get_u64(nfacct, NFACCT_ATTR_PKTS),
+			(unsigned long long)
+			nfacct_attr_get_u64(nfacct, NFACCT_ATTR_BYTES),
 			nfacct_attr_get_str(nfacct, NFACCT_ATTR_NAME));
 	} else {
 		ret = snprintf(buf, rem, "%s\n",
@@ -426,7 +426,7 @@ void nfacct_nlmsg_build_payload(struct nlmsghdr *nlh, struct nfacct *nfacct)
 		mnl_attr_put_u64(nlh, NFACCT_PKTS, htobe64(nfacct->pkts));
 
 	if (nfacct->bitset & (1 << NFACCT_ATTR_BYTES))
-		mnl_attr_put_u64(nlh, NFACCT_PKTS, htobe64(nfacct->bytes));
+		mnl_attr_put_u64(nlh, NFACCT_BYTES, htobe64(nfacct->bytes));
 }
 EXPORT_SYMBOL(nfacct_nlmsg_build_payload);
 
Signature · 1 line
1.7.10.4
author Applied
#1 lore raw

Hi,

Quoted 7 lines · Eric Leblond

Pkts and bytes are inversed in some part of the code. This patch fixes most of the occurence of this problem.

---
 src/libnetfilter_acct.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Pushed to Netfilter's git.

BR,

Signature · 2 lines
Eric Leblond <[email protected]>
Blog: https://home.regit.org/