From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Andreas Schultz <aschultz@tpip.net>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH RFC nf-next 0/3] named expressions for nf_tables
Date: Tue, 19 Apr 2016 21:46:38 +0200 [thread overview]
Message-ID: <20160419194638.GA7710@salvia> (raw)
In-Reply-To: <570BC27F.9080409@tpip.net>
Hi Andreas,
On Mon, Apr 11, 2016 at 05:27:59PM +0200, Andreas Schultz wrote:
> Would this support to have rules based on the value of a counter and/or
> the current rate (like quotas in nfacct)?
>
> something like this:
>
> nft add rule filter tcp-chain counter name tcp-counter bytes > 10000 jump deny
>
> A more realistic setup might more look like:
>
> table ip filter {
> counter counter-user1234 {
> packets 6086 bytes 6278052
> }
>
> chain chain-user1234 {
> counter name counter-user1234
> counter name counter-user1234 > 10000000 goto chain-user1234-overlimit
> counter name counter-user1234 > 500000 goto rate-limit
> accept
> }
>
> chain chain-user1234-overlimit {
> do-once notify userspace somehow
> reject
> }
I think we can express this with:
nft add limit counter-user1234 rate over 100 mbytes/day
nft add rule filter input \
limit name counter-user1234 \
log prefix "user1234" group 10 \
reject
The idea is to create a 'counter-user1234' limit. Then refer to this
from the rule.
BTW, currently the 'reject' statement will rely on icmp unreach to
reject this. Probably you want a plain 'drop' here.
> As far as I know there is currently no mechanism in nft that could do
> the "do-once notify userspace somehow", or is there???
You can do this through the log statement, and then use
libnetfilter_log for your application.
> The other issue I have with such a scheme that it requires lots of chains per
> client and might limit the number of clients that could be supported.
I think we can skip the extra non-base chains in the example above.
The question is if you would be OK by specifying the quota using
ratelimit, opposed to counter.
The idea is that you can reset limits with something like:
nft reset limit name user1234
so this basically resets the quota. Or even upgrade via:
nft update limit name user1234 over 1000 mbytes/day
(this would keep what it's been consumed already, so statefulness is
preserved).
next prev parent reply other threads:[~2016-04-19 19:46 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
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 [this message]
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=20160419194638.GA7710@salvia \
--to=pablo@netfilter.org \
--cc=aschultz@tpip.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).