mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-08 21:54:57 +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;
|
struct xt_quota_counter *e = q->master;
|
||||||
bool ret = q->flags & XT_QUOTA_INVERT;
|
bool ret = q->flags & XT_QUOTA_INVERT;
|
||||||
|
|
||||||
|
spin_lock_bh(&e->lock);
|
||||||
if (q->flags & XT_QUOTA_GROW) {
|
if (q->flags & XT_QUOTA_GROW) {
|
||||||
spin_lock_bh(&e->lock);
|
|
||||||
e->quota += (q->flags & XT_QUOTA_PACKET) ? 1 : skb->len;
|
e->quota += (q->flags & XT_QUOTA_PACKET) ? 1 : skb->len;
|
||||||
q->quota = e->quota;
|
q->quota = e->quota;
|
||||||
spin_unlock_bh(&e->lock);
|
|
||||||
ret = true;
|
ret = true;
|
||||||
} else {
|
} else {
|
||||||
spin_lock_bh(&e->lock);
|
|
||||||
if (e->quota >= skb->len) {
|
if (e->quota >= skb->len) {
|
||||||
e->quota -= (q->flags & XT_QUOTA_PACKET) ? 1 : skb->len;
|
e->quota -= (q->flags & XT_QUOTA_PACKET) ? 1 : skb->len;
|
||||||
ret = !ret;
|
ret = !ret;
|
||||||
@@ -205,9 +203,8 @@ quota_mt2(const struct sk_buff *skb, const struct xt_match_param *par)
|
|||||||
e->quota = 0;
|
e->quota = 0;
|
||||||
}
|
}
|
||||||
q->quota = e->quota;
|
q->quota = e->quota;
|
||||||
spin_unlock_bh(&e->lock);
|
|
||||||
}
|
}
|
||||||
|
spin_unlock_bh(&e->lock);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user