mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-07 13:15:12 +02:00
quota2: consolidate spinlocking calls
This commit is contained in:
@@ -189,14 +189,12 @@ quota_mt2(const struct sk_buff *skb, const struct xt_match_param *par)
|
||||
struct xt_quota_counter *e = q->master;
|
||||
bool ret = q->flags & XT_QUOTA_INVERT;
|
||||
|
||||
spin_lock_bh(&e->lock);
|
||||
if (q->flags & XT_QUOTA_GROW) {
|
||||
spin_lock_bh(&e->lock);
|
||||
e->quota += (q->flags & XT_QUOTA_PACKET) ? 1 : skb->len;
|
||||
q->quota = e->quota;
|
||||
spin_unlock_bh(&e->lock);
|
||||
ret = true;
|
||||
} else {
|
||||
spin_lock_bh(&e->lock);
|
||||
if (e->quota >= skb->len) {
|
||||
e->quota -= (q->flags & XT_QUOTA_PACKET) ? 1 : skb->len;
|
||||
ret = !ret;
|
||||
@@ -205,9 +203,8 @@ quota_mt2(const struct sk_buff *skb, const struct xt_match_param *par)
|
||||
e->quota = 0;
|
||||
}
|
||||
q->quota = e->quota;
|
||||
spin_unlock_bh(&e->lock);
|
||||
}
|
||||
|
||||
spin_unlock_bh(&e->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user