All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Krzysztof Oledzki <ole@ans.pl>
Cc: Netfilter Developer Mailing List <netfilter-devel@lists.netfilter.org>
Subject: Re: What should we do with packets marked as INVALID?
Date: Thu, 28 Dec 2006 17:25:22 +0100	[thread overview]
Message-ID: <4593EFF2.1090400@netfilter.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0612281032430.32322@bizon.gios.gov.pl>

Krzysztof Oledzki wrote:
> On Thu, 28 Dec 2006, Pablo Neira Ayuso wrote:
>> Krzysztof Oledzki wrote:
>>> So, the question is: what should we do with packets marked as INVALID?
>>>
>>> [...]
>>>
>>> So OK, REJECT is wrong (possibly kills valid connections), DROP (makes
>>> invalid connections hang "forever") is also wrong, so maybe we should
>>> forward such packets and allow dst hosts to handle it
>>> (ignore/reset/etc). Bzzzz... no, wait, it is also wrong as we lose one
>>> of the most important netfilter feature.
>>
>> IMO, the default action should be drop. Having a look at the errors in
>> the tcp window tracking code, I can't think about a sane connection that
>> can generate invalid out of window packets even under packet lost.
> 
> I agree to DROP it, especially that ~11Mbit/s communication betwen two
> of my hosts (FreeBSD 6) is able to ganarate the "ip_ct_tcp: ACK is under
> the lower bound" condition in about 1-2 minutes. One has 100Mbit NIC,
> the second 1Gbit NIC and there is a linux FW between them. But I also
> want to REJECT packets from unknown connections (no touple).

All packets have a conntrack, and therefore a tuple. Even those that
don't belong to a unexistent connection. The point is if the
conntrack is confirmed or not, ie. at least one packet of a certain
connection traversed the stack successfully. The TCP window tracking
does not mark as invalid unconfirmed conntracks, just checks if the
packets follows an appropiate protocol sequence, ie. a packet with the
flag push set for an "unknown" connection is invalid.

> I want to:
>  - REJECT packets without a touple, to kill unknown connections.
>  - DROP packets with a touple when window tracking decides that a packet
> is invalid
> 
> I think it is quite sane...

iptables -P FORWARD -j DROP
[... your ruleset ...]
iptables -A FORWARD -m state INVALID -j LOG --log-prefix "invalid: "
iptables -A FORWARD -m state INVALID -j DROP
iptables -A FORWARD -p tcp --syn -j REJECT --reject-with tcp-reset

Couldn't this be enough? In this case, an invalid packet is always
dropped, and a valid packet, a TCP syn packet for a filtered port, is
replied with a TCP reset. Of course, as I told you before, a packet with
a wrong flag combination for an unknown connection is marked as invalid
by the TCP tracking code, but this is the expected behaviour.

-- 
The dawn of the fourth age of Linux firewalling is coming; a time of
great struggle and heroic deeds -- J.Kadlecsik got inspired by J.Morris

  reply	other threads:[~2006-12-28 16:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-25  1:33 What should we do with packets marked as INVALID? Krzysztof Oledzki
2006-12-25 12:29 ` Jan Engelhardt
2006-12-25 14:08   ` Krzysztof Oledzki
2006-12-28  2:26 ` Pablo Neira Ayuso
2006-12-28 10:06   ` Krzysztof Oledzki
2006-12-28 16:25     ` Pablo Neira Ayuso [this message]
2006-12-28 16:36       ` Krzysztof Oledzki
2007-01-10  6:06 ` Patrick McHardy
2007-01-15 10:41   ` Krzysztof Oledzki
2007-01-15 14:35     ` Patrick McHardy

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=4593EFF2.1090400@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=netfilter-devel@lists.netfilter.org \
    --cc=ole@ans.pl \
    /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.