Skip to contentSkip to conversation

libnetfilter_conntrack endian issue

PATCH Applied Albert Veli 2 participants 2 messages Jul 29, 2008 netfilter

lore
Share & tools
lore
#0 lore raw

Hi!

I run contrack-tools on a big-endian arm machine and had a problem:

$ conntrack -L
conntrack v0.9.7: Operation failed: Address family not supported by protocol

The problem was in libnetfilter_conntrack-0.0.96/src/conntrack/api.c. See attached endian.patch. In nfct_build_query() the *data argument is converted into a u_int8_t*. This works for little-endian but not for big-endian. The fix is a one-liner. Replace

const u_int8_t *family = data;

with

const u_int32_t *family = data;

After the patch it works:

$ conntrack -L
conntrack v0.9.7: 0 flow entries has been shown.

I also tested the patch on my little-endian laptop and it doesn't seem to cause any regression there. Just wanted to let you guys know.

Best regards,

Albert

src/conntrack/api.c +1 -1
diff -urN libnetfilter_conntrack-0.0.96-org/src/conntrack/api.c libnetfilter_conntrack-0.0.96/src/conntrack/api.c
@@ -455,7 +455,7 @@
 		     unsigned int size)
 {
 	struct nfnlhdr *req = buffer;
-	const u_int8_t *family = data;
+	const u_int32_t *family = data;
 
 	assert(ssh != NULL);
 	assert(data != NULL);
maintainer Applied
#1 lore raw
Quoted 18 lines · Albert Veli

Hi!

I run contrack-tools on a big-endian arm machine and had a problem:

$ conntrack -L
conntrack v0.9.7: Operation failed: Address family not supported by protocol

The problem was in libnetfilter_conntrack-0.0.96/src/conntrack/api.c. See attached endian.patch. In nfct_build_query() the *data argument is converted into a u_int8_t*. This works for little-endian but not for big-endian. The fix is a one-liner. Replace

const u_int8_t *family = data;

with

const u_int32_t *family = data;

Quoted 7 lines

After the patch it works:

$ conntrack -L
conntrack v0.9.7: 0 flow entries has been shown.

I also tested the patch on my little-endian laptop and it doesn't seem to cause any regression there. Just wanted to let you guys know.

Applied. Thanks Albert.

Signature · 1 line
"Los honestos son inadaptados sociales" -- Les Luthiers