From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter users list <netfilter@vger.kernel.org>
Subject: Re: Cannot reference sets in later rules until next nft run
Date: Fri, 3 Sep 2021 09:42:28 +0200 [thread overview]
Message-ID: <20210903074228.GA22010@salvia> (raw)
In-Reply-To: <20210903012502.GA246533@lotus.rw.madduck.net>
On Fri, Sep 03, 2021 at 01:25:02PM +1200, martin f krafft wrote:
> Dear list,
>
> I am trying to create an nft ruleset that uses the include directive and a
> run-parts.d style directory for additions to the main ruleset.
>
> I've run into a problem with nft v0.9.8 on kernel 5.10.0, which I summarise
> as follows: If a rule in the main ruleset defines a set then I cannot use
> that set outside the current scope until a later run of nft.
>
> Let me illustrate:
>
> I have the following files (please find them attached):
>
> ==> inc.d/20-ssh.nft <==
> table inet test {
>
> set recent_ssh_connections4 { type ipv4_addr; timeout 30s; }
>
> chain incoming_ssh {
> update @recent_ssh_connections4 { ip saddr } \
> accept comment "SSH connections"
> }
>
> chain input {
> tcp flags syn tcp dport 22 counter jump incoming_ssh
> }
> }
>
> ==> inc.d/50-mosh_ports_v4.nft <==
> add rule inet test input \
> ip saddr @recent_ssh_connections4 udp dport 60000-61000 counter accept \
> comment "Portrange required for mosh"
>
> ==> ruleset.nft <==
> table inet test {
>
> chain input {
> type filter hook input priority filter;
>
> }
> }
>
> include "./inc.d/*.nft"
>
> When I try to load this ruleset, it fails (debug output is attached):
>
> % sudo nft -f ruleset.nft In file included from ruleset.nft:9:1-24:
> ./inc.d/50-mosh_ports_v4.nft:2:12-35: Error: No such file or directory
> ip saddr @recent_ssh_connections4 udp dport 60000-61000 counter accept \
> ^^^^^^^^^^^^^^^^^^^^^^^^
Just tried it here with lastest:
# nft -v
nftables v1.0.0 (Fearless Fosdick #2)
WorksForMe(tm)
# nft -f ruleset.nft
# nft list ruleset
table inet test {
set recent_ssh_connections4 {
type ipv4_addr
size 65535
timeout 30s
}
chain input {
type filter hook input priority filter; policy accept;
tcp flags syn tcp dport 22 counter packets 0 bytes 0 jump incoming_ssh
ip saddr @recent_ssh_connections4 udp dport 60000-61000 counter packets 0 bytes 0 accept comment "Portrange required for mosh"
}
chain incoming_ssh {
update @recent_ssh_connections4 { ip saddr } accept comment "SSH connections"
}
}
This is an old cache bug that was fixed starting 0.9.9 IIRC.
> If I load the included files with a separate invocation of nft, it works:
>
> % sed '/^include/d' ruleset.nft | sudo nft -f -
> % for f in inc.d/*.nft; do sudo nft -f $f; done
>
> At first, I thought this was a problem with include, but even if I replace
> the include directive with the contents of the files it would include, the
> error is the same.
>
> The error also stays if I convert the command-style content of
> inc.d/50-mosh_ports_v4.nft to the native format.
>
> The only way to make this work is to include the rules within the main and
> first table declaration in ruleset.nft, which means it's not possible to use
> sets in include files.
>
> Is this a bug, or am I doing something wrong?
It's a bug, please try out lastest.
Thanks.
next prev parent reply other threads:[~2021-09-03 7:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-03 1:25 Cannot reference sets in later rules until next nft run martin f krafft
2021-09-03 7:42 ` Pablo Neira Ayuso [this message]
2021-09-03 9:51 ` martin f krafft
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=20210903074228.GA22010@salvia \
--to=pablo@netfilter.org \
--cc=netfilter@vger.kernel.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