From: "U.Mutlu" <um@mutluit.com>
To: Pablo Neira Ayuso <pablo@netfilter.org>, imnozi@gmail.com
Cc: netfilter-devel@vger.kernel.org, netfilter@vger.kernel.org
Subject: Re: [nftables/nft] nft equivalent of "ipset test"
Date: Wed, 18 Oct 2023 11:54:30 +0200 [thread overview]
Message-ID: <652FAB56.5060200@mutluit.com> (raw)
In-Reply-To: <ZS+nJS/4dolCsIk8@calendula>
Pablo Neira Ayuso wrote on 10/18/23 11:36:
> On Tue, Oct 17, 2023 at 08:00:57PM -0400, imnozi@gmail.com wrote:
>> On Wed, 18 Oct 2023 00:36:37 +0200
>> "U.Mutlu" <um@mutluit.com> wrote:
>>
>>> ...
>>> Actualy I need to do this monster: :-)
>>>
>>> IP="1.2.3.4"
>>> ! nft "get element inet mytable myset { $IP }" > /dev/null 2>&1 && \
>>> ! nft "get element inet mytable myset2 { $IP }" > /dev/null 2>&1 && \
>>> nft "add element inet mytable myset { $IP }"
>>
>> Try using '||', akin to:
>
> Please, use 'nft create' for this, no need for an explicit test and
> then add from command line.
>
> The idiom above is an antipattern, because it is not atomic, the
> 'create' command provides a way to first test if the element exists
> (if so it fails) then add it.
Pablo, unfortunately your solution with 'create' cannot be used
in my above said special use-case of testing first in BOTH sets...
I just don't understand why the author cannot simply add a real 'test'
function to the nft tool...
The logic is already in 'get element' and also in your 'create' method.
PS: I'm not yet subscribed to netfilter-dev, so CC may fail...
next prev parent reply other threads:[~2023-10-18 9:54 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-17 17:11 [nftables/nft] nft equivalent of "ipset test" U.Mutlu
2023-10-17 21:35 ` Florian Westphal
2023-10-17 21:55 ` U.Mutlu
2023-10-17 22:05 ` Florian Westphal
2023-10-17 22:36 ` U.Mutlu
2023-10-18 9:23 ` Pablo Neira Ayuso
[not found] ` <20231017200057.57cfce21@playground>
2023-10-18 9:36 ` Pablo Neira Ayuso
2023-10-18 9:54 ` U.Mutlu [this message]
2023-10-18 10:00 ` Pablo Neira Ayuso
2023-10-18 11:07 ` U.Mutlu
2023-10-18 11:49 ` Pablo Neira Ayuso
2023-10-18 13:03 ` U.Mutlu
2023-10-18 14:37 ` Phil Sutter
2023-10-18 11:54 ` 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=652FAB56.5060200@mutluit.com \
--to=um@mutluit.com \
--cc=imnozi@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=netfilter@vger.kernel.org \
--cc=pablo@netfilter.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