summaryrefslogtreecommitdiff
path: root/sys/dev/pv
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2024-02-14 22:41:49 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2024-02-14 22:41:49 +0000
commit28eba6e3f2100cd3a462e774a66050163458d5ee (patch)
treee2bdb6d3868847cff0b9ea98da9dc6b411ff5649 /sys/dev/pv
parent6799ceb2ea702bd2f873cdfbc58b88ee7966a09f (diff)
Check IP length in ether_extract_headers().
For LRO with ix(4) it is necessary to detect ethernet padding. Extract ip_len and ip6_plen from the mbuf and provide it to the drivers. Add extended sanitity checks, like IP packet is shorter than TCP header. This prevents offloading to network hardware with bougus packets. Also iphlen of extracted headers contains header length for IPv4 and IPv6, to make code in drivers simpler. OK mglocker@
Diffstat (limited to 'sys/dev/pv')
-rw-r--r--sys/dev/pv/if_vio.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/sys/dev/pv/if_vio.c b/sys/dev/pv/if_vio.c
index 3648e4ac3f0..db399e7190d 100644
--- a/sys/dev/pv/if_vio.c
+++ b/sys/dev/pv/if_vio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_vio.c,v 1.30 2024/02/13 13:58:19 bluhm Exp $ */
+/* $OpenBSD: if_vio.c,v 1.31 2024/02/14 22:41:48 bluhm Exp $ */
/*
* Copyright (c) 2012 Stefan Fritsch, Alexander Fiveg.
@@ -764,12 +764,8 @@ again:
else
hdr->csum_offset = offsetof(struct udphdr, uh_sum);
- if (ext.ip4)
- hdr->csum_start += ext.ip4hlen;
-#ifdef INET6
- else if (ext.ip6)
- hdr->csum_start += sizeof(*ext.ip6);
-#endif
+ if (ext.ip4 || ext.ip6)
+ hdr->csum_start += ext.iphlen;
hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
}