From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH RFC nf-next 0/3] named expressions for nf_tables
Date: Wed, 6 Apr 2016 18:51:30 +0200 [thread overview]
Message-ID: <1459961493-7494-1-git-send-email-pablo@netfilter.org> (raw)
Hi,
This patchset introduces the named stateful expressions for nf_tables,
that allows userspace to set a name for the stateful expression for
several reasons:
* Provide a unique identifier to fetch and reset it internal state.
* Allow to update of their parameters and internal state.
* Allow to fetch and reset its internal state.
* Refer to the same stateful expression from one or more rules.
nf_tables currently supports to stateful expressions: limit and counter,
therefore you can create named instances of this expressions through
this new infrastructure.
This batch is composed of three patches:
1) Extend the nf_tables netlink interface to add, delete, dump and reset
named expressions.
2) Add a new expression to dereference named expressions.
3) Support atomic dump and reset of named expressions.
Note that this provides a native replacement for the iptables' nfacct
infrastructure, the use of nfacct is out of question due to the lack of
integration with nftables netlink interface and its 2-phase commit
protocol.
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
}
}
* Atomically fetch and reset counters:
# nft reset 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
}
}
This retrieves the existing counter values and reset them, a follow up
listing confirms this:
# nft list counters
table ip filter {
counter tcp-counter {
packets 0 bytes 0
}
counter udp-counter {
packets 0 bytes 0
}
counter icmp-counter {
packets 0 bytes 0
}
}
The snippet below shows a simplistic configuration to account tcp, udp
and icmp traffic through the named counter:
-o-
table ip filter {
counter tcp-counter {
packets 6086 bytes 6278052
}
counter udp-counter {
packets 272 bytes 64690
}
counter icmp-counter {
packets 10 bytes 840
}
chain input {
type filter hook input priority 0; policy accept;
ip protocol vmap { tcp : jump tcp-chain, icmp : jump icmp-chain, udp : jump udp-chain}
}
chain output {
type filter hook output priority 0; policy accept;
}
chain tcp-chain {
counter name tcp-counter
}
chain udp-chain {
counter name udp-counter
}
chain icmp-chain {
counter name icmp-counter
}
}
-o-
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
This example above updates the existing ratelimit 'user01234' to
250 mbytes/day.
Comments welcome,
Thanks.
Pablo Neira Ayuso (3):
netfilter: nf_tables: add stateful named expressions
netfilter: nf_tables: support for named expression reference
netfilter: nf_tables: support dump and reset for named expressions
include/net/netfilter/nf_tables.h | 32 +++
include/uapi/linux/netfilter/nf_tables.h | 41 +++
net/netfilter/Kconfig | 6 +
net/netfilter/Makefile | 1 +
net/netfilter/nf_tables_api.c | 453 ++++++++++++++++++++++++++++++-
net/netfilter/nft_counter.c | 36 ++-
net/netfilter/nft_nexpr.c | 112 ++++++++
7 files changed, 667 insertions(+), 14 deletions(-)
create mode 100644 net/netfilter/nft_nexpr.c
--
2.1.4
next reply other threads:[~2016-04-06 16:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-06 16:51 Pablo Neira Ayuso [this message]
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
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=1459961493-7494-1-git-send-email-pablo@netfilter.org \
--to=pablo@netfilter.org \
--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).