From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Patrick McHardy <kaber@trash.net>
Cc: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>,
netfilter-devel@vger.kernel.org
Subject: Re: [nf_tables PATCH 5/6 v5] netfilter: nf_tables: extend NFT_MSG_DELTABLE to support flushing the ruleset
Date: Tue, 2 Sep 2014 17:28:26 +0200 [thread overview]
Message-ID: <20140902152826.GA10181@salvia> (raw)
In-Reply-To: <20140902151241.GA29716@acer.localdomain>
On Tue, Sep 02, 2014 at 04:12:41PM +0100, Patrick McHardy wrote:
> On Tue, Sep 02, 2014 at 04:42:26PM +0200, Arturo Borrero Gonzalez wrote:
> > This patch extend the NFT_MSG_DELTABLE call to support flushing the entire
> > ruleset.
> >
> > The options now are:
> > * No family speficied, no table specified: flush all the ruleset.
> > * Family specified, no table specified: flush all tables in the AF.
> > * Family specified, table specified: flush the given table.
> >
> > Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
> > ---
> > v2: address comments by Pablo:
> > * don't return EINVAL if called with AF_UNSPEC and a concrete table.
> > * A more generic function, nft_flush()
> >
> > v3: no changes, resending the series.
> > v4: no changes, resending the series because v3 series was invalid.
> > v5: address comment by Pablo: delete set if the list of bindings is empty.
>
> > +static int nft_flush_table(struct nft_ctx *ctx)
> > +{
> > + int err;
> > + struct nft_chain *chain, *nc;
> > + struct nft_set *set, *ns;
> > +
> > + list_for_each_entry_safe(chain, nc, &ctx->table->chains, list) {
> > + ctx->chain = chain;
> > +
> > + err = nft_delrule_by_chain(ctx);
> > + if (err < 0)
> > + goto out;
> > +
> > + err = nft_delchain(ctx);
> > + if (err < 0)
> > + goto out;
> > + }
> > +
> > + list_for_each_entry_safe(set, ns, &ctx->table->sets, list) {
> > + if (set->flags & NFT_SET_ANONYMOUS &&
> > + !list_empty(&set->bindings))
> > + continue;
>
> So we're removing anonymous sets iff the bindings are empty. I feel I'm
> missing something:
>
> - how could we possibly still have bindings after the table has been flushed?
We remove break the binding until we reach the commit path. The table
is not actually flushed from nft_flush_table, instead the objects are
marked to be removed from the commit path.
The rule <-> set binding remains there until we reach the commit path.
> - if that were possible, why wouldn't it also apply to non-anonymous sets?
Non-anonymous sets need to be explicitly destroyed after the rule is
removed.
> If I'm not mistaken we should be able to unconditionally delete all sets
> once the ruleset has been flushed.
We have to keep bound-to-rule anonymous set until we reach the commit
path, packets may still be walking on it.
If we don't skip the removal of bound-to-rule anonymous sets, we'll
crash since we'll try to delete them twice in the commit path, once
from _DELRULE and again from _DELSET.
next prev parent reply other threads:[~2014-09-02 15:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-02 14:42 [nf_tables PATCH 1/6 v5] netfilter: nf_tables: refactor rule deletion helper Arturo Borrero Gonzalez
2014-09-02 14:42 ` [nft PATCH 6/6] src: add `flush ruleset' Arturo Borrero Gonzalez
2014-09-02 14:42 ` [nf_tables PATCH 2/6 v5] netfilter: nf_tables: add helper to unregister chain hooks Arturo Borrero Gonzalez
2014-09-03 9:46 ` Pablo Neira Ayuso
2014-09-02 14:42 ` [nf_tables PATCH 3/6 v5] netfilter: nf_tables: rename nf_table_delrule_by_chain() Arturo Borrero Gonzalez
2014-09-03 9:46 ` Pablo Neira Ayuso
2014-09-02 14:42 ` [nf_tables PATCH 4/6 v5] netfilter: nf_tables: add helpers to schedule objects deletion Arturo Borrero Gonzalez
2014-09-02 15:20 ` Patrick McHardy
2014-09-02 15:47 ` Pablo Neira Ayuso
2014-09-09 14:04 ` Pablo Neira Ayuso
2014-09-02 14:42 ` [nf_tables PATCH 5/6 v5] netfilter: nf_tables: extend NFT_MSG_DELTABLE to support flushing the ruleset Arturo Borrero Gonzalez
2014-09-02 15:12 ` Patrick McHardy
2014-09-02 15:28 ` Pablo Neira Ayuso [this message]
2014-09-09 15:03 ` Pablo Neira Ayuso
2014-09-03 9:46 ` [nf_tables PATCH 1/6 v5] netfilter: nf_tables: refactor rule deletion helper Pablo Neira Ayuso
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=20140902152826.GA10181@salvia \
--to=pablo@netfilter.org \
--cc=arturo.borrero.glez@gmail.com \
--cc=kaber@trash.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).