History

netfilter: xt_quota: fix the behavior of xt_quota module

A major flaw of the current xt_quota module is that quota in a specific rule gets reset every time there is a rule change in the same table. It makes the xt_quota module not very useful in a table in which iptables rules are changed at run time. This fix introduces a new counter that is visible to userspace as the remaining quota of the current rule. When userspace restores the rules in a table, it can restore the counter to the remaining quota instead of resetting it to the full quota.

Chenbo Feng committed 8 years ago

Commit e9837e51 parent a2d88182 files · +27 −36Browse files

Showing the changes to include/uapi/linux (1 of 2 files). Show all

Unified · Split

include/uapi/linux/netfilter/xt_quota.h+5−3
@@ -15,9 +15,11 @@ struct xt_quota_info { · 14 unmodified lines
1515 __u32 flags;
1616 __u32 pad;
1717 __aligned_u64 quota;
18−
19− /* Used internally by the kernel */
20− struct xt_quota_priv *master;
18+#ifdef __KERNEL__
19+ atomic64_t counter;
20+#else
21+ __aligned_u64 remain;
22+#endif
2123 };
2224
2325 #endif /* _XT_QUOTA_H */