Skip to contentSkip to conversation

conntrack -E -i not allowed?

DISCUSSION Alan Ezust 2 participants 8 messages Nov 1, 2006 – Nov 9, 2006

lore
Share & tools
lore

Alan Ezust

author
#0 lore raw

I'm trying to get conntrack -E to show me events, with conntrack IDs. At the moment, the ctid is now showing up in the output unless there is an [UNREPLIED] part to the line.

$ conntrack -E -i
conntrack v1.00beta2: Illegal option `-i' with this command

[NEW] udp 17 30 src=10.10.100.100 dst=204.174.64.1 sport=4536 dport=53
packets=1 bytes=67 [UNREPLIED] src=204.174.64.1 dst=10.10.100.100 sport=53 dport=4536 packets=0 bytes=0

Is there a trick to getting the ctids to be sent to the output of this?

conntrack -L -i seems to work, showing me the id. Personally, I think conntrack should always output the id.

author
#1 lore raw

Conntrack uses the following structures, but there is no documentation about what these structures are for, or where they are used:

// nf_conntrack.h (kernel headers)
struct nf_conn - for the *data member, what kind of structures get stored there?

nf_conntrack_tuple, nf_conntrack_expect

// nf_conntrack_tuple.h
nf_conntrack_tuple_hash - a linked list of tuples? Where is the code that inserts/removes elements from this hash?

nf_conntrack_tuple - this contains the information to distingusih a connection - is this the main structure? What is its relationship to the nfct_tuple?

// libnetfilter_conntrack.h:31
nfct_handle - /* Harald says: "better for encapsulation" ;) */ This comment is not helpful, just annoying. I'd like to see a proper description of this structure and a short line or two summarizing where/why it is used. is this for a single connection, or the conntrack system?

nfct_conntrack - seems to be the main structure used by
libnfnetlink The array of tuples is used to store table data (?)

Other types i'd like to see proper API docs for:
nfct_tuple
nfct_callback

Anyway, the reason I am delving into this code now is that I am trying patch conntrack so that when you do conntrack -E -i, it gives you the ctid in the output lines.

I ran conntrack in a debugger and it keeps bringing me into the nfnl_parse_attr method via libnetfilter_conntrack.c line 526.

Debugging it, and inspecting the "nfa" structure,
It seems to be an array of struct nfattr objects.
These nfattr structs have 2 fields, a length and a type.
It describes, I assume, which fields need to be extracted from the tuplehash.

This nfa structure is extracted from the struct nlmsghdr which was passed to nfct_conntrack_netlink_handler. So this struct doesn't contain the right information in it to tell parse_attr to to put a ctid record into its tb.

All this is called indirectly from nfnl_listen, which gets the nlmsghdr from callback_handler, which gets it from nfct_conntrack_netlink_handler. But my debugger isn't showing me where that function was called from (perhaps because it's coming from the kernel?)

So I think my question is, where is that struct nlmsghdr created that is being passed to the nfct_conntrack_netlink_handler, and where would be the right place to add an element to it so that there is a ctid. If that was done, would that be sufficient to get the ctid into the logline, or is there more to it than that?

Gads, tracing through this code gives me a headache.

Quoted 15 lines · Alan Ezust

I'm trying to get conntrack -E to show me events, with conntrack IDs. At the moment, the ctid is not showing up in the output.

$ conntrack -E -i
conntrack v1.00beta2: Illegal option `-i' with this command
   [NEW] udp      17 30 src=10.10.100.100 dst=204.174.64.1 sport=4536

dport=53 packets=1 bytes=67 [UNREPLIED] src=204.174.64.1 dst=10.10.100.100 sport=53 dport=4536 packets=0 bytes=0

Is there a trick to getting the ctids to be sent to the output of this?

conntrack -L -i seems to work, showing me the id. Personally, I think conntrack should always output the id.

Signature · 3 lines
Alan Ezust            www.presinet.com
Presinet, inc         [email protected]
           Victoria, BC,Canada
#2 lore raw
Quoted 1 line · Alan Ezust
Quoted 1 line

Is there a trick to getting the ctids to be sent to the output of this?

There is not.

Quoted 2 lines
Quoted 2 lines

conntrack -L -i seems to work, showing me the id. Personally, I think conntrack should always output the id.

No, actually we have plans to remove it soon. Why do you need the id?

Signature · 2 lines
The dawn of the fourth age of Linux firewalling is coming; a time of
great struggle and heroic deeds -- J.Kadlecsik got inspired by J.Morris
author
#3 lore raw

We need to be able to determine when we get an UPDATE or a DISCONNECT, which connections they correspond to. I assumed that was the purpose of the CT id. Why are you removing it?

Quoted 9 lines · Pablo Neira Ayuso
Quoted 1 line · Alan Ezust
Quoted 1 line

Is there a trick to getting the ctids to be sent to the output of this?

There is not.

Quoted 2 lines
Quoted 2 lines

conntrack -L -i seems to work, showing me the id. Personally, I think conntrack should always output the id.

No, actually we have plans to remove it soon. Why do you need the id?

Signature · 3 lines
Alan Ezust            www.presinet.com
Presinet, inc         [email protected]
           Victoria, BC,Canada
#4 lore raw
Quoted 1 line · Alan Ezust

We need to be able to determine when we get an UPDATE or a DISCONNECT, which connections they correspond to. I assumed that was the purpose of the CT id.

The purpose was to uniquely identify a connection but we currenlty assume that the tuple {src, portsrc, dst, portdst, l3protonum, protonum} is enough.

Quoted 1 line

Why are you removing it?

http://lists.netfilter.org/pipermail/netfilter-devel/2005-June/019923.html

Signature · 1 line
The dawn of the fourth age of Linux firewalling is coming; a time of great struggle and heroic deeds -- J.Kadlecsik got inspired by J.Morris
author
#5 lore raw

Thanks for the reply. Ok, I can see how I can generate some IDs, but I first want to make sure i have all of the information I need.

When I run conntrack, I only see one protocol number. I think it is a layer4 protocol (tcp vs udp). If I'm not seeing an l3proto in my output, why might that be?

udp 17 12 src=10.10.201.2 dst=204.174.64.1 sport=54475 dport=53
src=204.174.64.1 dst=209.53.156.2 sport=53 dport=54475 use=1 mark=0
tcp 6 420332 ESTABLISHED src=10.10.100.3 dst=10.10.1.22 sport=1356
dport=5432 src=10.10.1.22 dst=10.10.100.3 sport=5432 dport=1356 [ASSURED] use=1 mark=0

Quoted 12 lines · Pablo Neira Ayuso
Quoted 3 lines · Alan Ezust

We need to be able to determine when we get an UPDATE or a DISCONNECT, which connections they correspond to. I assumed that was the purpose of the CT id.

The purpose was to uniquely identify a connection but we currenlty assume that the tuple {src, portsrc, dst, portdst, l3protonum, protonum} is enough.

Quoted 1 line

Why are you removing it?

http://lists.netfilter.org/pipermail/netfilter-devel/2005-June/019923.html

Signature · 3 lines
Alan Ezust            www.presinet.com
Presinet, inc         [email protected]
           Victoria, BC,Canada
#6 lore raw
Quoted 7 lines · Alan Ezust

Thanks for the reply. Ok, I can see how I can generate some IDs, but I first want to make sure i have all of the information I need.

When I run conntrack, I only see one protocol number. I think it is a layer4 protocol (tcp vs udp). If I'm not seeing an l3proto in my output, why might that be?

Quoted 5 lines

udp 17 12 src=10.10.201.2 dst=204.174.64.1 sport=54475 dport=53
src=204.174.64.1 dst=209.53.156.2 sport=53 dport=54475 use=1 mark=0
tcp 6 420332 ESTABLISHED src=10.10.100.3 dst=10.10.1.22 sport=1356
dport=5432 src=10.10.1.22 dst=10.10.100.3 sport=5432 dport=1356 [ASSURED] use=1 mark=0

Are you using nf_conntrack? If so, l3protonum is not shown yet but it would not be hard to cook a patch to show it. I'll introduce this change in the new libnetfilter_conntrack API.

Signature · 2 lines
The dawn of the fourth age of Linux firewalling is coming; a time of
great struggle and heroic deeds -- J.Kadlecsik got inspired by J.Morris
author
#7 lore raw

Yes, I'm using svn checked out versions of your libnfnetlink and libnetfilter_conntrack, so let me know when you check in your changes and I'll update. Thanks ! --alan

Quoted 17 lines · Pablo Neira Ayuso
Quoted 7 lines · Alan Ezust

Thanks for the reply. Ok, I can see how I can generate some IDs, but I first want to make sure i have all of the information I need.

When I run conntrack, I only see one protocol number. I think it is a layer4 protocol (tcp vs udp). If I'm not seeing an l3proto in my output, why might that be?

Quoted 5 lines

udp 17 12 src=10.10.201.2 dst=204.174.64.1 sport=54475 dport=53
src=204.174.64.1 dst=209.53.156.2 sport=53 dport=54475 use=1 mark=0
tcp 6 420332 ESTABLISHED src=10.10.100.3 dst=10.10.1.22 sport=1356
dport=5432 src=10.10.1.22 dst=10.10.100.3 sport=5432 dport=1356 [ASSURED] use=1 mark=0

Are you using nf_conntrack? If so, l3protonum is not shown yet but it would not be hard to cook a patch to show it. I'll introduce this change in the new libnetfilter_conntrack API.

Signature · 3 lines
Alan Ezust            www.presinet.com
Presinet, inc         [email protected]
           Victoria, BC,Canada