netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] nfacct infrastructure (version 2)
@ 2011-12-23 13:42 pablo
  2011-12-23 13:42 ` [PATCH 1/2] netfilter: add extended accounting infrastructure over nfnetlink pablo
  2011-12-23 13:42 ` [PATCH 2/2] netfilter: xtables: add nfacct match to support extended accounting pablo
  0 siblings, 2 replies; 28+ messages in thread
From: pablo @ 2011-12-23 13:42 UTC (permalink / raw)
  To: netfilter-devel; +Cc: kaber, jengelh, kadlec, eric.dumazet

From: Pablo Neira Ayuso <pablo@netfilter.org>

Hi!

These patchset contains the second version of the nfacct infrastructure
after digesting comments from Patrick and Eric.

Now, we've got one new xt_nfacct match instead of the target as suggested
by Jan and Jozsef.

I'd like to apply this to nf-next, if nobody complains in the following
days, I'll do so.

Thanks!

Pablo Neira Ayuso (2):
  netfilter: add extended accounting infrastructure over nfnetlink
  netfilter: xtables: add nfacct match to support extended accounting

 include/linux/netfilter/Kbuild           |    2 +
 include/linux/netfilter/nfnetlink.h      |    3 +-
 include/linux/netfilter/nfnetlink_acct.h |   35 +++
 include/linux/netfilter/xt_nfacct.h      |   17 ++
 net/netfilter/Kconfig                    |   19 ++
 net/netfilter/Makefile                   |    2 +
 net/netfilter/nfnetlink_acct.c           |  345 ++++++++++++++++++++++++++++++
 net/netfilter/xt_nfacct.c                |   76 +++++++
 8 files changed, 498 insertions(+), 1 deletions(-)
 create mode 100644 include/linux/netfilter/nfnetlink_acct.h
 create mode 100644 include/linux/netfilter/xt_nfacct.h
 create mode 100644 net/netfilter/nfnetlink_acct.c
 create mode 100644 net/netfilter/xt_nfacct.c

-- 
1.7.2.5


^ permalink raw reply	[flat|nested] 28+ messages in thread
* [PATCH 0/2] [RFC] Extended accounting infrastructure for iptables
@ 2011-12-14 11:00 pablo
  2011-12-14 11:00 ` [PATCH 1/2] netfilter: add extended accounting infrastructure over nfnetlink pablo
  0 siblings, 1 reply; 28+ messages in thread
From: pablo @ 2011-12-14 11:00 UTC (permalink / raw)
  To: netfilter-devel; +Cc: kadlec, kaber, jengelh, thomas.jarosch

From: Pablo Neira Ayuso <pablo@netfilter.org>

Hi!

We currently have two ways to account traffic in netfilter:

- iptables chain and rule counters:

 # iptables -L -n -v
Chain INPUT (policy DROP 3 packets, 867 bytes)
 pkts bytes target     prot opt in     out     source               destinat
    8  1104 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/

- use flow-based accounting provided by ctnetlink:

 # conntrack -L
tcp      6 431999 ESTABLISHED src=192.168.1.130 dst=212.106.219.168 sport=58

While trying to display real-time accounting statistics, we require
to pool the kernel periodically to obtain this information. This is
OK if the number of flows is relatively low. However, in case that
the number of flows is huge, we can spend a considerable amount of
cycles to iterate over the list of flows that have been obtained.

Moreover, if we want to obtain the sum of the flow accounting results
that match some criteria, we have to iterate over the whole list of
existing flows, look for matchings and update the counters.

This patchset adds the extended accounting infrastructure in
kernel-space. It is composed of one nfnetlink interface that
allows you to create, to update and to retrieve accounting objects.
These objects can be used to account traffic with the flexibility
that iptables rules provide (by means of the new NFACCT target).

Quick example of use:

1) You create the accounting object:

libnetfilter_acct/examples# ./nfacct-add http-traffic

2) Add the iptables rules for traffic you want to account:

# iptables -I INPUT -p tcp --sport 80 -j NFACCT --nfacct-name http-traffic
# iptables -I OUTPUT -p tcp --dport 80 -j NFACCT --nfacct-name http-traffic

3) Retrieve the counters.

libnetfilter_acct/examples# ./nfacct-get
http-traffic = { pkts = 000000000125,   bytes = 000000023162 };

You can also atomically retrieve and zero counters in case that you
want to collect information periodically.

This comes with the user-space libnetfilter_acct library:

http://1984.lsi.us.es/git/libnetfilter_acct/

[Note: The current library API is still quite preliminary. I plan
to heavily rework it]

And the NFACCT extension for user-space iptables is here:

http://1984.lsi.us.es/git/iptables/commit/?id=850104ff9d619a7e0bc561aa16fee838fcd1937c

Comments welcome!

Pablo Neira Ayuso (2):
  netfilter: add extended accounting infrastructure over nfnetlink
  netfilter: xtables: add NFACCT target to support extended accounting

 include/linux/netfilter/Kbuild           |    2 +
 include/linux/netfilter/nfnetlink.h      |    3 +-
 include/linux/netfilter/nfnetlink_acct.h |   34 +++
 include/linux/netfilter/xt_NFACCT.h      |   17 ++
 net/netfilter/Kconfig                    |   18 ++
 net/netfilter/Makefile                   |    2 +
 net/netfilter/nfnetlink_acct.c           |  352 ++++++++++++++++++++++++++++++
 net/netfilter/xt_NFACCT.c                |   78 +++++++
 8 files changed, 505 insertions(+), 1 deletions(-)
 create mode 100644 include/linux/netfilter/nfnetlink_acct.h
 create mode 100644 include/linux/netfilter/xt_NFACCT.h
 create mode 100644 net/netfilter/nfnetlink_acct.c
 create mode 100644 net/netfilter/xt_NFACCT.c

-- 
1.7.2.5


^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2011-12-24  0:55 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-23 13:42 [PATCH 0/2] nfacct infrastructure (version 2) pablo
2011-12-23 13:42 ` [PATCH 1/2] netfilter: add extended accounting infrastructure over nfnetlink pablo
2011-12-23 14:10   ` Eric Dumazet
2011-12-23 14:12     ` Eric Dumazet
2011-12-24  0:24       ` Pablo Neira Ayuso
2011-12-24  0:23     ` Pablo Neira Ayuso
2011-12-23 14:54   ` Changli Gao
2011-12-24  0:55     ` Pablo Neira Ayuso
2011-12-23 13:42 ` [PATCH 2/2] netfilter: xtables: add nfacct match to support extended accounting pablo
  -- strict thread matches above, loose matches on Subject: below --
2011-12-14 11:00 [PATCH 0/2] [RFC] Extended accounting infrastructure for iptables pablo
2011-12-14 11:00 ` [PATCH 1/2] netfilter: add extended accounting infrastructure over nfnetlink pablo
2011-12-14 11:16   ` Eric Dumazet
2011-12-14 12:41     ` Pablo Neira Ayuso
2011-12-14 13:18       ` Eric Dumazet
2011-12-14 13:45         ` Eric Dumazet
2011-12-18  0:21           ` Pablo Neira Ayuso
2011-12-14 11:23   ` Patrick McHardy
2011-12-14 13:18     ` Pablo Neira Ayuso
2011-12-14 16:31       ` Patrick McHardy
2011-12-15 12:20         ` Pablo Neira Ayuso
2011-12-14 13:23   ` Changli Gao
2011-12-14 13:43   ` Jan Engelhardt
2011-12-14 16:50     ` Pablo Neira Ayuso
2011-12-14 18:30       ` Jozsef Kadlecsik
2011-12-14 23:06         ` Maciej Żenczykowski
2011-12-15 12:26         ` Pablo Neira Ayuso
2011-12-15 12:32           ` Jan Engelhardt
2011-12-14 13:49   ` Anand Raj Manickam
2011-12-14 13:54     ` Eric Dumazet

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