]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
netfilter: xtables: limit xt_mac to ethernet devices
authorJan Engelhardt <jengelh@medozas.de>
Tue, 16 Mar 2010 20:44:44 +0000 (21:44 +0100)
committerJan Engelhardt <jengelh@medozas.de>
Thu, 18 Mar 2010 13:20:06 +0000 (14:20 +0100)
I do not see a point of allowing the MAC module to work with devices
that don't possibly have one, e.g. various tunnel interfaces such as
tun and sit.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
net/netfilter/xt_mac.c

index 2039d0741b37d012be9b065898483675f25aedb7..b971ce93773e6648890bf23dacd995c52ec9b7e2 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <linux/module.h>
 #include <linux/skbuff.h>
+#include <linux/if_arp.h>
 #include <linux/if_ether.h>
 #include <linux/etherdevice.h>
 
@@ -29,6 +30,8 @@ static bool mac_mt(const struct sk_buff *skb, const struct xt_match_param *par)
        const struct xt_mac_info *info = par->matchinfo;
        bool ret;
 
+       if (skb->dev == NULL || skb->dev->type != ARPHRD_ETHER)
+               return false;
        if (skb_mac_header(skb) < skb->head)
                return false;
        if (skb_mac_header(skb) + ETH_HLEN > skb->data)