Skip to contentSkip to conversation

Patch: add id to libnetfilter_conntrack XML export

PATCH Victor Stinner 3 participants 4 messages Jan 5, 2007 – Jan 11, 2007 1 message not in the archive netfilter

lore
Share & tools
lore
#0 lore raw

Hi,

I heard that connection identifiers may disappear. Is it true? I like unique identifier because it's small (only 32 bits) and easy to manipulate. It's hard to identify a connection without such identifier.

I attached a patch to add connection identifier to XML export.

Victor Stinner
http://www.inl.fr/

conntrack/snprintf_xml.c +7 -0
Index: src/conntrack/snprintf_xml.c
===================================================================
@@ -364,6 +364,13 @@
 		buffer_size(ret, &size, &len);
 	}
 
+	if (test_bit(ATTR_ID, ct->set)) {
+		ret = snprintf(buf+size, len, "<id>%u</id>", ct->id);
+		if (ret == -1)
+			return -1;
+		buffer_size(ret, &size, &len);
+	}
+
 	if (test_bit(ATTR_MARK, ct->set)) {
 		ret = snprintf(buf+size, len, "<mark>%u</mark>", ct->mark);
 		if (ret == -1)
#1 lore raw
Quoted 3 lines · Victor Stinner

I heard that connection identifiers may disappear. Is it true? I like unique identifier because it's small (only 32 bits) and easy to manipulate. It's hard to identify a connection without such identifier.

Indeed, it's planned to get rid of the id. We resolved that the tuple src/dst/port-src/port-dst/l3protonum/l4protonum is enough to identify a conntrack.

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

Hi Victor,

Quoted 9 lines · Victor Stinner

Le Vendredi 5 Janvier 2007 15:45, vous avez écrit :

Quoted 7 lines
Quoted 3 lines · Victor Stinner

I heard that connection identifiers may disappear. Is it true? I like unique identifier because it's small (only 32 bits) and easy to manipulate. It's hard to identify a connection without such identifier.

Indeed, it's planned to get rid of the id. We resolved that the tuple src/dst/port-src/port-dst/l3protonum/l4protonum is enough to identify a conntrack.

Quoted 5 lines

Hum, what is your motivation to remove identifiers? I will be harder to identify a connection: parameters to identify it depends on the layer 3 and layer 4 protocols. (src, dst, port-src, port-dst, l3protonum, l4protonum) doesn't work with ICMP (arguments type and code) :-/ And what about IPv6? What about other layer3 protocols?

The 'id' is not enough to uniquely identify a flow since it can wrap
around: in a scenario with long-time flows, this can result in two flows with the same 'id'. The 'id' was introduced as a complement for the tuple since we weren't sure that the tuple was enough to identify a flow. After several discussions [1], we resolved that the tuple was enough.

For example, conntrackd uses the tuple and keeps the flows in a hash table, but a different abstract data type could be used (trees).

Quoted 2 lines

I'm working on pyctd and his PHP frontend. To kill a connection (or update a parameter like mark or (fixed) timeout), we just used his identifier.

Talking about pyctd, would you consider integrating this with conntrackd [2]? That daemon has a statistics mode that can still be improved a lot:
Third party apps can request information such as the whole conntrack table via UNIX sockets, this can be interesting in scenarios with heavily loaded firewall since this will not interrupt packet processing while dumping the conntrack table. Moreover, you can know the connection lifetime, ie. when did the flow was created, something that is not available in kernel space, and much more, for example, killing flows with masks, and other stuff that in kernel space could be overkill. Of course, this does not come without a price, per-connections counters are not available. However, I think that the information source (ctnetlink or conntrackd) for your statistics daemon could be a configurable parameter, the sysadmin could choose what to use depending on his setup. BTW, conntrackd doesn't output the flows in XML format yet, but with the new API that is fairly easy to be implemented.

[1]
http://lists.netfilter.org/pipermail/netfilter-devel/2006-March/023877.html
[2] http://people.netfilter.org/pablo/conntrackd/

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
#4 lore raw

* Pablo Neira Ayuso wrote, On 05/01/07 22:44:

Quoted 17 lines

Hi Victor,

Quoted 5 lines · Victor Stinner

Le Vendredi 5 Janvier 2007 15:45, vous avez écrit :

Quoted 4 lines
Quoted 3 lines · Victor Stinner

I heard that connection identifiers may disappear. Is it true? I like unique identifier because it's small (only 32 bits) and easy to manipulate. It's hard to identify a connection without such identifier.

Quoted 8 lines
Quoted 3 lines

Indeed, it's planned to get rid of the id. We resolved that the tuple src/dst/port-src/port-dst/l3protonum/l4protonum is enough to identify a conntrack.

Hum, what is your motivation to remove identifiers? I will be harder to identify a connection: parameters to identify it depends on the layer 3 and layer 4 protocols. (src, dst, port-src, port-dst, l3protonum, l4protonum) doesn't work with ICMP (arguments type and code) :-/ And what about IPv6? What about other layer3 protocols?

Quoted 5 lines

The 'id' is not enough to uniquely identify a flow since it can wrap
around: in a scenario with long-time flows, this can result in two flows with the same 'id'. The 'id' was introduced as a complement for the tuple since we weren't sure that the tuple was enough to identify a flow. After several discussions [1], we resolved that the tuple was enough.

Storing start-time for a conntrack can be very useful, I do it, it's the kind if thing that is likely to be useful for people who want to collect conntrack data over netlink.

Start-time combined with the tuple makes a good unique id.

Sam