All of lore.kernel.org
 help / color / mirror / Atom feed
* What should we do with packets marked as INVALID?
@ 2006-12-25  1:33 Krzysztof Oledzki
  2006-12-25 12:29 ` Jan Engelhardt
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Krzysztof Oledzki @ 2006-12-25  1:33 UTC (permalink / raw)
  To: Netfilter Developer Mailing List

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2714 bytes --]

Hello,

One of the most important feature provided by the netfilter subsystem is 
stateful connection tracking - the ability to decide that a packet is 
valid (or not) using not only data from a packet itself but also from a 
history of a flaw.

So, the question is: what should we do with packets marked as INVALID?

For a very long time I have thought that something like this should work 
best:

-A INVALID -m limit --limit 10/s -j LOG --log-prefix "INVALID: " --log-level 7 --log-tcp-sequence --log-tcp-options --log-ip-options
-A INVALID -p tcp -m limit --limit 4/s -j REJECT --reject-with tcp-reset
-A INVALID -p udp -m limit --limit 4/s -j REJECT
-A INVALID -j DROP

-A FORWARD -m conntrack --ctstate INVALID -j INVALID

This whole REJECT idea is to kill out of sync sessions - IMO it is better 
to send RST/port-unreachable ASAP, so hosts know they should reconnect 
immediatley (if that's appropriately) without needing to wait (sometines 
very long) for a session to timeout. Think on stalled NFS mounts, etc.

Then I realized that the same INVALID state handles packets from a valid 
flow (proto/src/dst/sport/dport match conntrack table) but with something 
the netfilter decides that is wrong (ex. out of window segments, 
short/truncated/malformed packets, bad checksum, etc). Rejecting such 
packets kills valid connections, and it is quite common to get a lot of, 
for example, "ip_ct_tcp: ACK is under the lower bound (possible overly 
delayed ACK)" on bigger firewalls:

root@fw2:~# grep -c "ip_ct_tcp: ACK is under the lower bound (possible overly delayed ACK)" /var/log/syslog
905

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.

So, I have two propositions:
  - Add another state (ex. UNCLEAN) for packet that matches 
proto/src/dst/sport/dport, but netfilter consider that it is wrong. There 
will be two states: INVALID (for packet with no known conntrack entry) and 
UNCLEAN and that gives us possibility to distinguish between these two 
states:

-A FORWARD -m conntrack --ctstate UNCLEAN -j DROP
-A FORWARD -m conntrack --ctstate INVALID -j INVALID

  - Drop such packets implicitly (something like s/-NF_ACCEPT/-NF_DROP/ in 
ip_conntrack_proto_*.c) and safely REJECT packets with INVALID state, like 
in my first example. This time INVALID will means that there is no 
appropriate conntrack entry, nothing else.

Comments?

Best regardas,


 			Krzysztof Olędzki

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-01-15 14:35 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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.