All of lore.kernel.org
 help / color / mirror / Atom feed
From: kaups <kaups@linux.ee>
To: netfilter-devel@lists.netfilter.org
Subject: netfilter time patch (feature request)/ optimization against big rulesets.
Date: Wed, 10 Mar 2004 12:41:48 +0200	[thread overview]
Message-ID: <200403101241.48559.kaups@linux.ee> (raw)

Hi.

You have a cool netfilter patch in pom, which allows to match packets against 
time based rules.

Right now I'm having a problem with it in big iptables rulesets, for example:

---------------------
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

[ ... about 10000 different rules ... ]

iptables -A INPUT -m time --timestart 8:00 --timestop 18:00 --days Mon -j 
ACCEPT
---------------------

If i use this ruleset allready established connections will continue after 
18:00. If i set the "iptables -A FORWARD -m state --state ESTABLISHED,RELATED 
-j ACCEPT" rule after time conditional matches, then bigger traffic will kill 
slow machines because of many unnecessary checks in a long linear chain.

Right now I can either use recent lists, or CONNAMRK targets:

iptables with recent lists:

---------------------
# packets accepted against time condition are also put into recent list
# and i match only those which are not listed.
iptables -A FORWARD -m recent \! --rcheck -j -m state --state 
ESTABLISHED,RELATED -j ACCEPT

[ ... about 10000 different rules ... ]

iptables -A INPUT -m time --timestart 8:00 --timestop 18:00 --days Mon -m 
recent --set -j ACCEPT
---------------------


iptables with CONNMARK:

---------------------
iptables -N TIMEACCEPT
iptables -A TIMEACCEPT -j MARK --set-mark 5
iptables -t mangle -A TIMEACCEPT -j CONNMARK --save-mark
iptables -A TIMEACCEPT -j ACCEPT

iptables -A PREROUTING -t mangle -j CONNMARK --restore-mark


iptables -A FORWARD -m mark \! --mark 5 -m state --state ESTABLISHED,RELATED 
-j ACCEPT

[ ... about 10000 different rules ... ]

iptables -A INPUT -m time --timestart 8:00 --timestop 18:00 --days Mon -j 
TIMEACCEPT
---------------------

But both of them are rather hacks, than a correct solutions.

Would it be possible to add extention that connections accepted in time 
conditional rules are valid in ip_conntrack table only to the end of 
condition? Hypothetical example:

---------------------
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

[ ... about 10000 different rules ... ]

iptables -A INPUT -m time --timestart 8:00 --timestop 18:00 --days Mon 
--with-validlimit -j ACCEPT
---------------------

For example if the connection arrives/begins at Mon 17:59, that means the 
entry in ip_conntrack will expire automatically at 18:00.


PS Please excuse my bad English.

-- 

Kaupo Arulo

             reply	other threads:[~2004-03-10 10:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-10 10:41 kaups [this message]
2004-03-10 14:42 ` netfilter time patch (feature request)/ optimization against big rulesets Henrik Nordstrom

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=200403101241.48559.kaups@linux.ee \
    --to=kaups@linux.ee \
    --cc=netfilter-devel@lists.netfilter.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.