Skip to content

Commit 5f2f3ca

Browse files
sowminivdavem330
authored andcommitted
sunvnet: Initialize network_header and transport_header in vnet_rx_one()
vnet_fullcsum() accesses ip_hdr() and transport header to compute the checksum for IPv4 packets, so these need to be initialized in skb created in vnet_rx_one(). Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b4ace4f commit 5f2f3ca

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

drivers/net/ethernet/sun/sunvnet.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,17 +389,27 @@ static int vnet_rx_one(struct vnet_port *port, struct vio_net_desc *desc)
389389
if (vio_version_after_eq(&port->vio, 1, 8)) {
390390
struct vio_net_dext *dext = vio_net_ext(desc);
391391

392+
skb_reset_network_header(skb);
393+
392394
if (dext->flags & VNET_PKT_HCK_IPV4_HDRCKSUM) {
393395
if (skb->protocol == ETH_P_IP) {
394-
struct iphdr *iph = (struct iphdr *)skb->data;
396+
struct iphdr *iph = ip_hdr(skb);
395397

396398
iph->check = 0;
397399
ip_send_check(iph);
398400
}
399401
}
400402
if ((dext->flags & VNET_PKT_HCK_FULLCKSUM) &&
401-
skb->ip_summed == CHECKSUM_NONE)
402-
vnet_fullcsum(skb);
403+
skb->ip_summed == CHECKSUM_NONE) {
404+
if (skb->protocol == htons(ETH_P_IP)) {
405+
struct iphdr *iph = ip_hdr(skb);
406+
int ihl = iph->ihl * 4;
407+
408+
skb_reset_transport_header(skb);
409+
skb_set_transport_header(skb, ihl);
410+
vnet_fullcsum(skb);
411+
}
412+
}
403413
if (dext->flags & VNET_PKT_HCK_IPV4_HDRCKSUM_OK) {
404414
skb->ip_summed = CHECKSUM_PARTIAL;
405415
skb->csum_level = 0;

0 commit comments

Comments
 (0)