netfilter: add dummy members to Ebtables code to ease transition to Xtables
[safe/jmp/linux-2.6] / net / bridge / netfilter / ebt_limit.c
index d48fa5c..9ca0a25 100644 (file)
  *  September, 2003
  *
  */
-
-#include <linux/netfilter_bridge/ebtables.h>
-#include <linux/netfilter_bridge/ebt_limit.h>
 #include <linux/module.h>
-
 #include <linux/netdevice.h>
 #include <linux/spinlock.h>
+#include <linux/netfilter/x_tables.h>
+#include <linux/netfilter_bridge/ebtables.h>
+#include <linux/netfilter_bridge/ebt_limit.h>
 
 static DEFINE_SPINLOCK(limit_lock);
 
@@ -31,7 +30,7 @@ static DEFINE_SPINLOCK(limit_lock);
 
 #define CREDITS_PER_JIFFY POW2_BELOW32(MAX_CPJ)
 
-static int ebt_limit_match(const struct sk_buff *skb,
+static bool ebt_limit_match(const struct sk_buff *skb,
    const struct net_device *in, const struct net_device *out,
    const void *data, unsigned int datalen)
 {
@@ -47,11 +46,11 @@ static int ebt_limit_match(const struct sk_buff *skb,
                /* We're not limited. */
                info->credit -= info->cost;
                spin_unlock_bh(&limit_lock);
-               return EBT_MATCH;
+               return true;
        }
 
        spin_unlock_bh(&limit_lock);
-       return EBT_NOMATCH;
+       return false;
 }
 
 /* Precision saver. */
@@ -66,20 +65,17 @@ user2credits(u_int32_t user)
        return (user * HZ * CREDITS_PER_JIFFY) / EBT_LIMIT_SCALE;
 }
 
-static int ebt_limit_check(const char *tablename, unsigned int hookmask,
+static bool ebt_limit_check(const char *tablename, unsigned int hookmask,
    const struct ebt_entry *e, void *data, unsigned int datalen)
 {
-       struct ebt_limit_info *info = (struct ebt_limit_info *)data;
-
-       if (datalen != EBT_ALIGN(sizeof(struct ebt_limit_info)))
-               return -EINVAL;
+       struct ebt_limit_info *info = data;
 
        /* Check for overflow. */
        if (info->burst == 0 ||
            user2credits(info->avg * info->burst) < user2credits(info->avg)) {
                printk("Overflow in ebt_limit, try lower: %u/%u\n",
                        info->avg, info->burst);
-               return -EINVAL;
+               return false;
        }
 
        /* User avg in seconds * EBT_LIMIT_SCALE: convert to jiffies * 128. */
@@ -87,14 +83,16 @@ static int ebt_limit_check(const char *tablename, unsigned int hookmask,
        info->credit = user2credits(info->avg * info->burst);
        info->credit_cap = user2credits(info->avg * info->burst);
        info->cost = user2credits(info->avg);
-       return 0;
+       return true;
 }
 
-static struct ebt_match ebt_limit_reg =
-{
+static struct ebt_match ebt_limit_reg __read_mostly = {
        .name           = EBT_LIMIT_MATCH,
+       .revision       = 0,
+       .family         = NFPROTO_BRIDGE,
        .match          = ebt_limit_match,
        .check          = ebt_limit_check,
+       .matchsize      = XT_ALIGN(sizeof(struct ebt_limit_info)),
        .me             = THIS_MODULE,
 };
 
@@ -110,4 +108,5 @@ static void __exit ebt_limit_fini(void)
 
 module_init(ebt_limit_init);
 module_exit(ebt_limit_fini);
+MODULE_DESCRIPTION("Ebtables: Rate-limit match");
 MODULE_LICENSE("GPL");