Skip to contentSkip to conversation

Libnetfilter_conntrack problems

PATCH In review Sébastien LAVEZE 5 participants 16 messages Apr 27, 2006 – May 16, 2006 netfilter

lore
Share & tools
lore
#0 lore raw

Hi,
I'm developping an application using the libnetfilter_conntrack I'm using a 2.16.1 kernel and all libraries compiled with SVN sources.

1) I'm trying to get the events relatives to the destruction of conntracks It works fine for update events ==>nfct_open(CONNTRACK, NF_NETLINK_CONNTRACK_UPDATE)
but not for destroy ==> nfct_open(CONNTRACK, NF_NETLINK_CONNTRACK_DESTROY), i never get any event

2) I also would like to work with ids, when i get a conntrack via a callback the id field is always set to zero, is it normal ?

Thanks
Sebastien

#1 lore raw
Quoted 2 lines · Sébastien LAVEZE

but not for destroy ==> nfct_open(CONNTRACK, NF_NETLINK_CONNTRACK_DESTROY), i never get any event

are you sure? did you wait until the respective entries really timed out from the conntrack table?

what does 'conntrack -E -e DESTROY' say? do you then see the events?

Quoted 2 lines

2) I also would like to work with ids, when i get a conntrack via a callback the id field is always set to zero, is it normal ?

IIRC, we dropped ID's recently. I'm a bit lagging behind, though.

Signature · 5 lines
- Harald Welte <[email protected]>                 http://netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie
#2 lore raw

OK
I was trying to have multiple handles in different threads and it was working only for the first created thread. I change my application in a multi-process one and all seems to work fine
However the DESTROY events come a long time after the actual end of a connection by timeout...am I right ?

Thanks
Sebastian

Quoted 23 lines · Harald Welte
Quoted 2 lines · Sébastien LAVEZE

but not for destroy ==> nfct_open(CONNTRACK, NF_NETLINK_CONNTRACK_DESTROY), i never get any event

are you sure? did you wait until the respective entries really timed out from the conntrack table?

what does 'conntrack -E -e DESTROY' say? do you then see the events?

Quoted 2 lines

2) I also would like to work with ids, when i get a conntrack via a callback the id field is always set to zero, is it normal ?

IIRC, we dropped ID's recently. I'm a bit lagging behind, though.

--
- Harald Welte <[email protected]> http://netfilter.org/
============================================================================
"Fragmentation is like classful addressing -- an interesting early
architectural error that shows how much experimentation was going
on while IP was being designed." -- Paul Vixie

#3 lore raw
Quoted 4 lines · Sébastien LAVEZE

OK
I was trying to have multiple handles in different threads and it was working only for the first created thread. I change my application in a multi-process one and all seems to work fine

The libraries are not thread safe at all, and there was never any work to make them so. I personally (like many other netfilter developers, I believe) never use threads in my programs, so it's unlikely that we'd be working on that. patches are welcome, though.

Quoted 2 lines

However the DESTROY events come a long time after the actual end of a connection by timeout...am I right ?

not really. please be more specific. what is 'end of a connection by timeout'? which specific timeout of which particular state are you talking about?

Signature · 5 lines
- Harald Welte <[email protected]>                 http://netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie
#4 lore raw

Hi,

Quoted 6 lines
Quoted 2 lines

However the DESTROY events come a long time after the actual end of a connection by timeout...am I right ?

not really. please be more specific. what is 'end of a connection by timeout'? which specific timeout of which particular state are you talking about?

My problem is pretty strange...
I got two processes, one has a callback registered to UPDATE events, the other one has a callback registered to DESTROY event

I do get destroy events but not all the time, when i have tcp connections that go from ESTABLISHED state to FIN_WAIT and finally to TIME_WAIT ( i see the progression of these states with the process linked to UPDATE events ) But when the TIME_WAIT timer is over i do not get the DESTROY event...

Thanks
Sebastien
These connections are forwarded connections and have NAT process Otherwise it works great for UDP connections

#5 lore raw

Hi,

Quoted 12 lines · Sébastien LAVEZE
Quoted 6 lines
Quoted 2 lines

However the DESTROY events come a long time after the actual end of a connection by timeout...am I right ?

not really. please be more specific. what is 'end of a connection by timeout'? which specific timeout of which particular state are you talking about?

My problem is pretty strange...
I got two processes, one has a callback registered to UPDATE events, the other one has a callback registered to DESTROY event

Quoted 5 lines

I do get destroy events but not all the time, when i have tcp connections that go from ESTABLISHED state to FIN_WAIT and finally to TIME_WAIT ( i see the progression of these states with the process linked to UPDATE events ) But when the TIME_WAIT timer is over i do not get the DESTROY event...

Could you try to do the same thing with the conntrack tool and let us know if the problem still persists?

to catch update events

# conntrack -E -e UPDATE

to catch destroy events

# conntrack -E -e DESTROY
Signature · 1 line
Pablo
#6 lore raw

Hi,
I have problem using the conntrack utility...
It always display the help message and i get the message conntrack v1.00beta2: Missing arguments...
I'm using the latest SVN version of libnetfilet_conntrack, libnfnetlink and conntrack and I'm using a 2.6.16.1 kernel on an ARM platform

Sebastien

Quoted 33 lines · Pablo Neira Ayuso

Hi,

Quoted 12 lines · Sébastien LAVEZE
Quoted 6 lines
Quoted 2 lines

However the DESTROY events come a long time after the actual end of a connection by timeout...am I right ?

not really. please be more specific. what is 'end of a connection by timeout'? which specific timeout of which particular state are you talking about?

My problem is pretty strange...
I got two processes, one has a callback registered to UPDATE events, the other one has a callback registered to DESTROY event

Quoted 5 lines

I do get destroy events but not all the time, when i have tcp connections that go from ESTABLISHED state to FIN_WAIT and finally to TIME_WAIT ( i see the progression of these states with the process linked to UPDATE events ) But when the TIME_WAIT timer is over i do not get the DESTROY event...

Could you try to do the same thing with the conntrack tool and let us know if the problem still persists?

to catch update events

# conntrack -E -e UPDATE

to catch destroy events

# conntrack -E -e DESTROY

--
Pablo

#7 lore raw

I guess the problem is having two event handles on two different processes and this might cause some strange behaviour. (I also have destroy events that come 5 mn after the expiration of the TIME_WAIT timer...)
Has someone ever tried that ??
Maybe it should be safer to have only one process listening to ALL events and then to dispatch them..
Is there a way to make the difference between UPDATE and DESTROY events with a single callback listening to ALL different ?? (type field maybe ?)

Thanks
Sebastian

#8 lore raw

Hi,
I applied the patch that fixes ARM parsing problem
Now the conntrack utility works !
I'm tracking forwarded connection (my system does nat and forwarding) Here are the results i get with the conntrack utility

conntrack -E -e UPDATE (it works fine)

[UPDATE] tcp 6 60 SYN_RECV src=192.168.32.42 dst=172.16.16.16 sport=48004
dport=21 src=172.16.16.16 dst=192.168.31.39 sport=21 dport=48004
[UPDATE] tcp 6 432000 ESTABLISHED src=192.168.32.42 dst=172.16.16.16 sport
=48004 dport=21 src=172.16.16.16 dst=192.168.31.39 sport=21 dport=48004 [ASSURED]
[UPDATE] tcp 6 120 FIN_WAIT src=192.168.32.42 dst=172.16.16.16 sport=48004
dport=21 src=172.16.16.16 dst=192.168.31.39 sport=21 dport=48004
[UPDATE] tcp 6 60 CLOSE_WAIT src=192.168.32.42 dst=172.16.16.16 sport=4800
4 dport=21 src=172.16.16.16 dst=192.168.31.39 sport=21 dport=48004
[UPDATE] tcp 6 30 LAST_ACK src=192.168.32.42 dst=172.16.16.16 sport=48004
dport=21 src=172.16.16.16 dst=192.168.31.39 sport=21 dport=48004
[UPDATE] tcp 6 120 TIME_WAIT src=192.168.32.42 dst=172.16.16.16 sport=4800
4 dport=21 src=172.16.16.16 dst=192.168.31.39 sport=21 dport=48004

But if i do conntrack -E -e DESTROY
I never get any events for the same connection as i did with the UPDATE events

So apparently there is no problem to use multiple callbacks in different processes but there is a problem with DESTROY events for TCP connections

For my application it's fine as now i'm working with connections states instead of waiting for destroy events

If you want me to do more tests I'm ok with that.

Thanks

Sebastien

Quoted 14 lines · Sébastien LAVEZE

I guess the problem is having two event handles on two different processes and this might cause some strange behaviour. (I also have destroy events that come 5 mn after the expiration of the TIME_WAIT timer...)
Has someone ever tried that ??
Maybe it should be safer to have only one process listening to ALL events and then to dispatch them..
Is there a way to make the difference between UPDATE and DESTROY events with a single callback listening to ALL different ?? (type field maybe ?)

Thanks
Sebastian

#9 lore raw
Quoted 2 lines · Sébastien LAVEZE

But if i do conntrack -E -e DESTROY
I never get any events for the same connection as i did with the UPDATE events

It's working for me using 2.6.16 on ARM and userspace from SVN. Are you sure you are waiting 2 minutes for the timeout? How about if you try pings?

#10 lore raw
Quoted 3 lines

It's working for me using 2.6.16 on ARM and userspace from SVN. Are you sure you are waiting 2 minutes for the timeout? How about if you try pings?

Ok
I'm also using 2.6.16 kernel with latest SVN
It works fine for LOCAL connection but not for FORWARDED connections I do get UPDATE events for forwarded connection but there are no DESTROY events for forwarded connections
Same stuff for pings (OK for local, NO for forward)

#11 lore raw
Quoted 10 lines · Sébastien LAVEZE
Quoted 3 lines

It's working for me using 2.6.16 on ARM and userspace from SVN. Are you sure you are waiting 2 minutes for the timeout? How about if you try pings?

Ok
I'm also using 2.6.16 kernel with latest SVN
It works fine for LOCAL connection but not for FORWARDED connections I do get UPDATE events for forwarded connection but there are no DESTROY events for forwarded connections
Same stuff for pings (OK for local, NO for forward)

Weird. I had problems with hardware lately, I had some time to set up some UML stuff last night, I'll be having a look at this.

Please, could you pass me as much information as you can in order to reproduce the problem? Thanks.

Signature · 1 line
Pablo
#12 lore raw

PATCH 1/1 conntrack: Fix option parsing for ARM

In reply to Sébastien LAVEZE
Quoted 3 lines · Sébastien LAVEZE

I have problem using the conntrack utility... It always display the help message and i get the message conntrack v1.00beta2: Missing arguments...

The result of getopt_long() was assigned to a char, which defaults to unsigned on ARM, so the comparison against -1 always failed.

src/conntrack.c +1 -1
Index: conntrack/src/conntrack.c
===================================================================
@@ -602,7 +602,7 @@
 
 int main(int argc, char *argv[])
 {
-	char c;
+	int c;
 	unsigned int command = 0, options = 0;
 	unsigned int type = 0, event_mask = 0;
 	unsigned int l3flags = 0, l4flags = 0, metaflags = 0;
#13 lore raw

Re: [PATCH] conntrack: Fix option parsing for ARM

Quoted 10 lines · Philip Craig
Quoted 3 lines · Sébastien LAVEZE

I have problem using the conntrack utility... It always display the help message and i get the message conntrack v1.00beta2: Missing arguments...

The result of getopt_long() was assigned to a char, which defaults to unsigned on ARM, so the comparison against -1 always failed.

Thanks for tracking this down Philip. I'm having trouble using SVN again .. Pablo, can you try to commit this please?

#14 lore raw

Re: [PATCH] conntrack: Fix option parsing for ARM

Quoted 10 lines · Patrick McHardy
Quoted 8 lines · Philip Craig
Quoted 3 lines · Sébastien LAVEZE

I have problem using the conntrack utility... It always display the help message and i get the message conntrack v1.00beta2: Missing arguments...

Quoted 6 lines
Quoted 3 lines

The result of getopt_long() was assigned to a char, which defaults to unsigned on ARM, so the comparison against -1 always failed.

Thanks for tracking this down Philip. I'm having trouble using SVN again .. Pablo, can you try to commit this please?

I'd like to but I can't, it seems that my x509 certificate expired on Apr 16:

Issuer: C=DE, ST=Bayern, L=Erlangen, O=gnumonks.org, CN=Harald
Welte/[email protected]

        Validity
            Not Before: Apr 16 16:55:23 2005 GMT
            Not After : Apr 16 16:55:23 2006 GMT
        Subject: C=DE, ST=Berlin, L=Berlin, O=Netfilter Project, 

OU=Development, CN=pablo/[email protected]

I need a renewal, could you tell to Harald about this?

Signature · 1 line
Pablo
#15 lore raw

Re: [PATCH] conntrack: Fix option parsing for ARM

Quoted 9 lines · Pablo Neira Ayuso
Quoted 2 lines

Thanks for tracking this down Philip. I'm having trouble using SVN again .. Pablo, can you try to commit this please?

I'd like to but I can't, it seems that my x509 certificate expired on Apr 16:

Issuer: C=DE, ST=Bayern, L=Erlangen, O=gnumonks.org, CN=Harald
Welte/[email protected]

Quoted 7 lines
        Validity
            Not Before: Apr 16 16:55:23 2005 GMT
            Not After : Apr 16 16:55:23 2006 GMT
        Subject: C=DE, ST=Berlin, L=Berlin, O=Netfilter Project,

OU=Development, CN=pablo/[email protected]

I need a renewal, could you tell to Harald about this?

I've CCed him. My certificate is still valid, but I'm getting this error:

svn: Commit failed (details follow):
svn: The CHECKOUT response did not contain a 'Location:' header
svn: Your commit message was left in a temporary file: