for several issues
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 1 line · Pablo Neira
Hi Harald,
Sorry for this very late reply. But finally i found enough spare time to look into your patches. Since they are mostly optimizations, I postponed them again and again :(
Quoted 6 lines
Here we go:
a) clean up for
tcp_packetfuntion. If a tcp packet with the rst flag set which also hasn't seen the reply yet hits the connection tracking, the conntrack will be drop inmediately. The current implemented of this condition is:
perfectly fine, I'm going to submit this to davem.
Quoted 1 line
b) update for expect-optimize in pom-ng.
I'll accept those patches, too.
Quoted 5 lines
c)
ip_ct_refreshlock issue. The conntrack table is write_lock'ed to refresh a non-confirmed conntrack but this is not needed since it's not inserted yet, so I consider that this lock is not needed. Actually playing with nfsim tells me that this condition only happens when a new conntrack is created, and this conntrack is not inserted yet.
Yes. But isn't this optimization based on the assumption that 'is_confirmed()' is an atomic operation? What if it gets confirmed on a second cpu, after is_confirmed() was called and before we refresh?
Am I missing something?
Quoted 4 lines
d)
ip_conntrack_inissue. I didn't posted any patch because I think that a bit of feedback would be ok.- I didn't find any helper that returns -1.
that doesn't mean that there could not be one in the future. From our past experience we know too well that there are lots of ugly protocols. And in some case, it might actually make sense to let the helper decide that this connection cannot be tracked and should thus become state INVALID.
Quoted 5 lines
- I didn't find a function
proto->packet(which actually calls its respective protocol specific function) that returnsNF_DROP. So the conditionalike(NF_DROP)is always true. In fact, all the functions that I had a look at return -1 andNF_ACCEPT.
Anyway, in which case does returningNF_DROPmake sense here?.
same as above. Some weird protocol might actually behave better if a packet is dropped. Yes, I know it sounds insane. Conntrack should never drop a packet. But people on netfilter-devel know that this is not always the truth :(
Quoted 8 lines
e) datalen variable issue in ftp conntrack helper. this calculation:
skb->len- dataoffis done twice, but it's not needed because datalen already contains this value. Patrick said that the patch is ok.
Patch file: ftp_helper-cleanup.patch
also fine with me.
Quoted 8 lines
f) Minor issue in commark. I sent a patch to Henrik because
ip_conntrack_getcalculates ctinfo and this is not needed. He told meip_conntrack_getis the official API and digging in pskb is not ok, I agree, actually I'm neither happy with my solution nor calculation ctinfo if it's not needed. He also pointed out that maybe another function which only return the conntrack without ctinfo could be implemented. Is implemented a function which does almost the same thing thatip_conntrack_getworthy?
In principle you're right. The question is, whether it's worth optimizing that case. Maybe you can do a little analysis: How many direct or indirect calleers of ip_conntrack_get (or __ip_conntrack_get) don't need ctinfo? If it is just about connmark, I guess we can leave it like it is. But if a reasonable number of callers doesn't need it, we could change it.
Quoted 8 lines
g) This is just a remark. Someone reposted to linux-net yesterday a patch which fixes a circular dependency in compilation for 2.4 branch.
Please see:
http://lists.netfilter.org/pipermail/netfilter-devel/2002-November/009928.htmlAttached the patch which fixes this. Don't blame if something's wrong, this patch is not mine, I'm just a forwarder.
this has already been submitted meanwhile.
Quoted 2 lines
best regards,
Pablo
You seem to be digging quite deep into the internals of netfilter/iptables/ip_conntrack. That's very welcome, we always need more people who understand the complex code. Would be nice to receive more of your insights and optimizations.
Signature · 5 lines
- Harald Welte <[email protected]> http://www.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
Quoted 5 lines · Harald Welte
Yes. But isn't this optimization based on the assumption that '
is_confirmed()' is an atomic operation? What if it gets confirmed on a second cpu, afteris_confirmed()was called and before we refresh?Am I missing something?
My understanding:
If it is not confirmed it is not yet in the conntrack hash, as it is not yet in the conntrack hash there can only be a single packet referencing this ct, and if another packet is being processed on another CPU for the same session before it is confirmed you will have one ct per packet, both of which will be confirmed individually.
It is also my understanding that the same packet will not be processed by both CPUs at the same time. Only one CPU will confirm the packet (and the conntrack referenced by it).
Note: assured is a different thing, this can obviosuly happen concurrently and should be expected to happen.
Quoted 6 lines
In principle you're right. The question is, whether it's worth optimizing that case. Maybe you can do a little analysis: How many direct or indirect calleers of
ip_conntrack_get(or__ip_conntrack_get) don't need ctinfo? If it is just about connmark, I guess we can leave it like it is. But if a reasonable number of callers doesn't need it, we could change it.
My feeling is that it would be better to make ip_conntrack_get an inline and let the compiler nullify the ctinfo calculation where it is not needed. The only reason I see for ip_conntrack_get not being an inline is to have correct module dependencies which can almost ceratinly be solved in a better way.
There is a few other callers that don't really need the ctinfo. Several of the other iptables extensions we have made just needs the conntrack (see ml archives), and in the tree there is
ipt_connlimit
ipt_connmark
ipt_CONNMARK
ipt_helper
ipt_MASQUERADE (only used in IP_NF_ASSERT)
ipt_NETMAP
ipt_REDIRECT (only used in IP_NF_ASSERT)
ipt_SAME
Some of these could go good with similar IP_NF_ASSERT as is used in ipt_MASQUERADE and ipt_REDIRECT which is further evidence that the inline approach is the best path if one wants to optimize away the use of ctinfo when not needed.
Regards
Henrik
Quoted 11 lines · Harald Welte
Quoted 5 lines
c)
ip_ct_refreshlock issue. The conntrack table is write_lock'ed to refresh a non-confirmed conntrack but this is not needed since it's not inserted yet, so I consider that this lock is not needed. Actually playing with nfsim tells me that this condition only happens when a new conntrack is created, and this conntrack is not inserted yet.Yes. But isn't this optimization based on the assumption that '
is_confirmed()' is an atomic operation? What if it gets confirmed on a second cpu, afteris_confirmed()was called and before we refresh?Am I missing something?
How did the second cpu get hold of our connection-entry that hasn't been inserted into the hashtable yet? :)
I have a patch that makes ip_ct_refresh() lockfree. I just need to SMP-test it a bit more before I post it. It gives a fairly large performance increase even on UP kernels since it removes the call to local_bh_enable().
And on SMP it sort of removes the only real serializing we have in conntrack for packets belonging to an existing connection. (we should go with something like the timer-handling patch Patrick Schaaf posted a long time ago (Subject: [PATCH][WORKSFORME] make add_timer rare) but this simple patch is a good first start)
Quoted 4 lines
You seem to be digging quite deep into the internals of netfilter/iptables/ip_conntrack. That's very welcome, we always need more people who understand the complex code. Would be nice to receive more of your insights and optimizations.
Yes we certainly do.
Signature · 1 line
/Martin