[SK_BUFF]: Introduce ip_hdr(), remove skb->nh.iph
[pandora-kernel.git] / net / ipv4 / netfilter / ip_conntrack_proto_udp.c
index d0e8a16..3b47987 100644 (file)
@@ -7,7 +7,6 @@
  */
 
 #include <linux/types.h>
-#include <linux/sched.h>
 #include <linux/timer.h>
 #include <linux/netfilter.h>
 #include <linux/in.h>
@@ -70,7 +69,7 @@ static int udp_packet(struct ip_conntrack *conntrack,
        /* If we've seen traffic both ways, this is some kind of UDP
           stream.  Extend timeout. */
        if (test_bit(IPS_SEEN_REPLY_BIT, &conntrack->status)) {
-               ip_ct_refresh_acct(conntrack, ctinfo, skb, 
+               ip_ct_refresh_acct(conntrack, ctinfo, skb,
                                   ip_ct_udp_timeout_stream);
                /* Also, more likely to be important, and not a probe */
                if (!test_and_set_bit(IPS_ASSURED_BIT, &conntrack->status))
@@ -90,19 +89,19 @@ static int udp_new(struct ip_conntrack *conntrack, const struct sk_buff *skb)
 static int udp_error(struct sk_buff *skb, enum ip_conntrack_info *ctinfo,
                     unsigned int hooknum)
 {
-       struct iphdr *iph = skb->nh.iph;
-       unsigned int udplen = skb->len - iph->ihl * 4;
+       const unsigned int hdrlen = ip_hdrlen(skb);
+       unsigned int udplen = skb->len - hdrlen;
        struct udphdr _hdr, *hdr;
 
        /* Header is too small? */
-       hdr = skb_header_pointer(skb, iph->ihl*4, sizeof(_hdr), &_hdr);
+       hdr = skb_header_pointer(skb, hdrlen, sizeof(_hdr), &_hdr);
        if (hdr == NULL) {
                if (LOG_INVALID(IPPROTO_UDP))
                        nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL,
                                  "ip_ct_udp: short packet ");
                return -NF_ACCEPT;
        }
-       
+
        /* Truncated/malformed packets */
        if (ntohs(hdr->len) > udplen || ntohs(hdr->len) < sizeof(*hdr)) {
                if (LOG_INVALID(IPPROTO_UDP))
@@ -110,7 +109,7 @@ static int udp_error(struct sk_buff *skb, enum ip_conntrack_info *ctinfo,
                                  "ip_ct_udp: truncated/malformed packet ");
                return -NF_ACCEPT;
        }
-       
+
        /* Packet with no checksum */
        if (!hdr->check)
                return NF_ACCEPT;
@@ -120,13 +119,13 @@ static int udp_error(struct sk_buff *skb, enum ip_conntrack_info *ctinfo,
         * because the checksum is assumed to be correct.
         * FIXME: Source route IP option packets --RR */
        if (ip_conntrack_checksum && hooknum == NF_IP_PRE_ROUTING &&
-           nf_ip_checksum(skb, hooknum, iph->ihl * 4, IPPROTO_UDP)) {
+           nf_ip_checksum(skb, hooknum, hdrlen, IPPROTO_UDP)) {
                if (LOG_INVALID(IPPROTO_UDP))
                        nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL,
                                  "ip_ct_udp: bad UDP checksum ");
                return -NF_ACCEPT;
        }
-       
+
        return NF_ACCEPT;
 }