Skip to contentSkip to conversation

Question on raw table and match state

PATCH Applied Steven Kath 4 participants 4 messages Feb 11, 2011 – Feb 14, 2011 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

----- "Pandu Poluan" <[email protected]> wrote: -----

Quoted 5 lines

I am wondering if the following rule will work:

iptables -t raw -A PREROUTING -p icmp -m state --state RELATED,ESTABLISHED -j ACCEPT

If you look at Jan's Netfilter packet flow diagram, you'll see that the raw PREROUTING chain is traversed before the conntrack functions are called. State can not be determined until after the packet is compared to the conntrack table. The rule you described can't work and I think the iptables binaries won't allow it to be created.

http://jengelh.medozas.de/images/nf-packet-flow.png

#2 lore raw

(sorry for top posting)

Strangely enough, the iptables binary does not complain when I tried:

iptables -t raw -A PREROUTING -p icmp -m state --state ESTABLISHED,RELATED -j LOG --log-prefix "RP MATCH:"

or replacing LOG with ACCEPT. But checking dmesg shows that the rule is not triggered. Just to be sure, I added the following:

iptables -A INPUT -p icmp -m state --state ESTABLISHED,RELATED -j LOG --log-prefix "FI MATCH:"

and dmesg indeed shows the rule triggering.

That said, I've now understood raw & conntrack much better, thanks.

Rgds,

Quoted 15 lines · Steven Kath

----- "Pandu Poluan" <[email protected]> wrote: -----

Quoted 5 lines

I am wondering if the following rule will work:

iptables -t raw -A PREROUTING -p icmp -m state --state RELATED,ESTABLISHED -j ACCEPT

If you look at Jan's Netfilter packet flow diagram, you'll see that the raw PREROUTING chain is traversed before the conntrack functions are called. State can not be determined until after the packet is compared to the conntrack table. The rule you described can't work and I think the iptables binaries won't allow it to be created.

http://jengelh.medozas.de/images/nf-packet-flow.png

Signature · 3 lines
--
Pandu E Poluan - IT Optimizer
My website: http://pandu.poluan.info/
#3 lore raw

PATCH 1/1 warn on use of ctstate checking in raw

Quoted 6 lines · Pandu Poluan

(sorry for top posting)

Strangely enough, the iptables binary does not complain when I tried:

iptables -t raw -A PREROUTING -p icmp -m state --state ESTABLISHED,RELATED -j LOG --log-prefix "RP MATCH:"

Well, rm -Rf * also does not complain about files going away -- "Computer is a serious tool" :-)

Oh well, nature. Here's a patch for nature...

parent 44bd4de9c2270b22c3c898310102bc6be9ed2978 (v2.6.38-rc1-187-g44bd4de) commit ddc00998c0b1aa720720529ebaac73bb142e531f

Author: Jan Engelhardt <[email protected]>
Date:   Sat Feb 12 04:24:07 2011 +0100

netfilter: xt_conntrack: warn about use in raw table

nfct happens to run after the raw table only.

---
 net/netfilter/xt_conntrack.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
net/netfilter/xt_conntrack.c +5 -0
index 4ef1b63..2c0086a 100644
@@ -272,6 +272,11 @@ static int conntrack_mt_check(const struct xt_mtchk_param *par)
 {
 	int ret;
 
+	if (strcmp(par->table, "raw") == 0) {
+		pr_info("state is undetermined at the time of raw table\n");
+		return -EINVAL;
+	}
+
 	ret = nf_ct_l3proto_try_module_get(par->family);
 	if (ret < 0)
 		pr_info("cannot load conntrack support for proto=%u\n",
Signature · 1 line
# Created with git-export-patch
#4 lore raw

Re: [patch] warn on use of ctstate checking in raw

Am 12.02.2011 04:27, schrieb Jan Engelhardt:

Quoted 4 lines

netfilter: xt_conntrack: warn about use in raw table

nfct happens to run after the raw table only.

APplied, thanks Jan.