Commit 22609b43 authored by Pablo Neira Ayuso's avatar Pablo Neira Ayuso

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: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent db6d857b
...@@ -21,10 +21,10 @@ struct nft_quota { ...@@ -21,10 +21,10 @@ struct nft_quota {
atomic64_t remain; atomic64_t remain;
}; };
static inline long nft_quota(struct nft_quota *priv, static inline bool nft_overquota(struct nft_quota *priv,
const struct nft_pktinfo *pkt) const struct nft_pktinfo *pkt)
{ {
return atomic64_sub_return(pkt->skb->len, &priv->remain); return atomic64_sub_return(pkt->skb->len, &priv->remain) < 0;
} }
static void nft_quota_eval(const struct nft_expr *expr, static void nft_quota_eval(const struct nft_expr *expr,
...@@ -33,7 +33,7 @@ static void nft_quota_eval(const struct nft_expr *expr, ...@@ -33,7 +33,7 @@ static void nft_quota_eval(const struct nft_expr *expr,
{ {
struct nft_quota *priv = nft_expr_priv(expr); struct nft_quota *priv = nft_expr_priv(expr);
if ((nft_quota(priv, pkt) < 0) ^ priv->invert) if (nft_overquota(priv, pkt) ^ priv->invert)
regs->verdict.code = NFT_BREAK; regs->verdict.code = NFT_BREAK;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment