For the quite common 'skb->nh.raw - skb->data' sequence.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
        if (!skb)
                return;
        if (lp->p_encap == ISDN_NET_ENCAP_ETHER) {
-               int pullsize = (ulong)skb->nh.raw - (ulong)skb->data - ETH_HLEN;
+               const int pullsize = skb_network_offset(skb) - ETH_HLEN;
                if (pullsize > 0) {
                        printk(KERN_DEBUG "isdn_net: Pull junk %d\n", pullsize);
                        skb_pull(skb, pullsize);
 
                            ~csum_tcpudp_magic(skb->nh.iph->saddr,
                                               skb->nh.iph->daddr, 0,
                                               IPPROTO_TCP, 0);
-                       ipofst = skb->nh.raw - skb->data;
+                       ipofst = skb_network_offset(skb);
                        if (ipofst != ENET_HEADER_SIZE) /* 802.3 frame */
                                tso->tsopl |= 1 << TSO_PARAM_ETHTYPE_SHIFT;
 
 
 
                ++st->tx_tso;
 
-               eth_type = skb->nh.raw - skb->data == ETH_HLEN ?
+               eth_type = skb_network_offset(skb) == ETH_HLEN ?
                        CPL_ETH_II : CPL_ETH_II_VLAN;
 
                hdr = (struct cpl_tx_pkt_lso *)skb_push(skb, sizeof(*hdr));
 
                d->flit[2] = 0;
                cntrl |= V_TXPKT_OPCODE(CPL_TX_PKT_LSO);
                hdr->cntrl = htonl(cntrl);
-               eth_type = skb->nh.raw - skb->data == ETH_HLEN ?
+               eth_type = skb_network_offset(skb) == ETH_HLEN ?
                    CPL_ETH_II : CPL_ETH_II_VLAN;
                tso_info |= V_LSO_ETH_TYPE(eth_type) |
                    V_LSO_IPHDR_WORDS(skb->nh.iph->ihl) |
 
                                                 0);
                        ipcse = 0;
                }
-               ipcss = skb->nh.raw - skb->data;
+               ipcss = skb_network_offset(skb);
                ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data;
                tucss = skb->h.raw - skb->data;
                tucso = (void *)&(skb->h.th->check) - (void *)skb->data;
 
         * frame (skb->data) and the start of the IP hdr.
         * l4os is the distance between the start of the
         * l3 hdr and the l4 hdr */
-       fcb->l3os = (u16)(skb->nh.raw - skb->data - GMAC_FCB_LEN);
+       fcb->l3os = (u16)(skb_network_offset(skb) - GMAC_FCB_LEN);
        fcb->l4os = (u16)(skb->h.raw - skb->nh.raw);
 
        fcb->flags = flags;
 
                skb->h.th->check = ~csum_tcpudp_magic(skb->nh.iph->saddr,
                                                      skb->nh.iph->daddr,
                                                      0, IPPROTO_TCP, 0);
-               ipcss = skb->nh.raw - skb->data;
+               ipcss = skb_network_offset(skb);
                ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data;
                ipcse = skb->h.raw - skb->data - 1;
                tucss = skb->h.raw - skb->data;
 
        }
        adapter->stats.xmitcsummed++;
        desc->tcp_hdr_offset = skb->h.raw - skb->data;
-       desc->ip_hdr_offset = skb->nh.raw - skb->data;
+       desc->ip_hdr_offset = skb_network_offset(skb);
 }
 
 int netxen_is_flash_supported(struct netxen_adapter *adapter)
 
        skb->nh.raw = skb->data;
 }
 
+static inline int skb_network_offset(const struct sk_buff *skb)
+{
+       return skb->nh.raw - skb->data;
+}
+
 static inline unsigned char *skb_mac_header(const struct sk_buff *skb)
 {
        return skb->mac.raw;
 
 
                        if (ka9qfrag == 1) {
                                skb_reserve(skbn, frontlen + 2);
-                               skbn->nh.raw = skbn->data + (skb->nh.raw - skb->data);
+                               skbn->nh.raw = skbn->data + skb_network_offset(skb);
                                memcpy(skb_put(skbn, len), skb->data, len);
                                p = skb_push(skbn, 2);
 
                                }
                        } else {
                                skb_reserve(skbn, frontlen + 1);
-                               skbn->nh.raw = skbn->data + (skb->nh.raw - skb->data);
+                               skbn->nh.raw = skbn->data + skb_network_offset(skb);
                                memcpy(skb_put(skbn, len), skb->data, len);
                                p = skb_push(skbn, 1);
                                *p = AX25_P_TEXT;
 
 {
        struct net_device *dev = skb->dev;
 
-       __skb_pull(skb, skb->nh.raw - skb->data);
+       __skb_pull(skb, skb_network_offset(skb));
 
        if (dev->hard_header &&
            dev->hard_header(skb, dev, ntohs(skb->protocol), NULL, NULL,
        if (!dst || !(neigh = dst->neighbour))
                goto discard;
 
-       __skb_pull(skb, skb->nh.raw - skb->data);
+       __skb_pull(skb, skb_network_offset(skb));
 
        if (!neigh_event_send(neigh, skb)) {
                int err;
        struct neighbour *neigh = dst->neighbour;
        struct net_device *dev = neigh->dev;
 
-       __skb_pull(skb, skb->nh.raw - skb->data);
+       __skb_pull(skb, skb_network_offset(skb));
 
        read_lock_bh(&neigh->lock);
        err = dev->hard_header(skb, dev, ntohs(skb->protocol),
 
 static int ip_dev_loopback_xmit(struct sk_buff *newskb)
 {
        skb_reset_mac_header(newskb);
-       __skb_pull(newskb, newskb->nh.raw - newskb->data);
+       __skb_pull(newskb, skb_network_offset(newskb));
        newskb->pkt_type = PACKET_LOOPBACK;
        newskb->ip_summed = CHECKSUM_UNNECESSARY;
        BUG_TRAP(newskb->dst);
 
        /* move skb->data to ip header from ext header */
        if (skb->data < skb->nh.raw)
-               __skb_pull(skb, skb->nh.raw - skb->data);
+               __skb_pull(skb, skb_network_offset(skb));
        while ((tmp_skb = __skb_dequeue(&sk->sk_write_queue)) != NULL) {
                __skb_pull(tmp_skb, skb->h.raw - skb->nh.raw);
                *tail_skb = tmp_skb;
 
 {
        u8 _optval, *op;
 
-       offset += skb->nh.raw - skb->data;
+       offset += skb_network_offset(skb);
        op = skb_header_pointer(skb, offset, sizeof(_optval), &_optval);
        if (op == NULL)
                return 1;
                tclass = 0;
 
        msg.skb = skb;
-       msg.offset = skb->nh.raw - skb->data;
+       msg.offset = skb_network_offset(skb);
        msg.type = type;
 
        len = skb->len - msg.offset;
 
 static int ip6_dev_loopback_xmit(struct sk_buff *newskb)
 {
        skb_reset_mac_header(newskb);
-       __skb_pull(newskb, newskb->nh.raw - newskb->data);
+       __skb_pull(newskb, skb_network_offset(newskb));
        newskb->pkt_type = PACKET_LOOPBACK;
        newskb->ip_summed = CHECKSUM_UNNECESSARY;
        BUG_TRAP(newskb->dst);
 
        /* move skb->data to ip header from ext header */
        if (skb->data < skb->nh.raw)
-               __skb_pull(skb, skb->nh.raw - skb->data);
+               __skb_pull(skb, skb_network_offset(skb));
        while ((tmp_skb = __skb_dequeue(&sk->sk_write_queue)) != NULL) {
                __skb_pull(tmp_skb, skb->h.raw - skb->nh.raw);
                *tail_skb = tmp_skb;
 
        struct nf_conntrack_tuple_hash *h;
        struct nf_conn *ct;
 
-       if (!nf_ct_get_tuple(skb, (unsigned int)(skb->nh.raw - skb->data),
+       if (!nf_ct_get_tuple(skb, skb_network_offset(skb),
                             dataoff, l3num, protonum, &tuple, l3proto,
                             l4proto)) {
                DEBUGP("resolve_normal_ct: Can't get tuple\n");
        if (do_acct) {
                ct->counters[CTINFO2DIR(ctinfo)].packets++;
                ct->counters[CTINFO2DIR(ctinfo)].bytes +=
-                       skb->len - (unsigned int)(skb->nh.raw - skb->data);
+                       skb->len - skb_network_offset(skb);
 
                if ((ct->counters[CTINFO2DIR(ctinfo)].packets & 0x80000000)
                    || (ct->counters[CTINFO2DIR(ctinfo)].bytes & 0x80000000))
 
                        skb_push(skb, skb->data - skb_mac_header(skb));
                else if (skb->pkt_type == PACKET_OUTGOING) {
                        /* Special case: outgoing packets have ll header at head */
-                       skb_pull(skb, skb->nh.raw - skb->data);
+                       skb_pull(skb, skb_network_offset(skb));
                }
        }
 
                        skb_push(skb, skb->data - skb_mac_header(skb));
                else if (skb->pkt_type == PACKET_OUTGOING) {
                        /* Special case: outgoing packets have ll header at head */
-                       skb_pull(skb, skb->nh.raw - skb->data);
+                       skb_pull(skb, skb_network_offset(skb));
                }
        }
 
        if (sk->sk_type == SOCK_DGRAM) {
                macoff = netoff = TPACKET_ALIGN(TPACKET_HDRLEN) + 16;
        } else {
-               unsigned maclen = skb->nh.raw - skb->data;
+               unsigned maclen = skb_network_offset(skb);
                netoff = TPACKET_ALIGN(TPACKET_HDRLEN + (maclen < 16 ? 16 : maclen));
                macoff = netoff - maclen;
        }
                aux.tp_len = PACKET_SKB_CB(skb)->origlen;
                aux.tp_snaplen = skb->len;
                aux.tp_mac = 0;
-               aux.tp_net = skb->nh.raw - skb->data;
+               aux.tp_net = skb_network_offset(skb);
 
                put_cmsg(msg, SOL_PACKET, PACKET_AUXDATA, sizeof(aux), &aux);
        }
 
                        nores = 1;
                        break;
                }
-               __skb_pull(skb, skb->nh.raw - skb->data);
+               __skb_pull(skb, skb_network_offset(skb));
        } while ((q = NEXT_SLAVE(q)) != start);
 
        if (nores && skb_res == NULL) {
 
        int offset, ihlen, ret = -EINVAL;
        struct iphdr _iph, *ih;
 
-       offset = skb->nh.raw - skb->data;
+       offset = skb_network_offset(skb);
        ih = skb_header_pointer(skb, offset, sizeof(_iph), &_iph);
        if (ih == NULL)
                goto out;
        int ret = -EINVAL, offset;
        struct ipv6hdr _ipv6h, *ip6;
 
-       offset = skb->nh.raw - skb->data;
+       offset = skb_network_offset(skb);
        ip6 = skb_header_pointer(skb, offset, sizeof(_ipv6h), &_ipv6h);
        if (ip6 == NULL)
                goto out;