Commit 42193ffd authored by Vasily Averin's avatar Vasily Averin Committed by Pablo Neira Ayuso
Browse files

netfilter: nf_tables: memcg accounting for dynamically allocated objects



nft_*.c files whose NFT_EXPR_STATEFUL flag is set on need to
use __GFP_ACCOUNT flag for objects that are dynamically
allocated from the packet path.

Such objects are allocated inside nft_expr_ops->init() callbacks
executed in task context while processing netlink messages.

In addition, this patch adds accounting to nft_set_elem_expr_clone()
used for the same purposes.

Signed-off-by: default avatarVasily Averin <vvs@openvz.org>
Acked-by: default avatarRoman Gushchin <roman.gushchin@linux.dev>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 31818213
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5526,7 +5526,7 @@ int nft_set_elem_expr_clone(const struct nft_ctx *ctx, struct nft_set *set,
	int err, i, k;

	for (i = 0; i < set->num_exprs; i++) {
		expr = kzalloc(set->exprs[i]->ops->size, GFP_KERNEL);
		expr = kzalloc(set->exprs[i]->ops->size, GFP_KERNEL_ACCOUNT);
		if (!expr)
			goto err_expr;

+1 −1
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ static int nft_connlimit_do_init(const struct nft_ctx *ctx,
			invert = true;
	}

	priv->list = kmalloc(sizeof(*priv->list), GFP_KERNEL);
	priv->list = kmalloc(sizeof(*priv->list), GFP_KERNEL_ACCOUNT);
	if (!priv->list)
		return -ENOMEM;

+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ static int nft_counter_do_init(const struct nlattr * const tb[],
	struct nft_counter __percpu *cpu_stats;
	struct nft_counter *this_cpu;

	cpu_stats = alloc_percpu(struct nft_counter);
	cpu_stats = alloc_percpu_gfp(struct nft_counter, GFP_KERNEL_ACCOUNT);
	if (cpu_stats == NULL)
		return -ENOMEM;

+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ static int nft_last_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
	u64 last_jiffies;
	int err;

	last = kzalloc(sizeof(*last), GFP_KERNEL);
	last = kzalloc(sizeof(*last), GFP_KERNEL_ACCOUNT);
	if (!last)
		return -ENOMEM;

+1 −1
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ static int nft_limit_init(struct nft_limit_priv *priv,
				 priv->rate);
	}

	priv->limit = kmalloc(sizeof(*priv->limit), GFP_KERNEL);
	priv->limit = kmalloc(sizeof(*priv->limit), GFP_KERNEL_ACCOUNT);
	if (!priv->limit)
		return -ENOMEM;

Loading