All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org, dvyukov@google.com
Subject: Re: [PATCH nf,v2] netfilter: nftables: accept all dummy chain when table is dormant
Date: Fri, 21 May 2021 00:50:54 +0200	[thread overview]
Message-ID: <20210520225054.GA31069@salvia> (raw)
In-Reply-To: <20210519183404.GG8317@breakpoint.cc>

On Wed, May 19, 2021 at 08:34:04PM +0200, Florian Westphal wrote:
> Pablo Neira Ayuso <pablo@netfilter.org> wrote:
[...]
> > Let's have a look a several possible scenarios:
> > 
> > Scenario A) batch containing two commands: dorm + wake up
> > 
> > From preparation phase.
> > 
> > - dorm: preparation phase sets the dormant flag (hooks are
> >         still registered).
> > - wake up: unset the dormant flag. This needs to skip hook
> >            registration, because they are already registered.
> >            (it needs a way to check that hooks are registered).
> > 
> > From commit phase.
> > 
> > - dorm: dormant flag is unset, no-op.
> > - wake-up: dormant flag is unset, no-op.
> > 
> > From abort phase (reversed), it undoes preparation phase.
> > 
> > - wake-up: set the dormant flag, unregister hooks.
> > - dorm: unset the dormant flag, register hooks (not possible)
> > 
> > Problems: Needs a function to check if hooks are present.
> >           abort phase needs to register hooks.
> 
> I agree that abort and/or commit phases cannot register hooks.
> 
> > Scenario B) batch containing two commands: wake up + dorm
> > 
> > From preparation phase.
> > 
> > - wake up: unset the dormant flag. This needs to register hooks.
> > - dorm: preparation phase sets the dormant flag (hooks are
> >         still registered).
> > 
> > From commit phase.
> > 
> > - wake-up: dormant flag is set, unregister hooks.
> > - dorm: dormant flag is set, unregister hooks (again).
> > 
> > From abort phase (reversed), it undoes preparation phase.
> > 
> > - dorm: unset the dormant flag, register hooks (not possible)
> > - wake-up: set dormant flag, unregister hooks.
> > 
> > Problems: commit phase needs try_unregister hook function.
> >           abort phase needs to unregister hooks.
> 
> ... but that is doable in the sense that unregister can't fail.

Right, but adding "unregister hooks" to the abort path breaks a
different scenario. This might unregister a hook that, because of a later
wake-up action, needs to stay there, because you cannot call register
a hook from the abort path, it's a bit of a whac-a-mole game.

> > I also tried looking at the transaction state instead of the dormant
> > flags, similar problems.
> > 
> > I also tried adding more internal flags to annotate context. I looked
> > at adding fields to nft_table to count for the number of pending hook
> > registration / unregistration. It's all tricky.
> 
> Ok, too bad.
> 
> > The patch I posted is addressing the issue by skipping hook
> > registration / unregistration for dormant flags updates.
> > 
> > What's your concern with the approach I'm proposing?
> 
> No concern, I did not understand the problem with hook register in
> abort/commit.
> 
> I also dislike that dormat tables now retrain the hook overhead, but
> I guess dormat tables are an exception and not the norm, so maybe
> unfounded concern.

You are right that this approach incurs in the hook evaluation penalty
from the packet path. But I don't think there's a need to optimize
this feature at this stage. If it turns out that this needs to be
optimized, maybe it should be possible to add a core feature to
disable hook while leaving in registered (ie. hook "dormant" state).

So I'm just inclined to keep it simple while making sure that any
possible (silly) robot-generated sequence with this toggle works fine.

  reply	other threads:[~2021-05-20 22:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-19 10:14 [PATCH nf,v2] netfilter: nftables: accept all dummy chain when table is dormant Pablo Neira Ayuso
2021-05-19 12:15 ` Florian Westphal
2021-05-19 15:56   ` Pablo Neira Ayuso
2021-05-19 18:34     ` Florian Westphal
2021-05-20 22:50       ` Pablo Neira Ayuso [this message]
2021-05-21  9:28         ` Florian Westphal

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=20210520225054.GA31069@salvia \
    --to=pablo@netfilter.org \
    --cc=dvyukov@google.com \
    --cc=fw@strlen.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.