netfilter: ipset: make ip_set_get_ip*_port to use skb_network_offset
authorAlexander Drozdov <al.drozdov@gmail.com>
Sat, 2 May 2015 17:28:01 +0000 (19:28 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 13 May 2015 11:25:45 +0000 (13:25 +0200)
All the ipset functions respect skb->network_header value,
except for ip_set_get_ip4_port() & ip_set_get_ip6_port(). The
functions should use skb_network_offset() to get the transport
header offset.

Signed-off-by: Alexander Drozdov <al.drozdov@gmail.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/ipset/ip_set_getport.c

index 29fb01ddff93b0a0da7ad1dc3691a141376f5007..1981f021cc60a25f57c68dc498f1c67926228b1f 100644 (file)
@@ -98,7 +98,7 @@ ip_set_get_ip4_port(const struct sk_buff *skb, bool src,
                    __be16 *port, u8 *proto)
 {
        const struct iphdr *iph = ip_hdr(skb);
-       unsigned int protooff = ip_hdrlen(skb);
+       unsigned int protooff = skb_network_offset(skb) + ip_hdrlen(skb);
        int protocol = iph->protocol;
 
        /* See comments at tcp_match in ip_tables.c */
@@ -135,7 +135,9 @@ ip_set_get_ip6_port(const struct sk_buff *skb, bool src,
        __be16 frag_off = 0;
 
        nexthdr = ipv6_hdr(skb)->nexthdr;
-       protoff = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &nexthdr,
+       protoff = ipv6_skip_exthdr(skb,
+                                  skb_network_offset(skb) +
+                                       sizeof(struct ipv6hdr), &nexthdr,
                                   &frag_off);
        if (protoff < 0 || (frag_off & htons(~0x7)) != 0)
                return false;