From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH RFC nf-next 0/3] named expressions for nf_tables
Date: Fri, 8 Apr 2016 13:43:51 +0200 [thread overview]
Message-ID: <20160408114351.GA6869@salvia> (raw)
In-Reply-To: <20160407214942.GB731@breakpoint.cc>
On Thu, Apr 07, 2016 at 11:49:42PM +0200, Florian Westphal wrote:
> Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > Several examples on how this would look from userspace:
> >
> > * Add the 'tcp-counter' counter to the 'filter' table:
> >
> > # nft add counter filter tcp-counter
> >
> > * Delete this counter (only possible if not dereferenced from a rule):
> >
> > # nft delete counter filter tcp-counter
> >
> > * List existing named counters:
> >
> > # nft lists counters
> > table ip filter {
> > counter tcp-counter {
> > packets 6086 bytes 6278052
> > }
> > counter udp-counter {
> > packets 272 bytes 64690
> > }
> > counter icmp-counter {
> > packets 10 bytes 840
> > }
> > }
>
> Can't you already create a 'named counter' via
>
> chain tcp-counter {
> counter
> }
>
> ?
>
> Seems to me we only would have to teach nft list to
> allow filtering output on chain names, e.g.
>
> nft list table filter \*-counter
>
> to have something similar using exsiting feature set.
Right, but we still need a way to uniquely identify this stateful
expression for atomic dump'n'reset.
> > So far, only counters are supported, but it should be possible to
> > support named limits. I have another (imcomplete) patch that allows to
> > update the named expressions parameters, this can be useful to
> > dynamically update the ratelimiting policies, the command line should
> > look like:
> >
> > # nft update limit name user01234 rate 250 mbytes/day
>
> Similar comment here, you could create
>
> chain user01234 {
> limit rate 100 mbytes/day
> }
Right, we can replace this rule via the handle, but I see two problems
with this:
1) The user needs to track the rule handle, not so much of a problem
since userspace can do this at the cost of a bit of more
complexity.
2) When replacing the rule, the new expression starts from no history
as it will be a new expression, we'll be basically reseting it.
Using 'nft update limit...' I think we should be capable of upgrading
the ratelimit by keeping around the quota that the user has already
consumed.
The idea is, if we know the previous cost of every byte/packets in
terms of tokens, given that tokens are generated per nanosecond and
that know how many tokens we have already consumed, then we can
recalculate the quota that has been already consumed and add this to
the limit update, eg. if limit rate is 100 mbytes/day but the user
already consumed 50 mbytes, when calling:
nft update limit rate 200 mbytes/day
we can keep the 50 mbytes that were already consumed around.
Let me know, thanks.
next prev parent reply other threads:[~2016-04-08 11:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-06 16:51 [PATCH RFC nf-next 0/3] named expressions for nf_tables Pablo Neira Ayuso
2016-04-06 16:51 ` [PATCH RFC nf-next 1/3] netfilter: nf_tables: add stateful named expressions Pablo Neira Ayuso
2016-04-06 16:51 ` [PATCH RFC nf-next 2/3] netfilter: nf_tables: support for named expression reference Pablo Neira Ayuso
2016-04-06 16:51 ` [PATCH RFC nf-next 3/3] netfilter: nf_tables: support dump and reset for named expressions Pablo Neira Ayuso
2016-04-07 21:49 ` [PATCH RFC nf-next 0/3] named expressions for nf_tables Florian Westphal
2016-04-08 11:43 ` Pablo Neira Ayuso [this message]
2016-04-08 12:04 ` Florian Westphal
2016-04-08 12:12 ` Florian Westphal
2016-04-11 15:27 ` Andreas Schultz
2016-04-19 19:46 ` Pablo Neira Ayuso
2016-04-20 6:41 ` 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=20160408114351.GA6869@salvia \
--to=pablo@netfilter.org \
--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 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).