Skip to content

Commit 55508d6

Browse files
osctobedavem330
authored andcommitted
net: Use skb_checksum_start_offset()
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>
1 parent 04fb451 commit 55508d6

9 files changed

Lines changed: 13 additions & 16 deletions

File tree

‎drivers/net/atlx/atl1.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2174,7 +2174,7 @@ static int atl1_tx_csum(struct atl1_adapter *adapter, struct sk_buff *skb,
21742174
u8 css, cso;
21752175

21762176
if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
2177-
css = (u8) (skb->csum_start - skb_headroom(skb));
2177+
css = skb_checksum_start_offset(skb);
21782178
cso = css + (u8) skb->csum_offset;
21792179
if (unlikely(css & 0x1)) {
21802180
/* L1 hardware requires an even number here */

‎drivers/net/macvtap.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,7 @@ static int macvtap_skb_to_vnet_hdr(const struct sk_buff *skb,
504504

505505
if (skb->ip_summed == CHECKSUM_PARTIAL) {
506506
vnet_hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
507-
vnet_hdr->csum_start = skb->csum_start -
508-
skb_headroom(skb);
507+
vnet_hdr->csum_start = skb_checksum_start_offset(skb);
509508
vnet_hdr->csum_offset = skb->csum_offset;
510509
} /* else everything is zero */
511510

‎drivers/net/tun.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ static __inline__ ssize_t tun_put_user(struct tun_struct *tun,
757757

758758
if (skb->ip_summed == CHECKSUM_PARTIAL) {
759759
gso.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
760-
gso.csum_start = skb->csum_start - skb_headroom(skb);
760+
gso.csum_start = skb_checksum_start_offset(skb);
761761
gso.csum_offset = skb->csum_offset;
762762
} /* else everything is zero */
763763

‎drivers/net/usb/smsc95xx.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,9 +1163,8 @@ static int smsc95xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
11631163

11641164
static u32 smsc95xx_calc_csum_preamble(struct sk_buff *skb)
11651165
{
1166-
int len = skb->data - skb->head;
1167-
u16 high_16 = (u16)(skb->csum_offset + skb->csum_start - len);
1168-
u16 low_16 = (u16)(skb->csum_start - len);
1166+
u16 low_16 = (u16)skb_checksum_start_offset(skb);
1167+
u16 high_16 = low_16 + skb->csum_offset;
11691168
return (high_16 << 16) | low_16;
11701169
}
11711170

@@ -1193,7 +1192,7 @@ static struct sk_buff *smsc95xx_tx_fixup(struct usbnet *dev,
11931192
if (skb->len <= 45) {
11941193
/* workaround - hardware tx checksum does not work
11951194
* properly with extremely small packets */
1196-
long csstart = skb->csum_start - skb_headroom(skb);
1195+
long csstart = skb_checksum_start_offset(skb);
11971196
__wsum calc = csum_partial(skb->data + csstart,
11981197
skb->len - csstart, 0);
11991198
*((__sum16 *)(skb->data + csstart

‎drivers/net/virtio_net.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ static int xmit_skb(struct virtnet_info *vi, struct sk_buff *skb)
519519

520520
if (skb->ip_summed == CHECKSUM_PARTIAL) {
521521
hdr->hdr.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
522-
hdr->hdr.csum_start = skb->csum_start - skb_headroom(skb);
522+
hdr->hdr.csum_start = skb_checksum_start_offset(skb);
523523
hdr->hdr.csum_offset = skb->csum_offset;
524524
} else {
525525
hdr->hdr.flags = 0;

‎net/core/dev.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,7 +1793,7 @@ int skb_checksum_help(struct sk_buff *skb)
17931793
goto out_set_summed;
17941794
}
17951795

1796-
offset = skb->csum_start - skb_headroom(skb);
1796+
offset = skb_checksum_start_offset(skb);
17971797
BUG_ON(offset >= skb_headlen(skb));
17981798
csum = skb_checksum(skb, offset, skb->len - offset, 0);
17991799

@@ -2090,8 +2090,8 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
20902090
* checksumming here.
20912091
*/
20922092
if (skb->ip_summed == CHECKSUM_PARTIAL) {
2093-
skb_set_transport_header(skb, skb->csum_start -
2094-
skb_headroom(skb));
2093+
skb_set_transport_header(skb,
2094+
skb_checksum_start_offset(skb));
20952095
if (!dev_can_checksum(dev, skb) &&
20962096
skb_checksum_help(skb))
20972097
goto out_kfree_skb;

‎net/core/skbuff.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1824,7 +1824,7 @@ void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to)
18241824
long csstart;
18251825

18261826
if (skb->ip_summed == CHECKSUM_PARTIAL)
1827-
csstart = skb->csum_start - skb_headroom(skb);
1827+
csstart = skb_checksum_start_offset(skb);
18281828
else
18291829
csstart = skb_headlen(skb);
18301830

‎net/ipv4/udp.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2226,7 +2226,7 @@ struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb, int features)
22262226
/* Do software UFO. Complete and fill in the UDP checksum as HW cannot
22272227
* do checksum of UDP packets sent as multiple IP fragments.
22282228
*/
2229-
offset = skb->csum_start - skb_headroom(skb);
2229+
offset = skb_checksum_start_offset(skb);
22302230
csum = skb_checksum(skb, offset, skb->len - offset, 0);
22312231
offset += skb->csum_offset;
22322232
*(__sum16 *)(skb->data + offset) = csum_fold(csum);

‎net/packet/af_packet.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,8 +1650,7 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
16501650

16511651
if (skb->ip_summed == CHECKSUM_PARTIAL) {
16521652
vnet_hdr.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
1653-
vnet_hdr.csum_start = skb->csum_start -
1654-
skb_headroom(skb);
1653+
vnet_hdr.csum_start = skb_checksum_start_offset(skb);
16551654
vnet_hdr.csum_offset = skb->csum_offset;
16561655
} /* else everything is zero */
16571656

0 commit comments

Comments
 (0)