From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Fernando Fernandez Mancera <ffmancera@riseup.net>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nft v3] src: add support to command "destroy"
Date: Tue, 25 Oct 2022 13:02:57 +0200 [thread overview]
Message-ID: <Y1fCYSWGl63YR1V0@salvia> (raw)
In-Reply-To: <20221024110122.1248-1-ffmancera@riseup.net>
On Mon, Oct 24, 2022 at 01:01:22PM +0200, Fernando Fernandez Mancera wrote:
> "destroy" command performs a deletion as "delete" command but does not fail
> when the object does not exist. As there is no NLM_F_* flag for ignoring such
> error, it needs to be ignored directly on error handling.
>
> Example of use:
>
> # nft list ruleset
> table ip filter {
> chain output {
> }
> }
> # nft destroy table ip missingtable
> # echo $?
> 0
> # nft list ruleset
> table ip filter {
> chain output {
> }
> }
Looks good, but this will also require a small patch in kernel.
Ignoring the return value is not sufficient for the transaction
semantics, considering the following example batch to be loaded via
nft -f:
destroy table ip xyz
table ip xyz {
}
so the transaction does not fail.
Kernel patch would be similar to what nf_conntrack_netlink.c does with
IPCTNL_MSG_CT_GET_CTRZERO.
You have to define a new command NFT_MSG_DESTROYTABLE, then register a
new entry in nfnl_callback that refers to nf_tables_deltable. Then,
from nf_tables_deltable:
if (NFNL_MSG_TYPE(cb->nlh->nlmsg_type) == NFT_MSG_DESTROYTABLE)
return 0;
return -ENOENT;
to silence the error reporting.
Keep it mind that:
nft flush table ip x
leaves the table in place, but:
nft delete table ip x
removes the table and its content (but it fails if table does not
exists).
What we need from kernel is the destroy semantics, it should be a
relatively small patch.
Thanks Fernando.
prev parent reply other threads:[~2022-10-25 11:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-24 11:01 [PATCH nft v3] src: add support to command "destroy" Fernando Fernandez Mancera
2022-10-25 11:02 ` Pablo Neira Ayuso [this message]
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=Y1fCYSWGl63YR1V0@salvia \
--to=pablo@netfilter.org \
--cc=ffmancera@riseup.net \
--cc=netfilter-devel@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;
as well as URLs for NNTP newsgroup(s).