All of lore.kernel.org
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org, Florian Westphal <fw@strlen.de>,
	Eric Garver <e@erig.me>
Subject: Re: [nf-next PATCH] netfilter: nf_tables: Support updating table's owner flag
Date: Tue, 12 Dec 2023 17:23:03 +0100	[thread overview]
Message-ID: <ZXiI58QCVek1rWiF@orbyte.nwl.cc> (raw)
In-Reply-To: <ZXhbYs4vQMWX/q+d@calendula>

Hi Pablo,

On Tue, Dec 12, 2023 at 02:08:50PM +0100, Pablo Neira Ayuso wrote:
> On Fri, Dec 08, 2023 at 02:01:03PM +0100, Phil Sutter wrote:
> > A process may take ownership of an existing table not owned yet or free
> > a table it owns already.
> > 
> > A practical use-case is Firewalld's CleanupOnExit=no option: If it
> > starts creating its own tables with owner flag, dropping that flag upon
> > program exit is the easiest solution to make the ruleset survive.
> 
> I can think of a package update as use-case for this feature?
> Meanwhile, package is being updated the ruleset remains in place.

Usually (with the distros I am familiar with at least), the daemon just
keeps running while its package is updated. The run-time change then
happens after reboot (or explicit restart). RHEL/Fedora support
'%systemd_postun_with_restart' macro to request restart of the service
upon package update, but it runs after the actual update process, so
the time-window in between old service and new one is short (in theory).

Unless I'm mistaken, firewalld service restart is internally just "stop
&& start", not a distinct action. Temporarily changing the config to
make firewalld not clean up in that case to reduce/eliminate the
downtime is a nice idea, though. Eric, WDYT?

> Is there any more scenario are you having in mind for this?

No, it was basically just that. When discussing with Eric whether using
'flags owner' is good (to avoid clashes with other nf_tables users) or
bad (ruleset is lost upon (unexpected) program exit), I thought of a
switchable owner flag as a nice alternative to dropping and recreating
the owned tables without owner flag before exiting.

BTW: A known limitation is that crashing firewalld will leave the system
without ruleset. I could think of a second flag, "persist" or so, which
makes nft_rcv_nl_event() just drop the owner flag from the table instead
of deleting it. What do you think?

> > Mostly for consistency, this patch enables taking ownership of an
> > existing table, too. This would allow firewalld to retake the ruleset it
> > has previously left.
> 
> Isn't it better to start from scratch? Basically, flush previous the
> table that you know it was there and reload the ruleset.

Yes, this is what firewalld currently does. Looking at the package
update scenario you mentioned, a starting daemon can't really expect the
existing table to be in shape and should better just recreate it from
scratch.

> Maybe also goal in this case is to keep counters (and other stateful
> objects) around?

Yes, this is a nice side-effect, too.

In my opinion, support for owner flag update (both add and remove) is
simple enough to maintain in code and relatively straightforward
regarding security (if owned tables may only be changed by the owner) so
there is not much reason to not provide it for whoever may find use in
it.

For firewalld on the other hand, I think introducing this "persist" flag
would be a full replacement to the proposed owner flag update.

Cheers, Phil

  reply	other threads:[~2023-12-12 16:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-08 13:01 [nf-next PATCH] netfilter: nf_tables: Support updating table's owner flag Phil Sutter
2023-12-12 13:08 ` Pablo Neira Ayuso
2023-12-12 16:23   ` Phil Sutter [this message]
2023-12-12 22:47     ` Eric Garver
2023-12-13 12:13       ` Phil Sutter
2023-12-13 14:08         ` Eric Garver
2023-12-13 15:29           ` Florian Westphal
2023-12-13 15:15         ` Pablo Neira Ayuso
2023-12-13 15:51           ` Phil Sutter
2023-12-13 15:54             ` Pablo Neira Ayuso
2023-12-13 16:32           ` Thomas Haller
2023-12-13 16:45             ` Florian Westphal
2023-12-13 17:04               ` Thomas Haller

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=ZXiI58QCVek1rWiF@orbyte.nwl.cc \
    --to=phil@nwl.cc \
    --cc=e@erig.me \
    --cc=fw@strlen.de \
    --cc=netfilter-devel@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 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.