All of lore.kernel.org
 help / color / mirror / Atom feed
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: Wed, 20 Apr 2016 08:41:57 +0200	[thread overview]
Message-ID: <20160420064157.GA951@salvia> (raw)
In-Reply-To: <20160419194638.GA7710@salvia>

On Tue, Apr 19, 2016 at 09:46:38PM +0200, Pablo Neira Ayuso wrote:
> 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

Actually using the limit rate policer will not work for quota-like
stuff since the budget gets refilled for each packet that is received.

> 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.

libnetfilter_log will keep spamming userspace after going overlimit.
You most likely want a single report event notification to userspace.

Anyway, I understand your use case, will come back with an update on
this.

      reply	other threads:[~2016-04-20  6:42 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
2016-04-20  6:41     ` Pablo Neira Ayuso [this message]

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=20160420064157.GA951@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 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.