Skip to content

Commit aabef97

Browse files
committed
netfilter: nft_quota: copy content when cloning expression
If the ruleset contains consumed quota, restore them accordingly. Otherwise, listing after restoration shows never used items. Restore the user-defined quota and flags too. Fixes: ed0a0c6 ("netfilter: nft_quota: move stateful fields out of expression data") Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 860e874 commit aabef97

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

net/netfilter/nft_quota.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,16 @@ static void nft_quota_destroy(const struct nft_ctx *ctx,
236236
static int nft_quota_clone(struct nft_expr *dst, const struct nft_expr *src)
237237
{
238238
struct nft_quota *priv_dst = nft_expr_priv(dst);
239+
struct nft_quota *priv_src = nft_expr_priv(src);
240+
241+
priv_dst->quota = priv_src->quota;
242+
priv_dst->flags = priv_src->flags;
239243

240244
priv_dst->consumed = kmalloc(sizeof(*priv_dst->consumed), GFP_ATOMIC);
241245
if (!priv_dst->consumed)
242246
return -ENOMEM;
243247

244-
atomic64_set(priv_dst->consumed, 0);
248+
*priv_dst->consumed = *priv_src->consumed;
245249

246250
return 0;
247251
}

0 commit comments

Comments
 (0)