Skip to content

Commit 22609b4

Browse files
committed
netfilter: nft_quota: introduce nft_overquota()
This is patch renames the existing function to nft_overquota() and make it return a boolean that tells us if we have exceeded our byte quota. Just a cleanup. Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent db6d857 commit 22609b4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

net/netfilter/nft_quota.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ struct nft_quota {
2121
atomic64_t remain;
2222
};
2323

24-
static inline long nft_quota(struct nft_quota *priv,
25-
const struct nft_pktinfo *pkt)
24+
static inline bool nft_overquota(struct nft_quota *priv,
25+
const struct nft_pktinfo *pkt)
2626
{
27-
return atomic64_sub_return(pkt->skb->len, &priv->remain);
27+
return atomic64_sub_return(pkt->skb->len, &priv->remain) < 0;
2828
}
2929

3030
static void nft_quota_eval(const struct nft_expr *expr,
@@ -33,7 +33,7 @@ static void nft_quota_eval(const struct nft_expr *expr,
3333
{
3434
struct nft_quota *priv = nft_expr_priv(expr);
3535

36-
if ((nft_quota(priv, pkt) < 0) ^ priv->invert)
36+
if (nft_overquota(priv, pkt) ^ priv->invert)
3737
regs->verdict.code = NFT_BREAK;
3838
}
3939

0 commit comments

Comments
 (0)