Skip to contentSkip to conversation

bad performance: bug or missing optimisation?

netfilter-core Rusty Russell 2 participants 4 messages Aug 27, 2003 – Aug 29, 2003 1 message not in the archive netfilter

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

In message <[email protected]> you write:

Quoted 7 lines

Hello!

While fighting with ICMP flood we came across strange NAT problem.

When box is forwarding ICMP flood from one source address to random destination addresses, it becomes unresponsive and CPU usage goes up.

Quoted 6 lines

No NAT was taking place, just conntrack and nat modules loaded.

Some debugging and profiling showed problem is that entry in ip_nat_core.c:bysource for flooding source address hash is growing very large and find_appropriate_src is walking all this list and always failing.

Ah, there are a couple of problems here.

The code is trying to ensure that we are compliant with Dan Kegel's proposed NAT RFC changes:

http://www.alumni.caltech.edu/~dank/peer-nat.html

But there are several problems. The first is that your application is probably not varying the ICMP echo ID, so it's hitting a single hash bucket for everything. The second is that the in_range code seems to have a logic bug:

	if ((mr->range[i].flags & IP_NAT_RANGE_PROTO_SPECIFIED)
	    && proto->in_range(&newtuple, IP_NAT_MANIP_SRC,
			       &mr->range[i].min, &mr->range[i].max))
		return 1;

This should be:

	if (!(mr->range[i].flags & IP_NAT_RANGE_PROTO_SPECIFIED)
	    || proto->in_range(&newtuple, IP_NAT_MANIP_SRC,
			       &mr->range[i].min, &mr->range[i].max))
		return 1;

Which means it will match the first entry...

Does that help?
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#2 lore raw

Hello,

Quoted 1 line
Quoted 1 line

While fighting with ICMP flood we came across strange NAT problem.

<snip>

Quoted 1 line
Quoted 1 line

No NAT was taking place, just conntrack and nat modules loaded.

<snip>

Quoted 1 line

Ah, there are a couple of problems here.

Do you remeber what I reported some time ago about a problem with ICMP redirects. When the NAT module was loaded, after some time, the kernel stopped reacting to ICMP redirects sent by one of my routers. When i unloaded the NAT module, everything came back to normal, and the kernel reacted to redirects and used to send the packets to the proper IPs.

Has that been investigated?

Regards,
Maciej

#3 lore raw

In message <[email protected]> you write:

Quoted 5 lines

Do you remeber what I reported some time ago about a problem with ICMP redirects. When the NAT module was loaded, after some time, the kernel stopped reacting to ICMP redirects sent by one of my routers. When i unloaded the NAT module, everything came back to normal, and the kernel reacted to redirects and used to send the packets to the proper IPs.

Hi Maciej,

Definitely a different problem. ICMP errors are handled
very differently from pings. I assume you were actually doing NAT at the time?

Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#4 lore raw

Hi,

Quoted 5 lines

Hi Maciej,

Definitely a different problem. ICMP errors are handled
very differently from pings. I assume you were actually doing NAT at the time?

No NAT rules, yet the nat modules were simply loaded because i used a copy of a setup that just had:

# iptables -X -t nat
# iptables -F -t nat
For flushing all the tables. So iptable_nat was in memory. After unloading
that, the redirects were treated again by the conntrack mechanism as
valid and accepted by the by the ruleset.
After modprobing iptable_nat again, after a few minutes, the -m state
rules did not match the redirects, so they were DROPped by the ruleset
default policy.

I will re-examine the problem with the latest 2.4 kernel.

Regards,
Maciej