All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jean-Michel Hemstedt" <jean-michel.hemstedt@alcatel.be>
To: "Harald Welte" <laforge@gnumonks.org>
Cc: <netfilter-devel@lists.samba.org>
Subject: Re: performance issues (nat / conntrack)
Date: Sun, 23 Jun 2002 11:15:32 +0200	[thread overview]
Message-ID: <008201c21a96$88eb6520$0489cb8a@etbx180> (raw)
In-Reply-To: 20020622185150.D31606@sunbeam.de.gnumonks.org



I know this debate is not new... I just didn't expect such a (90% see
below) perf drop, and unavailablity risk. That's why I'm only reporting
it, hoping secretly that experienced hackers will consider it seriously.
;o)

Note: I don't want to play with words, but if you prefer, consider
     'load generator' as 'malicious DoS user', and 'perf issue' as
      'DoS vulnerability' as Don Cohen cleverly suggested :-/
     (for me it's the same problem, except that DoS is ponctual while
      perf is what we may expect in normal situation)

> >
> > I'm doing some tcp benches on a netfilter enabled box and noticed
> > huge and surprising perf decrease when loading iptable_nat module.
>
> Sounds as expected.

loading a module, doesn't mean using it (lsmod reports it as 'unused'
in my tests). So, does it really 'sounds as expected', when you see
your cpu load hitting 100%, and most packets dropped just after having
done 'iptables -t nat -L' on a system with 1%CPU load handling 'only'
10kpps and forwarding about 1000 new TCP connections/s?

>
> > - ip_conntrack is of course also loading the system, but with huge memory
> > and a large bucket size, the problem can be solved. The big issue with
> > ip_conntrack are the state timeouts: it simply kill the system and drops
> > all the traffic with the default ones, because the ip_conntrack table
> > becomes quickly full, and it seems that there is no way to recover from
> > that  situation... Keeping unused entries (time_close) even 1 minute in
> > the cache is really not suitable for configurations handling (relatively)
> > large number of connections/s.
>
> what is a 'relatively' large number of connections? I've seen a couple
> of netfilter firewalls dealing with 200000+ tracked connections.

200K concurrent established connections, maybe... but surely not NEW
connections/second.
See previous results: with only ip_conntrack loaded (no nat), I hardly
reached 500 (new) conn/s.

>
> > o The cumulative effect should be reconsidered.
>
> could you please try to explain what you mean?

There are 3 aspects:
- table exhaustion (can be fixed with large memory) as long as the
  hash is correctly distributed (few collisions)
- concurrent timers (1 per conntrack tuple??)
- I can't explain the last one, but when the table is exhausted
  conntrack drops new packets, right? What I noticed is that at that
  moment, the cpu load suddenly hit 100%, and the machine did not
  recover, unless I killed the load generator

>
> > o Are there ways/plans to tune the timeouts dynamically? and what are
> >   the valid/invalid ranges of timeouts?
>
> No, see the mailinglist archives for th reason why.

If you refer to your mail of 18 January 2001, I think that this timeout
should also be reviewed ;o)... Waiting for somebody having the time and
being able of doing a redesign was quite idealistic, while a quick patch
for configurable timeouts per rule (ie: http timeouts different from smtp
ones, as suggested by Denis Ducamp) would have been more realistic.

>
> > o looking at the code, it seems that one timer is started by tuple...
> >   wouldn't it be more efficient to have a unique periodic callback
> >   scanning the whole or part of the table for aged entries?
>
> I think somebody (Martin Josefsson?) is currently looking into optimizing
>
> > - The annoying point is iptable_nat: normally the number of entries in
> > the nat table is much lower than the number of entries in the conntrack
> > table. So even if the hash function itself could be less efficient than
> > the ip_conntrack one (because it takes less arguments: src+dst+proto),
> > the load of nat, should be much lower than the load of conntrack.
> > o So... why is it the opposite??
>
> ? What 'nat table' are  you talking about?  Do you understand how NAT
> works and how it interacts with connection tracking?

Actually, that's also what i would like to know ;o)
bysource or byisproto hash tables, pointing to ip_nat_hash tuples
pointing to ip_conntrack entry. But i don't understand where the
extra processing comes from when there are no (nat) rules defined.
Just to recall my test: I generated an amount of new connections
per second passing through a forwarding machine without any iptables
module and measured the cpu load/responsiveness and other things...
Then while the machine was sustaining this amount of new conn/s, i did
'insmod ip_conntrack [size]', saw the cpu load increasing, and finally
just did 'iptables -t nat -L' to load the nat module without any rule,
and saw again the cpu load increasing. With 500conn/s, the cpu load went
from 10% -> ~50/70% -> 100% (machine unavailable).

>
> > o Are there ways to tune the nat performances?
>
> no. NAT (and esp. NAT performance) is not a very strong point of netfilter.
> Everybody agrees that NAT is evil and it should be avoided in all
circumstances.
> Rusty didn't want to become NAT/masquerading maintainer in the first place,
> but rather concentrate on packet filtering.

wow! what is the alternative for 'Everybody' using REDIRECT?

>
> The NAT subsystem has a number of shortcomings, some of which have been
> fixed, other still remain.
>
> > - Another (old) question: why are conntrack or nat active when there are
> > no rules configured (using them or not)? If not fixed it should be at
> > least documented...
>
> This is standard behaviour.  Does your network driver unload if you
> 'ifconfig down' an interface?  Does a TC qdisc module unload if you
> delete all instances of the queue?

ok, but does your interface sends irq when it is down? I don't care
about having an 'unused' module in memory as long as it is doing
nothing and not (over)loading the system.

>
> conntrack is _not_ related/intermangled with iptables at all.  Conntrack
> does not know if anybody is using conntrack state in the system.
>
> > Somebody doing "iptables -t nat -L" takes the risk
> > of killing its system if it's already under load...
>
> ?  Please explain why. I see no reason for this.

We agree, i also don't see any reason for it.
see above: a 'clean' machine without iptables modules or rule which
is handling 500conn/s hit 100%cpu and becomes unavailable if you do
'iptables -t nat -L'.

>
> > In the same spirit,
> > iptables -F should unload all unused modules (the ip_tables modules
> > doesn't hurt). Just one quick fix: replace the 'iptables' executable by
> > one 'iptables' script calling the exe (located somewhere else) and
> > doing an rmmod at the end...
>
> no. this is considered a feature. The current [and past] behaviour is wanted
> like this by design.

that's a... choice.

> - Harald Welte / laforge@gnumonks.org               http://www.gnumonks.org/

_______________________________________________________________________
-jmhe-               He who expects nothing shall never be disappointed

  reply	other threads:[~2002-06-23  9:15 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-20 19:48 performance issues (nat / conntrack) Jean-Michel Hemstedt
2002-06-22 16:51 ` Harald Welte
2002-06-23  9:15   ` Jean-Michel Hemstedt [this message]
2002-06-25 11:33     ` Jozsef Kadlecsik
2002-06-25 12:47       ` Harald Welte
2002-06-25 14:23         ` Jozsef Kadlecsik
     [not found]         ` <025001c21c50$763fa880$0489cb8a@etbx180>
2002-06-25 16:07           ` Harald Welte
2002-06-25 21:08         ` Jozsef Kadlecsik
2002-06-25 13:21       ` Jean-Michel Hemstedt
2002-06-25 13:51         ` Harald Welte
2002-06-25 14:33           ` Jozsef Kadlecsik
2002-06-25 14:51           ` Jean-Michel Hemstedt
2002-06-25 16:11             ` Harald Welte
2002-06-25 13:52         ` Patrick Schaaf
2002-06-25 14:53         ` Jozsef Kadlecsik
2002-06-25 15:22           ` Balazs Scheidler
2002-06-25 10:35 ` Jozsef Kadlecsik
2002-06-25 12:42   ` Jean-Michel Hemstedt
2002-06-25 13:50     ` Patrick Schaaf
2002-06-25 19:03       ` Harald Welte
2002-06-25 13:56     ` Alex Bennee
2002-06-25 14:17     ` Jozsef Kadlecsik
2002-06-25 15:13       ` Balazs Scheidler
2002-06-25 19:06         ` Harald Welte
2002-06-26  8:18           ` Balazs Scheidler
2002-06-27  2:21       ` Andrew Smith
2002-06-27 11:24         ` Harald Welte
2002-06-29  5:25           ` Andrew Smith
2002-06-25 19:01     ` Harald Welte
2002-06-25 20:53       ` conntrack DoS Henrik Nordstrom
2002-06-25 21:47         ` Jozsef Kadlecsik
2002-06-25 22:42           ` Henrik Nordstrom
2002-06-27  8:26             ` Jozsef Kadlecsik
     [not found] <20020621132640.2C326472B@lists.samba.org>
2002-06-21 17:35 ` performance issues (nat / conntrack) Don Cohen
2002-06-21 18:26   ` Jean-Michel Hemstedt
2002-06-23  9:14   ` Jean-Michel Hemstedt
2002-06-25 10:38     ` Jozsef Kadlecsik
2002-06-25 11:11       ` Jean-Michel Hemstedt
2002-06-25 11:48         ` Jozsef Kadlecsik
     [not found] <20020623132739.12D52455E@lists.samba.org>
2002-06-24  4:46 ` Don Cohen
2002-06-24  6:06   ` Patrick Schaaf
     [not found]     ` <15638.48245.84830.480715@isis.cs3-inc.com>
2002-06-24  6:48       ` Patrick Schaaf
2002-06-24  6:54         ` Don Cohen
2002-06-24  7:13           ` Patrick Schaaf
2002-06-24 15:18             ` Don Cohen
2002-06-25  2:44               ` Harald Welte
     [not found] <20020625151007.980D14140@lists.samba.org>
2002-06-25 17:00 ` Don Cohen
2002-06-25 21:47   ` Jean-Michel Hemstedt
2002-06-26 14:50     ` Harald Welte
2002-06-26 18:04       ` Jean-Michel Hemstedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='008201c21a96$88eb6520$0489cb8a@etbx180' \
    --to=jean-michel.hemstedt@alcatel.be \
    --cc=laforge@gnumonks.org \
    --cc=netfilter-devel@lists.samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.