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
Subject: Re: [nft PATCH v2] Implement 'reset rule' and 'reset rules' commands
Date: Tue, 17 Jan 2023 15:58:04 +0100	[thread overview]
Message-ID: <Y8a3fB86ccXiv3A9@orbyte.nwl.cc> (raw)
In-Reply-To: <Y8VDcq8UXg+5GD+F@salvia>

On Mon, Jan 16, 2023 at 01:30:42PM +0100, Pablo Neira Ayuso wrote:
> On Thu, Jan 12, 2023 at 05:23:42PM +0100, Phil Sutter wrote:
> > Reset rule counters and quotas in kernel, i.e. without having to reload
> > them. Requires respective kernel patch to support NFT_MSG_GETRULE_RESET
> > message type.
> 
> Only thing to mention: This adds a new rule_cache_dump() call, this
> was consolidated on top of the cache infrastructure, to have a single
> spot in the code to fetch kernel objects via netlink. This triggers to
> netlink dumps, one to populate the cache and another for the reset,
> right?

Well, rule_cache_dump() becomes dual-use, because the rule reset call is
so similar to the regular rule dump one.

I also changed it to allow turning the actual dump off (by sending
NLM_F_ACK instead of NLM_F_DUMP to kernel). This is used for resetting a
single rule (identified by rule-handle). Same functionality as with
resetting (a single) quota instead of "quotas".

If dump is active, the kernel returns the rules that have been reset to
user space, so users see the last state data. To correctly print this,
nft needs a table and chain cache. My v2 has this wrong, it needlessly
requests a rule cache also. Thanks for making me validate this aspect of
the implementation! :)

The only caveat I just noticed with reduced cache is that "whole ruleset
reset" does not print the rules because list_rule_cb() expects h->family
to be set. Making it accept NFPROTO_UNSPEC is trivial, though.

Cheers, Phil

  reply	other threads:[~2023-01-17 14:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-12 16:23 [nft PATCH v2] Implement 'reset rule' and 'reset rules' commands Phil Sutter
2023-01-16 12:30 ` Pablo Neira Ayuso
2023-01-17 14:58   ` Phil Sutter [this message]
2023-01-17 15:51     ` Pablo Neira Ayuso
2023-01-17 17:04       ` Phil Sutter

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=Y8a3fB86ccXiv3A9@orbyte.nwl.cc \
    --to=phil@nwl.cc \
    --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.