net: Use skb_checksum_start_offset()
authorMichał Mirosław <mirq-linux@rere.qmqm.pl>
Tue, 14 Dec 2010 15:24:08 +0000 (15:24 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 16 Dec 2010 22:43:14 +0000 (14:43 -0800)
Replace skb->csum_start - skb_headroom(skb) with skb_checksum_start_offset().

Note for usb/smsc95xx: skb->data - skb->head == skb_headroom(skb).

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/atlx/atl1.c
drivers/net/macvtap.c
drivers/net/tun.c
drivers/net/usb/smsc95xx.c
drivers/net/virtio_net.c
net/core/dev.c
net/core/skbuff.c
net/ipv4/udp.c
net/packet/af_packet.c

index 53363108994ee93bed670940b0eb91170a389456..def8df83359c833fc8888c9239258a040e2f6e94 100644 (file)
@@ -2174,7 +2174,7 @@ static int atl1_tx_csum(struct atl1_adapter *adapter, struct sk_buff *skb,
        u8 css, cso;
 
        if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
-               css = (u8) (skb->csum_start - skb_headroom(skb));
+               css = skb_checksum_start_offset(skb);
                cso = css + (u8) skb->csum_offset;
                if (unlikely(css & 0x1)) {
                        /* L1 hardware requires an even number here */
index 42567279843ecfc804efd233b841338f21cef933..21845affea1303ed80a952d38b78d24c39281e28 100644 (file)
@@ -504,8 +504,7 @@ static int macvtap_skb_to_vnet_hdr(const struct sk_buff *skb,
 
        if (skb->ip_summed == CHECKSUM_PARTIAL) {
                vnet_hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
-               vnet_hdr->csum_start = skb->csum_start -
-                                       skb_headroom(skb);
+               vnet_hdr->csum_start = skb_checksum_start_offset(skb);
                vnet_hdr->csum_offset = skb->csum_offset;
        } /* else everything is zero */
 
index 55f3a3e667a9af0291da7c7d4e46c12e84d7ce6a..7599c457abd158648a50f1ccf997a3174a2f2443 100644 (file)
@@ -757,7 +757,7 @@ static __inline__ ssize_t tun_put_user(struct tun_struct *tun,
 
                if (skb->ip_summed == CHECKSUM_PARTIAL) {
                        gso.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
-                       gso.csum_start = skb->csum_start - skb_headroom(skb);
+                       gso.csum_start = skb_checksum_start_offset(skb);
                        gso.csum_offset = skb->csum_offset;
                } /* else everything is zero */
 
index 65cb1abfbe577f304f390fe4b7dba650fb5b2574..bc86f4b6ecc218289bad5889ffce90e6e57c27cd 100644 (file)
@@ -1163,9 +1163,8 @@ static int smsc95xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
 
 static u32 smsc95xx_calc_csum_preamble(struct sk_buff *skb)
 {
-       int len = skb->data - skb->head;
-       u16 high_16 = (u16)(skb->csum_offset + skb->csum_start - len);
-       u16 low_16 = (u16)(skb->csum_start - len);
+       u16 low_16 = (u16)skb_checksum_start_offset(skb);
+       u16 high_16 = low_16 + skb->csum_offset;
        return (high_16 << 16) | low_16;
 }
 
@@ -1193,7 +1192,7 @@ static struct sk_buff *smsc95xx_tx_fixup(struct usbnet *dev,
                if (skb->len <= 45) {
                        /* workaround - hardware tx checksum does not work
                         * properly with extremely small packets */
-                       long csstart = skb->csum_start - skb_headroom(skb);
+                       long csstart = skb_checksum_start_offset(skb);
                        __wsum calc = csum_partial(skb->data + csstart,
                                skb->len - csstart, 0);
                        *((__sum16 *)(skb->data + csstart
index b6d402806ae67253d2c12ff902ea79d40be5fe87..90a23e410d1b47c876b5d13af94d945960ba109c 100644 (file)
@@ -519,7 +519,7 @@ static int xmit_skb(struct virtnet_info *vi, struct sk_buff *skb)
 
        if (skb->ip_summed == CHECKSUM_PARTIAL) {
                hdr->hdr.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
-               hdr->hdr.csum_start = skb->csum_start - skb_headroom(skb);
+               hdr->hdr.csum_start = skb_checksum_start_offset(skb);
                hdr->hdr.csum_offset = skb->csum_offset;
        } else {
                hdr->hdr.flags = 0;
index 794b20de5d44cdfad677d0f710661d19c860aa2b..92d414ac0e30e79392a44c686697d334205149da 100644 (file)
@@ -1793,7 +1793,7 @@ int skb_checksum_help(struct sk_buff *skb)
                goto out_set_summed;
        }
 
-       offset = skb->csum_start - skb_headroom(skb);
+       offset = skb_checksum_start_offset(skb);
        BUG_ON(offset >= skb_headlen(skb));
        csum = skb_checksum(skb, offset, skb->len - offset, 0);
 
@@ -2090,8 +2090,8 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
                         * checksumming here.
                         */
                        if (skb->ip_summed == CHECKSUM_PARTIAL) {
-                               skb_set_transport_header(skb, skb->csum_start -
-                                             skb_headroom(skb));
+                               skb_set_transport_header(skb,
+                                       skb_checksum_start_offset(skb));
                                if (!dev_can_checksum(dev, skb) &&
                                     skb_checksum_help(skb))
                                        goto out_kfree_skb;
index 8814a9a52f47c3c73a1a65b8b20a8c5cd4d07e46..19d6c21220fd47bb7141d8376a55c1785627a5e8 100644 (file)
@@ -1824,7 +1824,7 @@ void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to)
        long csstart;
 
        if (skb->ip_summed == CHECKSUM_PARTIAL)
-               csstart = skb->csum_start - skb_headroom(skb);
+               csstart = skb_checksum_start_offset(skb);
        else
                csstart = skb_headlen(skb);
 
index b37181da487cc22164f8b9f6fe0f160ee742a36f..1198adf4510214338a37629959d1508335d6da1f 100644 (file)
@@ -2226,7 +2226,7 @@ struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb, int features)
        /* Do software UFO. Complete and fill in the UDP checksum as HW cannot
         * do checksum of UDP packets sent as multiple IP fragments.
         */
-       offset = skb->csum_start - skb_headroom(skb);
+       offset = skb_checksum_start_offset(skb);
        csum = skb_checksum(skb, offset, skb->len - offset, 0);
        offset += skb->csum_offset;
        *(__sum16 *)(skb->data + offset) = csum_fold(csum);
index e79efaf063895422275675279c4a9230d0bffd76..91cb1d71f018d8b6b77c029dca1b99cb2855ef21 100644 (file)
@@ -1650,8 +1650,7 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
 
                if (skb->ip_summed == CHECKSUM_PARTIAL) {
                        vnet_hdr.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
-                       vnet_hdr.csum_start = skb->csum_start -
-                                                       skb_headroom(skb);
+                       vnet_hdr.csum_start = skb_checksum_start_offset(skb);
                        vnet_hdr.csum_offset = skb->csum_offset;
                } /* else everything is zero */