Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: nfnetlink_acct: Adding quota support to accounting framework

nfacct objects already support accounting at the byte and packet
level. As such it is a natural extension to add the possiblity to
define a ceiling limit for both metrics.

All the support for quotas itself is added to nfnetlink acctounting
framework to stay coherent with current accounting object management.
Quota limit checks are implemented in xt_nfacct filter where
statistic collection is already done.

Pablo Neira Ayuso has also contributed to this feature.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

authored by

Mathieu Poirier and committed by
Pablo Neira Ayuso
683399ed 1404c3ab

+107 -2
+2
include/uapi/linux/netfilter/nfnetlink.h
··· 20 20 #define NFNLGRP_CONNTRACK_EXP_DESTROY NFNLGRP_CONNTRACK_EXP_DESTROY 21 21 NFNLGRP_NFTABLES, 22 22 #define NFNLGRP_NFTABLES NFNLGRP_NFTABLES 23 + NFNLGRP_ACCT_QUOTA, 24 + #define NFNLGRP_ACCT_QUOTA NFNLGRP_ACCT_QUOTA 23 25 __NFNLGRP_MAX, 24 26 }; 25 27 #define NFNLGRP_MAX (__NFNLGRP_MAX - 1)
+4 -1
net/netfilter/xt_nfacct.c
··· 21 21 22 22 static bool nfacct_mt(const struct sk_buff *skb, struct xt_action_param *par) 23 23 { 24 + int overquota; 24 25 const struct xt_nfacct_match_info *info = par->targinfo; 25 26 26 27 nfnl_acct_update(skb, info->nfacct); 27 28 28 - return true; 29 + overquota = nfnl_acct_overquota(skb, info->nfacct); 30 + 31 + return overquota == NFACCT_UNDERQUOTA ? false : true; 29 32 } 30 33 31 34 static int