X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=net%2Fnetfilter%2Fxt_pkttype.c;h=7936f7e23254bcfdaf1a8a867f9bf9b41129c8a9;hb=e2205a156f4dd727097f7f492bf03aa8920b0071;hp=c598bbed8e09f7a49d08018591409dc86f29ec70;hpb=d3c5ee6d545b5372fd525ebe16988a5b6efeceb0;p=linux-2.6 diff --git a/net/netfilter/xt_pkttype.c b/net/netfilter/xt_pkttype.c index c598bbed8e..7936f7e232 100644 --- a/net/netfilter/xt_pkttype.c +++ b/net/netfilter/xt_pkttype.c @@ -11,13 +11,14 @@ #include #include #include +#include #include #include MODULE_LICENSE("GPL"); MODULE_AUTHOR("Michal Ludvig "); -MODULE_DESCRIPTION("IP tables match to match on linklayer packet type"); +MODULE_DESCRIPTION("Xtables: link layer packet type match"); MODULE_ALIAS("ipt_pkttype"); MODULE_ALIAS("ip6t_pkttype"); @@ -27,15 +28,19 @@ pkttype_mt(const struct sk_buff *skb, const struct net_device *in, const void *matchinfo, int offset, unsigned int protoff, bool *hotdrop) { - u_int8_t type; const struct xt_pkttype_info *info = matchinfo; + u_int8_t type; - if (skb->pkt_type == PACKET_LOOPBACK) - type = MULTICAST(ip_hdr(skb)->daddr) - ? PACKET_MULTICAST - : PACKET_BROADCAST; - else + if (skb->pkt_type != PACKET_LOOPBACK) type = skb->pkt_type; + else if (match->family == AF_INET && + ipv4_is_multicast(ip_hdr(skb)->daddr)) + type = PACKET_MULTICAST; + else if (match->family == AF_INET6 && + ipv6_hdr(skb)->daddr.s6_addr[0] == 0xFF) + type = PACKET_MULTICAST; + else + type = PACKET_BROADCAST; return (type == info->pkttype) ^ info->invert; }