if (skb->h.th->doff > 5) {
                        tcp_opt_len = (skb->h.th->doff - 5) << 2;
                }
-               ip_tcp_len = (skb->nh.iph->ihl << 2) + sizeof(struct tcphdr);
+               ip_tcp_len = ip_hdrlen(skb) + sizeof(struct tcphdr);
 
                skb->nh.iph->check = 0;
                skb->nh.iph->tot_len = htons(mss + ip_tcp_len + tcp_opt_len);
 
                                      const struct sk_buff *skb)
 {
        swqe->ip_start = (u8)(((u64)skb->nh.iph) - ((u64)skb->data));
-       swqe->ip_end = (u8)(swqe->ip_start + skb->nh.iph->ihl * 4 - 1);
+       swqe->ip_end = (u8)(swqe->ip_start + ip_hdrlen(skb) - 1);
 }
 
 static inline void write_tcp_offset_end(struct ehea_swqe *swqe,
        /* copy only eth/ip/tcp headers to immediate data and
         * the rest of skb->data to sg1entry
         */
-       headersize = ETH_HLEN + (skb->nh.iph->ihl * 4) + (skb->h.th->doff * 4);
+       headersize = ETH_HLEN + ip_hdrlen(skb) + (skb->h.th->doff * 4);
 
        skb_data_size = skb->len - skb->data_len;
 
 
 #include "netxen_nic_hw.h"
 #include "netxen_nic_phan_reg.h"
 
+#include <net/ip.h>
+
 /*  PCI Windowing for DDR regions.  */
 
 #define ADDR_IN_RANGE(addr, low, high) \
                      struct cmd_desc_type0 *desc, struct sk_buff *skb)
 {
        if (desc->mss) {
-               desc->total_hdr_length = sizeof(struct ethhdr) +
-                   ((skb->nh.iph)->ihl * sizeof(u32)) +
-                   ((skb->h.th)->doff * sizeof(u32));
+               desc->total_hdr_length = (sizeof(struct ethhdr) +
+                                         ip_hdrlen(skb) +
+                                         skb->h.th->doff * 4);
                netxen_set_cmd_desc_opcode(desc, TX_TCP_LSO);
        } else if (skb->ip_summed == CHECKSUM_PARTIAL) {
                if (skb->nh.iph->protocol == IPPROTO_TCP) {
 
 
 #include <linux/dma-mapping.h>
 #include <linux/vmalloc.h>
+#include <net/ip.h>
 
 MODULE_DESCRIPTION("NetXen Multi port (1/10) Gigabit Network Driver");
 MODULE_LICENSE("GPL");
                if (skb_shinfo(skb)->gso_size > 0) {
 
                        no_of_desc++;
-                       if (((skb->nh.iph)->ihl * sizeof(u32)) +
-                           ((skb->h.th)->doff * sizeof(u32)) +
-                           sizeof(struct ethhdr) >
+                       if ((ip_hdrlen(skb) + skb->h.th->doff * 4 +
+                            sizeof(struct ethhdr)) >
                            (sizeof(struct cmd_desc_type0) - 2)) {
                                no_of_desc++;
                        }
 
 #include <linux/ethtool.h>
 #include <linux/pci.h>
 #include <linux/ip.h>
+#include <net/ip.h>
 #include <linux/tcp.h>
 #include <linux/in.h>
 #include <linux/delay.h>
        mss = skb_shinfo(skb)->gso_size;
        if (mss != 0) {
                mss += ((skb->h.th->doff - 5) * 4);     /* TCP options */
-               mss += (skb->nh.iph->ihl * 4) + sizeof(struct tcphdr);
+               mss += ip_hdrlen(skb) + sizeof(struct tcphdr);
                mss += ETH_HLEN;
 
                if (mss != sky2->tx_last_mss) {
 
 #include <linux/dma-mapping.h>
 
 #include <net/checksum.h>
+#include <net/ip.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
                        mss |= (skb_headlen(skb) - ETH_HLEN) << 9;
                else {
                        tcp_opt_len = ((skb->h.th->doff - 5) * 4);
-                       ip_tcp_len = (skb->nh.iph->ihl * 4) +
-                                    sizeof(struct tcphdr);
+                       ip_tcp_len = ip_hdrlen(skb) + sizeof(struct tcphdr);
 
                        skb->nh.iph->check = 0;
                        skb->nh.iph->tot_len = htons(mss + ip_tcp_len +
                }
 
                tcp_opt_len = ((skb->h.th->doff - 5) * 4);
-               ip_tcp_len = (skb->nh.iph->ihl * 4) + sizeof(struct tcphdr);
+               ip_tcp_len = ip_hdrlen(skb) + sizeof(struct tcphdr);
 
                hdr_len = ip_tcp_len + tcp_opt_len;
                if (unlikely((ETH_HLEN + hdr_len) > 80) &&
 
        QETH_DBF_TEXT(trace, 5, "eddpficx");
        /* create our segmentation headers and copy original headers */
        if (skb->protocol == htons(ETH_P_IP))
-               eddp = qeth_eddp_create_eddp_data(qhdr, (u8 *)skb->nh.iph,
-                               skb->nh.iph->ihl*4,
-                               (u8 *)skb->h.th, skb->h.th->doff*4);
+               eddp = qeth_eddp_create_eddp_data(qhdr,
+                                                 skb_network_header(skb),
+                                                 ip_hdrlen(skb),
+                                                 skb->h.raw,
+                                                 skb->h.th->doff * 4);
        else
                eddp = qeth_eddp_create_eddp_data(qhdr, (u8 *)skb->nh.ipv6h,
                                sizeof(struct ipv6hdr),
        QETH_DBF_TEXT(trace, 5, "creddpct");
        if (skb->protocol == htons(ETH_P_IP))
                ctx = qeth_eddp_create_context_generic(card, skb,
-                       sizeof(struct qeth_hdr) + skb->nh.iph->ihl*4 +
-                       skb->h.th->doff*4);
+                                                      (sizeof(struct qeth_hdr) +
+                                                       ip_hdrlen(skb) +
+                                                       skb->h.th->doff * 4));
        else if (skb->protocol == htons(ETH_P_IPV6))
                ctx = qeth_eddp_create_context_generic(card, skb,
                        sizeof(struct qeth_hdr) + sizeof(struct ipv6hdr) +
 
 #include <linux/types.h>
 #include <linux/ip.h>
 #include <linux/in.h>
+#include <linux/skbuff.h>
 
 #include <net/inet_sock.h>
 #include <net/snmp.h>
 #define IPSKB_REROUTED         16
 };
 
+static inline unsigned int ip_hdrlen(const struct sk_buff *skb)
+{
+       return skb->nh.iph->ihl * 4;
+}
+
 struct ipcm_cookie
 {
        __be32                  addr;
 struct net_device;
 struct packet_type;
 struct rtable;
-struct sk_buff;
 struct sockaddr;
 
 extern void            ip_mc_dropsocket(struct sock *);
 
        flags = offset & ~IP_OFFSET;
        offset &= IP_OFFSET;
        offset <<= 3;           /* offset is in 8-byte chunks */
-       ihl = skb->nh.iph->ihl * 4;
+       ihl = ip_hdrlen(skb);
 
        /* Determine the position of this fragment. */
        end = offset + skb->len - ihl;
        BUG_TRAP(FRAG_CB(head)->offset == 0);
 
        /* Allocate a new buffer for the datagram. */
-       ihlen = head->nh.iph->ihl*4;
+       ihlen = ip_hdrlen(head);
        len = ihlen + qp->len;
 
        if (len > 65535)
 
 
 static inline int ip_local_deliver_finish(struct sk_buff *skb)
 {
-       int ihl = skb->nh.iph->ihl*4;
-
-       __skb_pull(skb, ihl);
+       __skb_pull(skb, ip_hdrlen(skb));
 
        /* Point into the IP datagram, just past the header. */
        skb->h.raw = skb->data;
 
 static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert)
 {
        struct sk_buff *skb;
-       int ihl = pkt->nh.iph->ihl<<2;
+       const int ihl = ip_hdrlen(pkt);
        struct igmphdr *igmp;
        struct igmpmsg *msg;
        int ret;
 
                                  struct ip_vs_app *app)
 {
        int diff;
-       unsigned int tcp_offset = (*pskb)->nh.iph->ihl*4;
+       const unsigned int tcp_offset = ip_hdrlen(*pskb);
        struct tcphdr *th;
        __u32 seq;
 
                                 struct ip_vs_app *app)
 {
        int diff;
-       unsigned int tcp_offset = (*pskb)->nh.iph->ihl*4;
+       const unsigned int tcp_offset = ip_hdrlen(*pskb);
        struct tcphdr *th;
        __u32 seq;
 
 
 {
        struct tcphdr _tcph, *th;
 
-       th = skb_header_pointer(skb, skb->nh.iph->ihl * 4,
-                               sizeof(_tcph), &_tcph);
+       th = skb_header_pointer(skb, ip_hdrlen(skb), sizeof(_tcph), &_tcph);
        if (th == NULL)
                return 0;
        return th->rst;
 
        struct ip_vs_service *svc;
        struct tcphdr _tcph, *th;
 
-       th = skb_header_pointer(skb, skb->nh.iph->ihl*4,
-                               sizeof(_tcph), &_tcph);
+       th = skb_header_pointer(skb, ip_hdrlen(skb), sizeof(_tcph), &_tcph);
        if (th == NULL) {
                *verdict = NF_DROP;
                return 0;
                 struct ip_vs_protocol *pp, struct ip_vs_conn *cp)
 {
        struct tcphdr *tcph;
-       unsigned int tcphoff = (*pskb)->nh.iph->ihl * 4;
+       const unsigned int tcphoff = ip_hdrlen(*pskb);
 
        /* csum_check requires unshared skb */
        if (!ip_vs_make_skb_writable(pskb, tcphoff+sizeof(*tcph)))
                 struct ip_vs_protocol *pp, struct ip_vs_conn *cp)
 {
        struct tcphdr *tcph;
-       unsigned int tcphoff = (*pskb)->nh.iph->ihl * 4;
+       const unsigned int tcphoff = ip_hdrlen(*pskb);
 
        /* csum_check requires unshared skb */
        if (!ip_vs_make_skb_writable(pskb, tcphoff+sizeof(*tcph)))
 static int
 tcp_csum_check(struct sk_buff *skb, struct ip_vs_protocol *pp)
 {
-       unsigned int tcphoff = skb->nh.iph->ihl*4;
+       const unsigned int tcphoff = ip_hdrlen(skb);
 
        switch (skb->ip_summed) {
        case CHECKSUM_NONE:
 {
        struct tcphdr _tcph, *th;
 
-       th = skb_header_pointer(skb, skb->nh.iph->ihl*4,
-                               sizeof(_tcph), &_tcph);
+       th = skb_header_pointer(skb, ip_hdrlen(skb), sizeof(_tcph), &_tcph);
        if (th == NULL)
                return 0;
 
 
 #include <linux/udp.h>
 
 #include <net/ip_vs.h>
-
+#include <net/ip.h>
 
 static struct ip_vs_conn *
 udp_conn_in_get(const struct sk_buff *skb, struct ip_vs_protocol *pp,
        struct ip_vs_conn *cp;
        __be16 _ports[2], *pptr;
 
-       pptr = skb_header_pointer(skb, skb->nh.iph->ihl*4,
+       pptr = skb_header_pointer(skb, ip_hdrlen(skb),
                                  sizeof(_ports), _ports);
        if (pptr == NULL)
                return NULL;
        struct ip_vs_service *svc;
        struct udphdr _udph, *uh;
 
-       uh = skb_header_pointer(skb, skb->nh.iph->ihl*4,
+       uh = skb_header_pointer(skb, ip_hdrlen(skb),
                                sizeof(_udph), &_udph);
        if (uh == NULL) {
                *verdict = NF_DROP;
                 struct ip_vs_protocol *pp, struct ip_vs_conn *cp)
 {
        struct udphdr *udph;
-       unsigned int udphoff = (*pskb)->nh.iph->ihl * 4;
+       const unsigned int udphoff = ip_hdrlen(*pskb);
 
        /* csum_check requires unshared skb */
        if (!ip_vs_make_skb_writable(pskb, udphoff+sizeof(*udph)))
                 struct ip_vs_protocol *pp, struct ip_vs_conn *cp)
 {
        struct udphdr *udph;
-       unsigned int udphoff = (*pskb)->nh.iph->ihl * 4;
+       unsigned int udphoff = ip_hdrlen(*pskb);
 
        /* csum_check requires unshared skb */
        if (!ip_vs_make_skb_writable(pskb, udphoff+sizeof(*udph)))
 udp_csum_check(struct sk_buff *skb, struct ip_vs_protocol *pp)
 {
        struct udphdr _udph, *uh;
-       unsigned int udphoff = skb->nh.iph->ihl*4;
+       const unsigned int udphoff = ip_hdrlen(skb);
 
        uh = skb_header_pointer(skb, udphoff, sizeof(_udph), &_udph);
        if (uh == NULL)
 
        ip_ct_refresh(ct, *pskb, master_timeout * HZ);
 
        /* No data? */
-       dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
+       dataoff = ip_hdrlen(*pskb) + sizeof(struct udphdr);
        if (dataoff >= (*pskb)->len) {
                if (net_ratelimit())
                        printk("amanda_help: skblen = %u\n", (*pskb)->len);
 
 
        IP_NF_ASSERT((skb->nh.iph->frag_off & htons(IP_OFFSET)) == 0);
 
-       if (!ip_ct_get_tuple(skb->nh.iph, skb, skb->nh.iph->ihl*4,
-                               &tuple,proto))
+       if (!ip_ct_get_tuple(skb->nh.iph, skb, ip_hdrlen(skb), &tuple,proto))
                return NULL;
 
        /* look for tuple match */
 
                return NF_ACCEPT;
        }
 
-       th = skb_header_pointer(*pskb, (*pskb)->nh.iph->ihl*4,
+       th = skb_header_pointer(*pskb, ip_hdrlen(*pskb),
                                sizeof(_tcph), &_tcph);
        if (th == NULL)
                return NF_ACCEPT;
 
-       dataoff = (*pskb)->nh.iph->ihl*4 + th->doff*4;
+       dataoff = ip_hdrlen(*pskb) + th->doff * 4;
        /* No data? */
        if (dataoff >= (*pskb)->len) {
                DEBUGP("ftp: pskblen = %u\n", (*pskb)->len);
 
        int tpktoff;
 
        /* Get TCP header */
-       th = skb_header_pointer(*pskb, (*pskb)->nh.iph->ihl * 4,
+       th = skb_header_pointer(*pskb, ip_hdrlen(*pskb),
                                sizeof(_tcph), &_tcph);
        if (th == NULL)
                return 0;
 
        /* Get TCP data offset */
-       tcpdataoff = (*pskb)->nh.iph->ihl * 4 + th->doff * 4;
+       tcpdataoff = ip_hdrlen(*pskb) + th->doff * 4;
 
        /* Get TCP data length */
        tcpdatalen = (*pskb)->len - tcpdataoff;
        struct udphdr _uh, *uh;
        int dataoff;
 
-       uh = skb_header_pointer(*pskb, (*pskb)->nh.iph->ihl * 4, sizeof(_uh),
-                               &_uh);
+       uh = skb_header_pointer(*pskb, ip_hdrlen(*pskb), sizeof(_uh), &_uh);
        if (uh == NULL)
                return NULL;
-       dataoff = (*pskb)->nh.iph->ihl * 4 + sizeof(_uh);
+       dataoff = ip_hdrlen(*pskb) + sizeof(_uh);
        if (dataoff >= (*pskb)->len)
                return NULL;
        *datalen = (*pskb)->len - dataoff;
 
        struct pptp_pkt_hdr _pptph, *pptph;
        struct PptpControlHeader _ctlh, *ctlh;
        union pptp_ctrl_union _pptpReq, *pptpReq;
-       unsigned int tcplen = (*pskb)->len - (*pskb)->nh.iph->ihl * 4;
+       unsigned int tcplen = (*pskb)->len - ip_hdrlen(*pskb);
        unsigned int datalen, reqlen, nexthdr_off;
        int oldsstate, oldcstate;
        int ret;
                return NF_ACCEPT;
        }
 
-       nexthdr_off = (*pskb)->nh.iph->ihl*4;
+       nexthdr_off = ip_hdrlen(*pskb);
        tcph = skb_header_pointer(*pskb, nexthdr_off, sizeof(_tcph), &_tcph);
        BUG_ON(!tcph);
        nexthdr_off += tcph->doff * 4;
 
        }
 
        /* Not a full tcp header? */
-       th = skb_header_pointer(*pskb, (*pskb)->nh.iph->ihl*4,
+       th = skb_header_pointer(*pskb, ip_hdrlen(*pskb),
                                sizeof(_tcph), &_tcph);
        if (th == NULL)
                return NF_ACCEPT;
 
        /* No data? */
-       dataoff = (*pskb)->nh.iph->ihl*4 + th->doff*4;
+       dataoff = ip_hdrlen(*pskb) + th->doff * 4;
        if (dataoff >= (*pskb)->len)
                return NF_ACCEPT;
 
 
        IP_NF_ASSERT(skb->nfct == NULL);
 
        /* Not enough header? */
-       inside = skb_header_pointer(skb, skb->nh.iph->ihl*4, sizeof(_in), &_in);
+       inside = skb_header_pointer(skb, ip_hdrlen(skb), sizeof(_in), &_in);
        if (inside == NULL)
                return -NF_ACCEPT;
 
        }
 
        innerproto = ip_conntrack_proto_find_get(inside->ip.protocol);
-       dataoff = skb->nh.iph->ihl*4 + sizeof(inside->icmp) + inside->ip.ihl*4;
+       dataoff = ip_hdrlen(skb) + sizeof(inside->icmp) + inside->ip.ihl * 4;
        /* Are they talking about one of our connections? */
        if (!ip_ct_get_tuple(&inside->ip, skb, dataoff, &origtuple, innerproto)) {
                DEBUGP("icmp_error: ! get_tuple p=%u", inside->ip.protocol);
        struct icmphdr _ih, *icmph;
 
        /* Not enough header? */
-       icmph = skb_header_pointer(skb, skb->nh.iph->ihl*4, sizeof(_ih), &_ih);
+       icmph = skb_header_pointer(skb, ip_hdrlen(skb), sizeof(_ih), &_ih);
        if (icmph == NULL) {
                if (LOG_INVALID(IPPROTO_ICMP))
                        nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL,
 
        /* See ip_conntrack_proto_tcp.c */
        if (ip_conntrack_checksum && hooknum == NF_IP_PRE_ROUTING &&
-           nf_ip_checksum(skb, hooknum, skb->nh.iph->ihl * 4, 0)) {
+           nf_ip_checksum(skb, hooknum, ip_hdrlen(skb), 0)) {
                if (LOG_INVALID(IPPROTO_ICMP))
                        nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL,
                                      "ip_ct_icmp: bad ICMP checksum ");
 
 }
 
 #define for_each_sctp_chunk(skb, sch, _sch, offset, count)             \
-for (offset = skb->nh.iph->ihl * 4 + sizeof(sctp_sctphdr_t), count = 0;        \
+for (offset = ip_hdrlen(skb) + sizeof(sctp_sctphdr_t), count = 0;      \
        offset < skb->len &&                                            \
        (sch = skb_header_pointer(skb, offset, sizeof(_sch), &_sch));   \
        offset += (ntohs(sch->length) + 3) & ~3, count++)
 
                             enum ip_conntrack_dir dir)
 {
        struct iphdr *iph = skb->nh.iph;
-       struct tcphdr *tcph = (void *)skb->nh.iph + skb->nh.iph->ihl*4;
+       struct tcphdr *tcph = (void *)skb->nh.iph + ip_hdrlen(skb);
        __u32 end;
 #ifdef DEBUGP_VARS
        struct ip_ct_tcp_state *sender = &conntrack->proto.tcp.seen[dir];
 
        typeof(ip_nat_sip_hook) ip_nat_sip;
 
        /* No Data ? */
-       dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
+       dataoff = ip_hdrlen(*pskb) + sizeof(struct udphdr);
        if (dataoff >= (*pskb)->len) {
                DEBUGP("skb->len = %u\n", (*pskb)->len);
                return NF_ACCEPT;
 
 {
        /* root is playing with raw sockets. */
        if ((*pskb)->len < sizeof(struct iphdr)
-           || (*pskb)->nh.iph->ihl * 4 < sizeof(struct iphdr)) {
+           || ip_hdrlen(*pskb) < sizeof(struct iphdr)) {
                if (net_ratelimit())
                        printk("ipt_hook: happy cracking.\n");
                return NF_ACCEPT;
 
        typeof(ip_nat_tftp_hook) ip_nat_tftp;
 
        tfh = skb_header_pointer(*pskb,
-                                (*pskb)->nh.iph->ihl*4+sizeof(struct udphdr),
+                                ip_hdrlen(*pskb) + sizeof(struct udphdr),
                                 sizeof(_tftph), &_tftph);
        if (tfh == NULL)
                return NF_ACCEPT;
 
        } *inside;
        struct ip_conntrack_protocol *proto;
        struct ip_conntrack_tuple inner, target;
-       int hdrlen = (*pskb)->nh.iph->ihl * 4;
+       int hdrlen = ip_hdrlen(*pskb);
        enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
        unsigned long statusbit;
        enum ip_nat_manip_type manip = HOOK2MANIP(hooknum);
        if (!skb_make_writable(pskb, hdrlen + sizeof(*inside)))
                return 0;
 
-       inside = (void *)(*pskb)->data + (*pskb)->nh.iph->ihl*4;
+       inside = (void *)(*pskb)->data + ip_hdrlen(*pskb);
 
        /* We're actually going to mangle it beyond trivial checksum
           adjustment, so make sure the current checksum is correct. */
 
        /* rcu_read_lock()ed by nf_hook_slow */
        proto = __ip_conntrack_proto_find(inside->ip.protocol);
-       if (!ip_ct_get_tuple(&inside->ip, *pskb, (*pskb)->nh.iph->ihl*4 +
+       if (!ip_ct_get_tuple(&inside->ip, *pskb, ip_hdrlen(*pskb) +
                             sizeof(struct icmphdr) + inside->ip.ihl*4,
                             &inner, proto))
                return 0;
           packet: PREROUTING (DST manip), routing produces ICMP, goes
           through POSTROUTING (which must correct the DST manip). */
        if (!manip_pkt(inside->ip.protocol, pskb,
-                      (*pskb)->nh.iph->ihl*4
-                      + sizeof(inside->icmp),
+                      ip_hdrlen(*pskb) + sizeof(inside->icmp),
                       &ct->tuplehash[!dir].tuple,
                       !manip))
                return 0;
 
        if ((*pskb)->ip_summed != CHECKSUM_PARTIAL) {
                /* Reloading "inside" here since manip_pkt inner. */
-               inside = (void *)(*pskb)->data + (*pskb)->nh.iph->ihl*4;
+               inside = (void *)(*pskb)->data + ip_hdrlen(*pskb);
                inside->icmp.checksum = 0;
                inside->icmp.checksum = csum_fold(skb_checksum(*pskb, hdrlen,
                                                               (*pskb)->len - hdrlen,
 
 {
        unsigned int dir, optoff, optend;
 
-       optoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct tcphdr);
-       optend = (*pskb)->nh.iph->ihl*4 + tcph->doff*4;
+       optoff = ip_hdrlen(*pskb) + sizeof(struct tcphdr);
+       optend = ip_hdrlen(*pskb) + tcph->doff * 4;
 
        if (!skb_make_writable(pskb, optend))
                return 0;
        this_way = &ct->nat.info.seq[dir];
        other_way = &ct->nat.info.seq[!dir];
 
-       if (!skb_make_writable(pskb, (*pskb)->nh.iph->ihl*4+sizeof(*tcph)))
+       if (!skb_make_writable(pskb, ip_hdrlen(*pskb) + sizeof(*tcph)))
                return 0;
 
-       tcph = (void *)(*pskb)->data + (*pskb)->nh.iph->ihl*4;
+       tcph = (void *)(*pskb)->data + ip_hdrlen(*pskb);
        if (after(ntohl(tcph->seq), this_way->correction_pos))
                newseq = htonl(ntohl(tcph->seq) + this_way->offset_after);
        else
 
                }
 
                /* Relocate data pointer */
-               th = skb_header_pointer(*pskb, (*pskb)->nh.iph->ihl * 4,
+               th = skb_header_pointer(*pskb, ip_hdrlen(*pskb),
                                        sizeof(_tcph), &_tcph);
                if (th == NULL)
                        return -1;
-               *data = (*pskb)->data + (*pskb)->nh.iph->ihl * 4 +
+               *data = (*pskb)->data + ip_hdrlen(*pskb) +
                    th->doff * 4 + dataoff;
        } else {
                if (!ip_nat_mangle_udp_packet(pskb, ct, ctinfo,
                /* ip_nat_mangle_udp_packet uses skb_make_writable() to copy
                 * or pull everything in a linear buffer, so we can safely
                 * use the skb pointers now */
-               *data = (*pskb)->data + (*pskb)->nh.iph->ihl * 4 +
-                   sizeof(struct udphdr);
+               *data = ((*pskb)->data + ip_hdrlen(*pskb) +
+                        sizeof(struct udphdr));
        }
 
        return 0;
 
        if (!ip_nat_mangle_udp_packet(pskb, ct, ctinfo,
                                      matchoff, matchlen, addr, addrlen))
                return 0;
-       *dptr = (*pskb)->data + (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
+       *dptr = (*pskb)->data + ip_hdrlen(*pskb) + sizeof(struct udphdr);
        return 1;
 
 }
        struct addr_map map;
        int dataoff, datalen;
 
-       dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
+       dataoff = ip_hdrlen(*pskb) + sizeof(struct udphdr);
        datalen = (*pskb)->len - dataoff;
        if (datalen < sizeof("SIP/2.0") - 1)
                return NF_DROP;
                return 0;
 
        /* We need to reload this. Thanks Patrick. */
-       *dptr = (*pskb)->data + (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
+       *dptr = (*pskb)->data + ip_hdrlen(*pskb) + sizeof(struct udphdr);
        return 1;
 }
 
        char buffer[sizeof("65536")];
        int bufflen;
 
-       dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
+       dataoff = ip_hdrlen(*pskb) + sizeof(struct udphdr);
 
        /* Get actual SDP lenght */
        if (ct_sip_get_info(dptr, (*pskb)->len - dataoff, &matchoff,
        char buffer[sizeof("nnn.nnn.nnn.nnn")];
        unsigned int dataoff, bufflen;
 
-       dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
+       dataoff = ip_hdrlen(*pskb) + sizeof(struct udphdr);
 
        /* Mangle owner and contact info. */
        bufflen = sprintf(buffer, "%u.%u.%u.%u", NIPQUAD(newip));
 
                if ((*pskb)->nh.iph->protocol == IPPROTO_ICMP) {
                        struct icmphdr _hdr, *hp;
 
-                       hp = skb_header_pointer(*pskb,
-                                               (*pskb)->nh.iph->ihl*4,
+                       hp = skb_header_pointer(*pskb, ip_hdrlen(*pskb),
                                                sizeof(_hdr), &_hdr);
                        if (hp != NULL &&
                            hp->type == ICMP_REDIRECT)
 
        /* root is playing with raw sockets. */
        if ((*pskb)->len < sizeof(struct iphdr)
-           || (*pskb)->nh.iph->ihl * 4 < sizeof(struct iphdr))
+           || ip_hdrlen(*pskb) < sizeof(struct iphdr))
                return NF_ACCEPT;
 
        ret = ip_nat_fn(hooknum, pskb, in, out, okfn);
 
        /* root is playing with raw sockets. */
        if ((*pskb)->len < sizeof(struct iphdr)
-           || (*pskb)->nh.iph->ihl * 4 < sizeof(struct iphdr))
+           || ip_hdrlen(*pskb) < sizeof(struct iphdr))
                return NF_ACCEPT;
 
        ret = ip_nat_fn(hooknum, pskb, in, out, okfn);
 
 {
        /* Stop iteration if it doesn't match */
        if (!m->u.kernel.match->match(skb, in, out, m->u.kernel.match, m->data,
-                                     offset, skb->nh.iph->ihl*4, hotdrop))
+                                     offset, ip_hdrlen(skb), hotdrop))
                return 1;
        else
                return 0;
 
 #include <linux/module.h>
 #include <linux/skbuff.h>
 #include <linux/ip.h>
+#include <net/ip.h>
 #include <linux/tcp.h>
 #include <net/checksum.h>
 
        __be16 oldval;
 
        /* Not enought header? */
-       tcph = skb_header_pointer(*pskb, (*pskb)->nh.iph->ihl*4,
+       tcph = skb_header_pointer(*pskb, ip_hdrlen(*pskb),
                                  sizeof(_tcph), &_tcph);
        if (!tcph)
                return 0;
             tcph->cwr == einfo->proto.tcp.cwr)))
                return 1;
 
-       if (!skb_make_writable(pskb, (*pskb)->nh.iph->ihl*4+sizeof(*tcph)))
+       if (!skb_make_writable(pskb, ip_hdrlen(*pskb) + sizeof(*tcph)))
                return 0;
-       tcph = (void *)(*pskb)->nh.iph + (*pskb)->nh.iph->ihl*4;
+       tcph = (void *)(*pskb)->nh.iph + ip_hdrlen(*pskb);
 
        oldval = ((__be16 *)tcph)[6];
        if (einfo->operation & IPT_ECN_OP_SET_ECE)
 
 static void send_reset(struct sk_buff *oldskb, int hook)
 {
        struct sk_buff *nskb;
-       struct iphdr *iph = oldskb->nh.iph;
        struct tcphdr _otcph, *oth, *tcph;
        __be16 tmp_port;
        __be32 tmp_addr;
        if (oldskb->nh.iph->frag_off & htons(IP_OFFSET))
                return;
 
-       oth = skb_header_pointer(oldskb, oldskb->nh.iph->ihl * 4,
+       oth = skb_header_pointer(oldskb, ip_hdrlen(oldskb),
                                 sizeof(_otcph), &_otcph);
        if (oth == NULL)
                return;
                return;
 
        /* Check checksum */
-       if (nf_ip_checksum(oldskb, hook, iph->ihl * 4, IPPROTO_TCP))
+       if (nf_ip_checksum(oldskb, hook, ip_hdrlen(oldskb), IPPROTO_TCP))
                return;
 
        /* We need a linear, writeable skb.  We also need to expand
        skb_shinfo(nskb)->gso_segs = 0;
        skb_shinfo(nskb)->gso_type = 0;
 
-       tcph = (struct tcphdr *)((u_int32_t*)nskb->nh.iph + nskb->nh.iph->ihl);
+       tcph = (struct tcphdr *)(skb_network_header(nskb) + ip_hdrlen(nskb));
 
        /* Swap source and dest */
        tmp_addr = nskb->nh.iph->saddr;
 
        /* Truncate to length (no data) */
        tcph->doff = sizeof(struct tcphdr)/4;
-       skb_trim(nskb, nskb->nh.iph->ihl*4 + sizeof(struct tcphdr));
+       skb_trim(nskb, ip_hdrlen(nskb) + sizeof(struct tcphdr));
        nskb->nh.iph->tot_len = htons(nskb->len);
 
        if (tcph->ack) {
                tcph->ack_seq = 0;
        } else {
                needs_ack = 1;
-               tcph->ack_seq = htonl(ntohl(oth->seq) + oth->syn + oth->fin
-                                     + oldskb->len - oldskb->nh.iph->ihl*4
-                                     - (oth->doff<<2));
+               tcph->ack_seq = htonl(ntohl(oth->seq) + oth->syn + oth->fin +
+                                     oldskb->len - ip_hdrlen(oldskb) -
+                                     (oth->doff << 2));
                tcph->seq = 0;
        }
 
 
        /* Adjust IP checksum */
        nskb->nh.iph->check = 0;
-       nskb->nh.iph->check = ip_fast_csum((unsigned char *)nskb->nh.iph,
+       nskb->nh.iph->check = ip_fast_csum(skb_network_header(nskb),
                                           nskb->nh.iph->ihl);
 
        /* "Never happens" */
 
        /* Our naive response construction doesn't deal with IP
           options, and probably shouldn't try. */
-       if ((*pskb)->nh.iph->ihl<<2 != sizeof(struct iphdr))
+       if (ip_hdrlen(*pskb) != sizeof(struct iphdr))
                return NF_DROP;
 
        /* WARNING: This code causes reentry within iptables.
 
 
 #include <linux/in.h>
 #include <linux/ip.h>
+#include <net/ip.h>
 #include <linux/module.h>
 #include <linux/skbuff.h>
 #include <linux/tcp.h>
        /* In practice, TCP match does this, so can't fail.  But let's
         * be good citizens.
         */
-       th = skb_header_pointer(skb, skb->nh.iph->ihl * 4,
-                               sizeof(_tcph), &_tcph);
+       th = skb_header_pointer(skb, ip_hdrlen(skb), sizeof(_tcph), &_tcph);
        if (th == NULL) {
                *hotdrop = 0;
                return 0;
 
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/netfilter_ipv4/ip_tables.h>
+#include <net/ip.h>
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
 {
        /* root is playing with raw sockets. */
        if ((*pskb)->len < sizeof(struct iphdr)
-           || (*pskb)->nh.iph->ihl * 4 < sizeof(struct iphdr)) {
+           || ip_hdrlen(*pskb) < sizeof(struct iphdr)) {
                if (net_ratelimit())
                        printk("ipt_hook: happy cracking.\n");
                return NF_ACCEPT;
 
 #include <net/sock.h>
 #include <net/route.h>
 #include <linux/ip.h>
+#include <net/ip.h>
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
 
        /* root is playing with raw sockets. */
        if ((*pskb)->len < sizeof(struct iphdr)
-           || (*pskb)->nh.iph->ihl * 4 < sizeof(struct iphdr)) {
+           || ip_hdrlen(*pskb) < sizeof(struct iphdr)) {
                if (net_ratelimit())
                        printk("ipt_hook: happy cracking.\n");
                return NF_ACCEPT;
 
                return -NF_DROP;
        }
 
-       *dataoff = skb_network_offset(*pskb) + (*pskb)->nh.iph->ihl * 4;
+       *dataoff = skb_network_offset(*pskb) + ip_hdrlen(*pskb);
        *protonum = (*pskb)->nh.iph->protocol;
 
        return NF_ACCEPT;
        if (!help || !help->helper)
                return NF_ACCEPT;
 
-       return help->helper->help(pskb, (skb_network_offset(*pskb) +
-                                        (*pskb)->nh.iph->ihl * 4),
+       return help->helper->help(pskb,
+                                 skb_network_offset(*pskb) + ip_hdrlen(*pskb),
                                  ct, ctinfo);
 }
 
 {
        /* root is playing with raw sockets. */
        if ((*pskb)->len < sizeof(struct iphdr)
-           || (*pskb)->nh.iph->ihl * 4 < sizeof(struct iphdr)) {
+           || ip_hdrlen(*pskb) < sizeof(struct iphdr)) {
                if (net_ratelimit())
                        printk("ipt_hook: happy cracking.\n");
                return NF_ACCEPT;
 
        NF_CT_ASSERT(skb->nfct == NULL);
 
        /* Not enough header? */
-       inside = skb_header_pointer(skb, skb->nh.iph->ihl*4, sizeof(_in), &_in);
+       inside = skb_header_pointer(skb, ip_hdrlen(skb), sizeof(_in), &_in);
        if (inside == NULL)
                return -NF_ACCEPT;
 
        /* rcu_read_lock()ed by nf_hook_slow */
        innerproto = __nf_ct_l4proto_find(PF_INET, inside->ip.protocol);
 
-       dataoff = skb->nh.iph->ihl*4 + sizeof(inside->icmp);
+       dataoff = ip_hdrlen(skb) + sizeof(inside->icmp);
        /* Are they talking about one of our connections? */
        if (!nf_ct_get_tuple(skb, dataoff, dataoff + inside->ip.ihl*4, PF_INET,
                             inside->ip.protocol, &origtuple,
        struct icmphdr _ih, *icmph;
 
        /* Not enough header? */
-       icmph = skb_header_pointer(skb, skb->nh.iph->ihl*4, sizeof(_ih), &_ih);
+       icmph = skb_header_pointer(skb, ip_hdrlen(skb), sizeof(_ih), &_ih);
        if (icmph == NULL) {
                if (LOG_INVALID(IPPROTO_ICMP))
                        nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL,
 
        } *inside;
        struct nf_conntrack_l4proto *l4proto;
        struct nf_conntrack_tuple inner, target;
-       int hdrlen = (*pskb)->nh.iph->ihl * 4;
+       int hdrlen = ip_hdrlen(*pskb);
        enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
        unsigned long statusbit;
        enum nf_nat_manip_type manip = HOOK2MANIP(hooknum);
        if (!skb_make_writable(pskb, hdrlen + sizeof(*inside)))
                return 0;
 
-       inside = (void *)(*pskb)->data + (*pskb)->nh.iph->ihl*4;
+       inside = (void *)(*pskb)->data + ip_hdrlen(*pskb);
 
        /* We're actually going to mangle it beyond trivial checksum
           adjustment, so make sure the current checksum is correct. */
        l4proto = __nf_ct_l4proto_find(PF_INET, inside->ip.protocol);
 
        if (!nf_ct_get_tuple(*pskb,
-                            (*pskb)->nh.iph->ihl*4 + sizeof(struct icmphdr),
-                            (*pskb)->nh.iph->ihl*4 +
-                            sizeof(struct icmphdr) + inside->ip.ihl*4,
+                            ip_hdrlen(*pskb) + sizeof(struct icmphdr),
+                            (ip_hdrlen(*pskb) +
+                             sizeof(struct icmphdr) + inside->ip.ihl * 4),
                             (u_int16_t)AF_INET,
                             inside->ip.protocol,
                             &inner, l3proto, l4proto))
           packet: PREROUTING (DST manip), routing produces ICMP, goes
           through POSTROUTING (which must correct the DST manip). */
        if (!manip_pkt(inside->ip.protocol, pskb,
-                      (*pskb)->nh.iph->ihl*4 + sizeof(inside->icmp),
+                      ip_hdrlen(*pskb) + sizeof(inside->icmp),
                       &ct->tuplehash[!dir].tuple,
                       !manip))
                return 0;
 
        if ((*pskb)->ip_summed != CHECKSUM_PARTIAL) {
                /* Reloading "inside" here since manip_pkt inner. */
-               inside = (void *)(*pskb)->data + (*pskb)->nh.iph->ihl*4;
+               inside = (void *)(*pskb)->data + ip_hdrlen(*pskb);
                inside->icmp.checksum = 0;
                inside->icmp.checksum =
                        csum_fold(skb_checksum(*pskb, hdrlen,
 
                }
 
                /* Relocate data pointer */
-               th = skb_header_pointer(*pskb, (*pskb)->nh.iph->ihl * 4,
+               th = skb_header_pointer(*pskb, ip_hdrlen(*pskb),
                                        sizeof(_tcph), &_tcph);
                if (th == NULL)
                        return -1;
-               *data = (*pskb)->data + (*pskb)->nh.iph->ihl * 4 +
+               *data = (*pskb)->data + ip_hdrlen(*pskb) +
                    th->doff * 4 + dataoff;
        } else {
                if (!nf_nat_mangle_udp_packet(pskb, ct, ctinfo,
                /* nf_nat_mangle_udp_packet uses skb_make_writable() to copy
                 * or pull everything in a linear buffer, so we can safely
                 * use the skb pointers now */
-               *data = (*pskb)->data + (*pskb)->nh.iph->ihl * 4 +
-                   sizeof(struct udphdr);
+               *data = ((*pskb)->data + ip_hdrlen(*pskb) +
+                        sizeof(struct udphdr));
        }
 
        return 0;
 
                                    (int)rep_len - (int)match_len,
                                    ct, ctinfo);
                /* Tell TCP window tracking about seq change */
-               nf_conntrack_tcp_update(*pskb, (*pskb)->nh.iph->ihl*4,
+               nf_conntrack_tcp_update(*pskb, ip_hdrlen(*pskb),
                                        ct, CTINFO2DIR(ctinfo));
        }
        return 1;
        unsigned int dir, optoff, optend;
        struct nf_conn_nat *nat = nfct_nat(ct);
 
-       optoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct tcphdr);
-       optend = (*pskb)->nh.iph->ihl*4 + tcph->doff*4;
+       optoff = ip_hdrlen(*pskb) + sizeof(struct tcphdr);
+       optend = ip_hdrlen(*pskb) + tcph->doff * 4;
 
        if (!skb_make_writable(pskb, optend))
                return 0;
        this_way = &nat->info.seq[dir];
        other_way = &nat->info.seq[!dir];
 
-       if (!skb_make_writable(pskb, (*pskb)->nh.iph->ihl*4+sizeof(*tcph)))
+       if (!skb_make_writable(pskb, ip_hdrlen(*pskb) + sizeof(*tcph)))
                return 0;
 
-       tcph = (void *)(*pskb)->data + (*pskb)->nh.iph->ihl*4;
+       tcph = (void *)(*pskb)->data + ip_hdrlen(*pskb);
        if (after(ntohl(tcph->seq), this_way->correction_pos))
                newseq = htonl(ntohl(tcph->seq) + this_way->offset_after);
        else
        if (!nf_nat_sack_adjust(pskb, tcph, ct, ctinfo))
                return 0;
 
-       nf_conntrack_tcp_update(*pskb, (*pskb)->nh.iph->ihl*4, ct, dir);
+       nf_conntrack_tcp_update(*pskb, ip_hdrlen(*pskb), ct, dir);
 
        return 1;
 }
 
 #include <linux/module.h>
 #include <linux/skbuff.h>
 #include <linux/ip.h>
+#include <net/ip.h>
 #include <linux/udp.h>
 
 #include <net/netfilter/nf_nat.h>
        if (!nf_nat_mangle_udp_packet(pskb, ct, ctinfo,
                                      matchoff, matchlen, addr, addrlen))
                return 0;
-       *dptr = (*pskb)->data + (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
+       *dptr = (*pskb)->data + ip_hdrlen(*pskb) + sizeof(struct udphdr);
        return 1;
 
 }
        struct addr_map map;
        int dataoff, datalen;
 
-       dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
+       dataoff = ip_hdrlen(*pskb) + sizeof(struct udphdr);
        datalen = (*pskb)->len - dataoff;
        if (datalen < sizeof("SIP/2.0") - 1)
                return NF_DROP;
                return 0;
 
        /* We need to reload this. Thanks Patrick. */
-       *dptr = (*pskb)->data + (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
+       *dptr = (*pskb)->data + ip_hdrlen(*pskb) + sizeof(struct udphdr);
        return 1;
 }
 
        char buffer[sizeof("65536")];
        int bufflen;
 
-       dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
+       dataoff = ip_hdrlen(*pskb) + sizeof(struct udphdr);
 
        /* Get actual SDP lenght */
        if (ct_sip_get_info(ct, dptr, (*pskb)->len - dataoff, &matchoff,
        char buffer[sizeof("nnn.nnn.nnn.nnn")];
        unsigned int dataoff, bufflen;
 
-       dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
+       dataoff = ip_hdrlen(*pskb) + sizeof(struct udphdr);
 
        /* Mangle owner and contact info. */
        bufflen = sprintf(buffer, "%u.%u.%u.%u", NIPQUAD(newip));
 
                if ((*pskb)->nh.iph->protocol == IPPROTO_ICMP) {
                        struct icmphdr _hdr, *hp;
 
-                       hp = skb_header_pointer(*pskb,
-                                               (*pskb)->nh.iph->ihl*4,
+                       hp = skb_header_pointer(*pskb, ip_hdrlen(*pskb),
                                                sizeof(_hdr), &_hdr);
                        if (hp != NULL &&
                            hp->type == ICMP_REDIRECT)
 
        /* root is playing with raw sockets. */
        if ((*pskb)->len < sizeof(struct iphdr) ||
-           (*pskb)->nh.iph->ihl * 4 < sizeof(struct iphdr))
+           ip_hdrlen(*pskb) < sizeof(struct iphdr))
                return NF_ACCEPT;
 
        ret = nf_nat_fn(hooknum, pskb, in, out, okfn);
 
        /* root is playing with raw sockets. */
        if ((*pskb)->len < sizeof(struct iphdr) ||
-           (*pskb)->nh.iph->ihl * 4 < sizeof(struct iphdr))
+           ip_hdrlen(*pskb) < sizeof(struct iphdr))
                return NF_ACCEPT;
 
        ret = nf_nat_fn(hooknum, pskb, in, out, okfn);
 
 #if 0
        /* root is playing with raw sockets. */
        if ((*pskb)->len < sizeof(struct iphdr)
-           || (*pskb)->nh.iph->ihl * 4 < sizeof(struct iphdr)) {
+           || ip_hdrlen(*pskb) < sizeof(struct iphdr)) {
                if (net_ratelimit())
                        printk("ip6t_hook: happy cracking.\n");
                return NF_ACCEPT;
 
 #if 0
        /* root is playing with raw sockets. */
        if ((*pskb)->len < sizeof(struct iphdr)
-           || (*pskb)->nh.iph->ihl * 4 < sizeof(struct iphdr)) {
+           || ip_hdrlen(*pskb) < sizeof(struct iphdr)) {
                if (net_ratelimit())
                        printk("ip6t_hook: happy cracking.\n");
                return NF_ACCEPT;