* [PATCH] libnetfilter_conntrack: Packet/byte counters are 64 bit
@ 2007-08-14 7:19 Philip Craig
2007-09-02 8:55 ` Pablo Neira Ayuso
0 siblings, 1 reply; 3+ messages in thread
From: Philip Craig @ 2007-08-14 7:19 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: Netfilter Developer Mailing List
[-- Attachment #1: libnfct-counter64.patch --]
[-- Type: text/x-diff, Size: 3298 bytes --]
The counters in struct nf_conntrack are 64 bit, so the getter/setter
have to access them as such.
Signed-off-by: Philip Craig <philipc@snapgear.com>
Index: libnetfilter_conntrack/src/conntrack/api.c
===================================================================
--- libnetfilter_conntrack.orig/src/conntrack/api.c 2007-08-14 16:00:51.000000000 +1000
+++ libnetfilter_conntrack/src/conntrack/api.c 2007-08-14 16:04:21.000000000 +1000
@@ -267,6 +267,19 @@
}
/**
+ * nfct_set_attr_u64 - set the value of a certain conntrack attribute
+ * @ct: pointer to a valid conntrack
+ * @type: attribute type
+ * @value: unsigned 64 bits attribute value
+ */
+void nfct_set_attr_u64(struct nf_conntrack *ct,
+ const enum nf_conntrack_attr type,
+ u_int64_t value)
+{
+ nfct_set_attr(ct, type, &value);
+}
+
+/**
* nfct_get_attr - get a conntrack attribute
* ct: pointer to a valid conntrack
* @type: attribute type
@@ -341,6 +354,22 @@
}
/**
+ * nfct_get_attr_u64 - get attribute of unsigned 64-bits long
+ * @ct: pointer to a valid conntrack
+ * @type: attribute type
+ *
+ * Returns the value of the requested attribute, if the attribute is not
+ * set, 0 is returned. In order to check if the attribute is set or not,
+ * use nfct_attr_is_set.
+ */
+u_int64_t nfct_get_attr_u64(const struct nf_conntrack *ct,
+ const enum nf_conntrack_attr type)
+{
+ const u_int64_t *ret = nfct_get_attr(ct, type);
+ return ret == NULL ? 0 : *ret;
+}
+
+/**
* nfct_attr_is_set - check if a certain attribute is set
* @ct: pointer to a valid conntrack object
* @type: attribute type
Index: libnetfilter_conntrack/include/libnetfilter_conntrack/libnetfilter_conntrack.h
===================================================================
--- libnetfilter_conntrack.orig/include/libnetfilter_conntrack/libnetfilter_conntrack.h 2007-08-14 16:03:14.000000000 +1000
+++ libnetfilter_conntrack/include/libnetfilter_conntrack/libnetfilter_conntrack.h 2007-08-14 16:03:32.000000000 +1000
@@ -91,10 +91,10 @@
ATTR_DNAT_PORT, /* u16 bits */
ATTR_TIMEOUT = 24, /* u32 bits */
ATTR_MARK, /* u32 bits */
- ATTR_ORIG_COUNTER_PACKETS, /* u32 bits */
- ATTR_REPL_COUNTER_PACKETS, /* u32 bits */
- ATTR_ORIG_COUNTER_BYTES = 28, /* u32 bits */
- ATTR_REPL_COUNTER_BYTES, /* u32 bits */
+ ATTR_ORIG_COUNTER_PACKETS, /* u64 bits */
+ ATTR_REPL_COUNTER_PACKETS, /* u64 bits */
+ ATTR_ORIG_COUNTER_BYTES = 28, /* u64 bits */
+ ATTR_REPL_COUNTER_BYTES, /* u64 bits */
ATTR_USE, /* u32 bits */
ATTR_ID, /* u32 bits */
ATTR_STATUS = 32, /* u32 bits */
@@ -194,6 +194,10 @@
const enum nf_conntrack_attr type,
u_int32_t value);
+extern void nfct_set_attr_u64(struct nf_conntrack *ct,
+ const enum nf_conntrack_attr type,
+ u_int64_t value);
+
/* getter */
extern const void *nfct_get_attr(const struct nf_conntrack *ct,
const enum nf_conntrack_attr type);
@@ -207,6 +211,9 @@
extern u_int32_t nfct_get_attr_u32(const struct nf_conntrack *ct,
const enum nf_conntrack_attr type);
+extern u_int64_t nfct_get_attr_u64(const struct nf_conntrack *ct,
+ const enum nf_conntrack_attr type);
+
/* checker */
extern int nfct_attr_is_set(const struct nf_conntrack *ct,
const enum nf_conntrack_attr type);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] libnetfilter_conntrack: Packet/byte counters are 64 bit
2007-08-14 7:19 [PATCH] libnetfilter_conntrack: Packet/byte counters are 64 bit Philip Craig
@ 2007-09-02 8:55 ` Pablo Neira Ayuso
2007-09-03 0:20 ` Philip Craig
0 siblings, 1 reply; 3+ messages in thread
From: Pablo Neira Ayuso @ 2007-09-02 8:55 UTC (permalink / raw)
To: Philip Craig; +Cc: Netfilter Developer Mailing List
Philip Craig wrote:
> The counters in struct nf_conntrack are 64 bit, so the getter/setter
> have to access them as such.
Still my kernel has 32 bit counters although I know that there was a
patch on the table to recover 64 bits counters. I'm still getting in
sync with the development again, did that patch finally hit mainline?
--
"Será preciso viajar por los ojos de los idiotas" -- Poeta en Nueva York
-- Federico García Lorca.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] libnetfilter_conntrack: Packet/byte counters are 64 bit
2007-09-02 8:55 ` Pablo Neira Ayuso
@ 2007-09-03 0:20 ` Philip Craig
0 siblings, 0 replies; 3+ messages in thread
From: Philip Craig @ 2007-09-03 0:20 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: Netfilter Developer Mailing List
Pablo Neira Ayuso wrote:
> Philip Craig wrote:
>> The counters in struct nf_conntrack are 64 bit, so the getter/setter
>> have to access them as such.
>
> Still my kernel has 32 bit counters although I know that there was a
> patch on the table to recover 64 bits counters. I'm still getting in
> sync with the development again, did that patch finally hit mainline?
The kernel still sends 32 bit from what I can see, but this is problem
independent of what the kernel sends. The library handles receiving both
32 and 64 bit counters from the kernel, and stores them in a 64 bit
field in a structure. The getter/setter then access that field, but that
doesn't work if they access only 32 bits of it, at least for big endian.
An alternative fix is to change the nf_conntrack field to 32 bit,
but I would only do that if you never intend for the kernel to send
64 bit counters.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-09-03 0:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-14 7:19 [PATCH] libnetfilter_conntrack: Packet/byte counters are 64 bit Philip Craig
2007-09-02 8:55 ` Pablo Neira Ayuso
2007-09-03 0:20 ` Philip Craig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).