13 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
14 #include <linux/module.h>
15 #include <linux/netdevice.h>
17 #include <linux/netfilter/x_tables.h>
18 #include <linux/netfilter_bridge/ebtables.h>
23 #define MAX_CPJ (0xFFFFFFFF / (HZ*60*60*24))
25 #define _POW2_BELOW2(x) ((x)|((x)>>1))
26 #define _POW2_BELOW4(x) (_POW2_BELOW2(x)|_POW2_BELOW2((x)>>2))
27 #define _POW2_BELOW8(x) (_POW2_BELOW4(x)|_POW2_BELOW4((x)>>4))
28 #define _POW2_BELOW16(x) (_POW2_BELOW8(x)|_POW2_BELOW8((x)>>8))
29 #define _POW2_BELOW32(x) (_POW2_BELOW16(x)|_POW2_BELOW16((x)>>16))
30 #define POW2_BELOW32(x) ((_POW2_BELOW32(x)>>1) + 1)
32 #define CREDITS_PER_JIFFY POW2_BELOW32(MAX_CPJ)
40 spin_lock_bh(&limit_lock);
48 spin_unlock_bh(&limit_lock);
52 spin_unlock_bh(&limit_lock);
73 if (info->
burst == 0 ||
74 user2credits(info->
avg * info->
burst) < user2credits(info->
avg)) {
75 pr_info(
"overflow, try lower: %u/%u\n",
84 info->
cost = user2credits(info->
avg);
94 struct ebt_compat_limit_info {
105 .match = ebt_limit_mt,
106 .checkentry = ebt_limit_mt_check,
109 .compatsize =
sizeof(
struct ebt_compat_limit_info),
114 static int __init ebt_limit_init(
void)
119 static void __exit ebt_limit_fini(
void)