]> err.no Git - linux-2.6/blobdiff - net/bridge/netfilter/ebt_among.c
Merge branch 'for-2.6.27' of git://git.marvell.com/mv643xx_eth into upstream-next
[linux-2.6] / net / bridge / netfilter / ebt_among.c
index a614485828af31e78559d6bb610439b4f3353296..70b6dca5ea755502a74e294546156a8bea345509 100644 (file)
 #include <linux/module.h>
 
 static int ebt_mac_wormhash_contains(const struct ebt_mac_wormhash *wh,
-                                    const char *mac, uint32_t ip)
+                                    const char *mac, __be32 ip)
 {
        /* You may be puzzled as to how this code works.
-        * Some tricks were used, refer to 
+        * Some tricks were used, refer to
         *      include/linux/netfilter_bridge/ebt_among.h
         * as there you can find a solution of this mystery.
         */
        const struct ebt_mac_wormhash_tuple *p;
        int start, limit, i;
        uint32_t cmp[2] = { 0, 0 };
-       int key = (const unsigned char) mac[5];
+       int key = ((const unsigned char *)mac)[5];
 
        memcpy(((char *) cmp) + 2, mac, 6);
        start = wh->table[key];
@@ -70,27 +70,30 @@ static int ebt_mac_wormhash_check_integrity(const struct ebt_mac_wormhash
        return 0;
 }
 
-static int get_ip_dst(const struct sk_buff *skb, uint32_t *addr)
+static int get_ip_dst(const struct sk_buff *skb, __be32 *addr)
 {
        if (eth_hdr(skb)->h_proto == htons(ETH_P_IP)) {
-               struct iphdr _iph, *ih;
+               const struct iphdr *ih;
+               struct iphdr _iph;
 
                ih = skb_header_pointer(skb, 0, sizeof(_iph), &_iph);
                if (ih == NULL)
                        return -1;
                *addr = ih->daddr;
        } else if (eth_hdr(skb)->h_proto == htons(ETH_P_ARP)) {
-               struct arphdr _arph, *ah;
-               uint32_t buf, *bp;
+               const struct arphdr *ah;
+               struct arphdr _arph;
+               const __be32 *bp;
+               __be32 buf;
 
                ah = skb_header_pointer(skb, 0, sizeof(_arph), &_arph);
                if (ah == NULL ||
-                   ah->ar_pln != sizeof(uint32_t) ||
+                   ah->ar_pln != sizeof(__be32) ||
                    ah->ar_hln != ETH_ALEN)
                        return -1;
                bp = skb_header_pointer(skb, sizeof(struct arphdr) +
-                                       2 * ETH_ALEN + sizeof(uint32_t),
-                                       sizeof(uint32_t), &buf);
+                                       2 * ETH_ALEN + sizeof(__be32),
+                                       sizeof(__be32), &buf);
                if (bp == NULL)
                        return -1;
                *addr = *bp;
@@ -98,26 +101,29 @@ static int get_ip_dst(const struct sk_buff *skb, uint32_t *addr)
        return 0;
 }
 
-static int get_ip_src(const struct sk_buff *skb, uint32_t *addr)
+static int get_ip_src(const struct sk_buff *skb, __be32 *addr)
 {
        if (eth_hdr(skb)->h_proto == htons(ETH_P_IP)) {
-               struct iphdr _iph, *ih;
+               const struct iphdr *ih;
+               struct iphdr _iph;
 
                ih = skb_header_pointer(skb, 0, sizeof(_iph), &_iph);
                if (ih == NULL)
                        return -1;
                *addr = ih->saddr;
        } else if (eth_hdr(skb)->h_proto == htons(ETH_P_ARP)) {
-               struct arphdr _arph, *ah;
-               uint32_t buf, *bp;
+               const struct arphdr *ah;
+               struct arphdr _arph;
+               const __be32 *bp;
+               __be32 buf;
 
                ah = skb_header_pointer(skb, 0, sizeof(_arph), &_arph);
                if (ah == NULL ||
-                   ah->ar_pln != sizeof(uint32_t) ||
+                   ah->ar_pln != sizeof(__be32) ||
                    ah->ar_hln != ETH_ALEN)
                        return -1;
                bp = skb_header_pointer(skb, sizeof(struct arphdr) +
-                                       ETH_ALEN, sizeof(uint32_t), &buf);
+                                       ETH_ALEN, sizeof(__be32), &buf);
                if (bp == NULL)
                        return -1;
                *addr = *bp;
@@ -130,10 +136,10 @@ static int ebt_filter_among(const struct sk_buff *skb,
                            const struct net_device *out, const void *data,
                            unsigned int datalen)
 {
-       struct ebt_among_info *info = (struct ebt_among_info *) data;
+       const struct ebt_among_info *info = data;
        const char *dmac, *smac;
        const struct ebt_mac_wormhash *wh_dst, *wh_src;
-       uint32_t dip = 0, sip = 0;
+       __be32 dip = 0, sip = 0;
 
        wh_dst = ebt_among_wh_dst(info);
        wh_src = ebt_among_wh_src(info);
@@ -175,7 +181,7 @@ static int ebt_among_check(const char *tablename, unsigned int hookmask,
                           const struct ebt_entry *e, void *data,
                           unsigned int datalen)
 {
-       struct ebt_among_info *info = (struct ebt_among_info *) data;
+       const struct ebt_among_info *info = data;
        int expected_length = sizeof(struct ebt_among_info);
        const struct ebt_mac_wormhash *wh_dst, *wh_src;
        int err;
@@ -187,7 +193,7 @@ static int ebt_among_check(const char *tablename, unsigned int hookmask,
 
        if (datalen != EBT_ALIGN(expected_length)) {
                printk(KERN_WARNING
-                      "ebtables: among: wrong size: %d"
+                      "ebtables: among: wrong size: %d "
                       "against expected %d, rounded to %Zd\n",
                       datalen, expected_length,
                       EBT_ALIGN(expected_length));
@@ -206,9 +212,9 @@ static int ebt_among_check(const char *tablename, unsigned int hookmask,
        return 0;
 }
 
-static struct ebt_match filter_among = {
-       .name           = EBT_AMONG_MATCH, 
-       .match          = ebt_filter_among, 
+static struct ebt_match filter_among __read_mostly = {
+       .name           = EBT_AMONG_MATCH,
+       .match          = ebt_filter_among,
        .check          = ebt_among_check,
        .me             = THIS_MODULE,
 };
@@ -225,4 +231,5 @@ static void __exit ebt_among_fini(void)
 
 module_init(ebt_among_init);
 module_exit(ebt_among_fini);
+MODULE_DESCRIPTION("Ebtables: Combined MAC/IP address list matching");
 MODULE_LICENSE("GPL");