Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: "Thomas Köller" <thomas@koeller.dyndns.org>
Cc: netfilter@vger.kernel.org
Subject: Re: connection tracking state in rules
Date: Tue, 12 Nov 2024 19:24:45 +0100	[thread overview]
Message-ID: <ZzOdbYay4hhiwqbZ@calendula> (raw)
In-Reply-To: <c7d037d9-2261-4627-8e46-bd960f1ab6d3@koeller.dyndns.org>

On Tue, Nov 12, 2024 at 06:56:30PM +0100, Thomas Köller wrote:
> Hi,
> 
> tried to create a rule using the conntrack state of a packet:
> 
> [root@sarkovy nftables]# cat ruleset-own.txt
> create table netdev world
> add set netdev world blacklist { type ipv4_addr; flags dynamic,timeout;
> timeout 1h; gc-interval 6h; size 256; }
> create chain netdev world ingress { type filter hook ingress device
> "eth_cable" priority filter; policy drop; }
> add rule netdev world ingress ip protocol tcp ip saddr @blacklist counter
> drop
> add rule netdev world ingress ct state established,related counter accept
> [root@sarkovy nftables]# nft -cf ruleset-own.txt
> ruleset-own.txt:5:31-38: Error: Could not process rule: Protocol error
> add rule netdev world ingress ct state established,related counter accept
>                               ^^^^^^^^
> This is rejected, but why?

Because there is currently no support for connection tracking at
ingress.

> And, btw., which one is correct, 'ct state established,related' or 'ct state
> { established,related }'?

Use of { } implies a set instance.

# nft describe ct state
ct expression, datatype ct_state (conntrack state) (basetype bitmask, integer), 32 bits

pre-defined symbolic constants (in hexadecimal):
        invalid                         0x00000001
        new                             0x00000008
        established                     0x00000002
        related                         0x00000004
        untracked                       0x00000040

Use of:

        ct state established,related

(just like in iptables --m --state) is perfectly fine for this
particular case.

  parent reply	other threads:[~2024-11-12 18:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-12 17:56 connection tracking state in rules Thomas Köller
2024-11-12 18:21 ` Florian Westphal
2024-11-12 18:24 ` Pablo Neira Ayuso [this message]
2024-11-12 19:04   ` Thomas Köller
2024-11-12 20:10     ` Kerin Millar

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=ZzOdbYay4hhiwqbZ@calendula \
    --to=pablo@netfilter.org \
    --cc=netfilter@vger.kernel.org \
    --cc=thomas@koeller.dyndns.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox