All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Schaaf <bof@bof.de>
To: Don Cohen <don-nf@isis.cs3-inc.com>
Cc: netfilter-devel@lists.samba.org
Subject: Re: conntrack performance/DoS formula
Date: Sat, 29 Jun 2002 19:22:18 +0200	[thread overview]
Message-ID: <20020629192218.P4136@oknodo.bof.de> (raw)
In-Reply-To: <15645.58583.30187.70748@isis.cs3-inc.com>; from don-nf@isis.cs3-inc.com on Sat, Jun 29, 2002 at 09:48:23AM -0700

>   This version adds a '-b X' option. If you specify that, all TCP conntracks
>   with timeouts less than X get ignored. For example, use "-b 431940" to only
>   count the conntracks active within the last 60 seconds.
> 
> I guess I just don't understand conntrack well enough.
> How does -b 431940 map to active in the last 60 sec?

Whenever a new packet arrives, the timeout of its conntrack is set to
the maximum value. For ESTABLISHED TCP connections, that's 5 days,
i.e. 432000 seconds.

> Also, why does this matter?

When worrying about chain lengths, we are worrying about lookup performance.
By restricting the accounting to conntracks active during the last 60 seconds,
I tried to capture the part of the buckets "where the action was".

My finding is that the really long chain lengths, which also prevail when
I use the crc32 hash, are all for very old inactive (and UNREPLIED)
connections  - which look like portscans from one or two days ago.
And indeed, those show the +n -n pattern on the ports that you observed,
and maybe, just maybe this is a sign of some malicious conntrack attacking
scan tool. If my further analysis below is correct, however, that attack
is almost futile.

> If you use my suggestion to treat a "full
> bucket" like a full table then the issue is whether buckets are full,
> and I don't see how that's affected by how recently used the entries
> are. 

I think my analysis shows a possible problem with your approach: when such
a port scan results in an overly long single bucket list, that list will
prevail for up to 5 days. If N is the number of buckets, and newly arriving
connections are evenly spread over the buckets, then every Nth connection
will fall into that overly long bucket - being blocked if we apply your
cutting logic unmodified.

However, in my observation of those problematic buckets, the connections
are UNREPLIED. Then we can use the same trick that is used when
ip_conntrack_max is reached: recycle one of those UNREPLIED
connections immediately for the new conntrack.

(If you are not aware of that ip_conntrack_max handling, have a look at
the early_drop() logic in ip_conntrack_core.c)

>   Incidentally, this makes the current ip_conntrack hash function look a lot
>   less bad than before. I appears that the "long bucket" packets mostly belong
>   to some kind of port scan. They will time out eventually, and they will NOT
>   contribute significantly to CPU usage, because they will be rarely hit.
> 
> They do contribute to cpu cost because they lengthen the search for
> other connections.

NO. They were "alone in their bucket". In other words, no active connection
fell into the same bucket, so they won't come into play at all during lookup.
And, as each entry has its individual timer, there is no scanning of the
overall table, so they would be really untouched in real life, until they
timeout after 5 days.


At this point, I would like to stop for some time, and await results
from other's real world ip_conntrack setups.

best regards
  Patrick

  reply	other threads:[~2002-06-29 17:22 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-27 20:46 conntrack performance/DoS formula Don Cohen
2002-06-28  6:23 ` Patrick Schaaf
2002-06-28 17:53   ` Don Cohen
2002-06-28 18:36     ` Patrick Schaaf
2002-06-28 19:03       ` Don Cohen
2002-06-28 19:35         ` Patrick Schaaf
2002-06-28 19:39           ` Patrick Schaaf
2002-06-28 21:10           ` Don Cohen
2002-06-28 21:28             ` Patrick Schaaf
2002-06-28 21:49               ` Don Cohen
2002-06-28 22:30               ` Don Cohen
2002-06-29  9:03                 ` Patrick Schaaf
2002-06-29 16:48                   ` Don Cohen
2002-06-29 17:22                     ` Patrick Schaaf [this message]
2002-07-05 13:47                       ` Harald Welte
2002-06-29 17:33                     ` Patrick Schaaf
2002-06-29  9:29                 ` Patrick Schaaf
2002-06-29 12:07                 ` Patrick Schaaf
2002-06-29 12:34                   ` Patrick Schaaf
2002-06-30  8:31                     ` Patrick Schaaf
2002-06-30 19:40                       ` Don Cohen
2002-07-01  8:07                         ` Henrik Nordstrom
2002-07-01 17:49                           ` Don Cohen
2002-07-02  7:58                             ` Henrik Nordstrom
     [not found]                           ` <15652.38084.704660.234319@isis.cs3-inc.com>
2002-07-04 21:53                             ` Henrik Nordstrom
2002-07-05  7:08                               ` Don Cohen
2002-07-05 11:41                                 ` Henrik Nordstrom
2002-07-06  2:49                                   ` Don Cohen
2002-07-02 14:55                         ` Harald Welte
2002-07-02 14:40         ` Harald Welte
2002-07-02 16:32           ` Patrick Schaaf
2002-07-02 16:35             ` Patrick Schaaf
2002-07-02 16:53               ` Henrik Nordstrom
2002-07-02 17:48               ` Don Cohen
2002-07-02 18:31                 ` Patrick Schaaf
2002-07-02 21:52                   ` cttest-0.1 Patrick Schaaf
2002-07-03  4:15                     ` cttest-0.1 Joakim Axelsson
2002-07-05 15:37                       ` cttest-0.1 Martin Josefsson
2002-07-05 16:10                       ` cttest-0.1 Joakim Axelsson
2002-07-05 16:54                         ` cttest-0.1 Patrick Schaaf
2002-07-05 16:53                           ` cttest-0.1 Joakim Axelsson
2002-07-06  6:10                             ` cttest-0.1 Andrew Smith
2002-07-06  7:12                               ` cttest-0.1 Patrick Schaaf
2002-07-06 15:23                                 ` cttest-0.1 Patrick Schaaf
2002-07-06 21:14                                   ` cttest-0.1 Joakim Axelsson
2002-07-06 22:41                                     ` cttest-0.1 Joakim Axelsson
2002-07-06 23:16                                       ` cttest-0.1 Joakim Axelsson
2002-07-07  2:30                                         ` cttest-0.1 Svenning Sorensen
2002-07-07  4:23                                           ` cttest-0.1 Joakim Axelsson
2002-07-07  5:46                                             ` cttest-0.1 Joakim Axelsson
2002-07-07 11:00                                               ` cttest-0.1 Henrik Nordstrom
2002-07-06 22:54                                     ` cttest-0.1 Joakim Axelsson
2002-07-02 14:38 ` conntrack performance/DoS formula Harald Welte
     [not found] <20020701121404.B78724512@lists.samba.org>
2002-07-01 21:30 ` Don Cohen
2002-07-02  6:05   ` Patrick Schaaf

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=20020629192218.P4136@oknodo.bof.de \
    --to=bof@bof.de \
    --cc=don-nf@isis.cs3-inc.com \
    --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.