From: Joel Newkirk <netfilter@newkirk.us>
To: Rinse Kloek <rinse@solcon.nl>, netfilter@lists.netfilter.org
Subject: Re: Iptables efficiency
Date: Tue, 11 Mar 2003 09:31:23 -0500 [thread overview]
Message-ID: <200303110931.23730.netfilter@newkirk.us> (raw)
In-Reply-To: <007b01c2e72f$76712180$0200a8c0@rinse>
On Monday 10 March 2003 01:04 pm, Rinse Kloek wrote:
> We use a RedHat 7.3 machine as bridge on a P3 1.8 Ghz with 2 64 bits
> Gigabit interfaces. On the machine we have a lot of iptables rules
> like : all -- 213.134.x.0 0.0.0.0/0
> all -- 0.0.0.0/0 213.134.x.0
> TOS all -- 213.134.x.4 0.0.0.0/0 TOS set 0x08
> all -- 0.0.0.0/0 213.134.x.4
>
> We have about 3200 iptables rules on our bridge. I've tested today to
> remove 1000 of these rules. The load dropped from about 40% to 25%. So
> I think the iptables rule take up the most of the CPU load. Do you
> think this is a problem of ineffeciency of iptables or just a
> 'limitation' in the TCP/IP stack of linux ?
>
> regards Rinse
What is the traffic load like?
What types of matches are you performing? IP and port, TOS, state,
string? Are most of your rules 'test and drop' or 'test and accept', or
are you performing extensive modifications like the TOS set above?
These are big factors in the cost of getting a packet through.
What is the structure of the ruleset? Is it 'flat' where a given packet
could potentially be tested against a large percentage of these rules?
If you haven't done so, try organizing your rules as a tree, using custom
chains. IE, instead of having 2000 rules in a row in FORWARD that test
"-s a.b.c.d" try having rules that test "-s a.b.c.n/24" "-s a.b.d.n/24"
"a.b.e.n/24" etc and jump to user-defined chains, one for each of the
main rules. This will immediately reduce the maximum number of tests
for a given packet from ~2000 to ~260. (max now would be 253 for all
legal values of the last octet, plus the number of rules in the main
chain) You can further reduce by breaking that last octet down into,
say, 16 chains of 16 IPs each, and then your second-level chains will
contain rules that test "-s a.b.c.0/28" "-s a.b.c.16/28" "-s
a.b.c.32/28" etc and jump to even more detailed chains. Now you've
reduced your maximum from ~2000 tests to ~40. (16+16+mainchain - .0 and
.255 only shorten two of these third-level chains)
Has removal of those rules increased the throughput, or just the CPU load
on the bridge?
j
prev parent reply other threads:[~2003-03-11 14:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-10 18:04 Iptables efficiency Rinse Kloek
2003-03-11 13:13 ` Raymond Leach
2003-03-11 14:31 ` Joel Newkirk [this message]
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=200303110931.23730.netfilter@newkirk.us \
--to=netfilter@newkirk.us \
--cc=netfilter@lists.netfilter.org \
--cc=rinse@solcon.nl \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox