summaryrefslogtreecommitdiffstats
path: root/sys/dev/hyperv/utilities/hv_util.c
diff options
context:
space:
mode:
authorsephe <sephe@FreeBSD.org>2016-10-13 05:59:33 +0000
committersephe <sephe@FreeBSD.org>2016-10-13 05:59:33 +0000
commitf158b55f5f5918f69bb6a4dee3f9d3862a972151 (patch)
treee4dc0f81d9720c5ccf7212b46a4cee3a180beda6 /sys/dev/hyperv/utilities/hv_util.c
parent1e6ea0f603ada5448cfed65ea2046588d66e8719 (diff)
downloadFreeBSD-src-f158b55f5f5918f69bb6a4dee3f9d3862a972151.zip
FreeBSD-src-f158b55f5f5918f69bb6a4dee3f9d3862a972151.tar.gz
MFC 304786,304788
304786 hyperv/ic: Cleanup heartbeat channel callback. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7626 304788 hyperv/ic: Update total message size if negotiate message size grows. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7627
Diffstat (limited to 'sys/dev/hyperv/utilities/hv_util.c')
-rw-r--r--sys/dev/hyperv/utilities/hv_util.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/sys/dev/hyperv/utilities/hv_util.c b/sys/dev/hyperv/utilities/hv_util.c
index bb5b110..3fc16c9 100644
--- a/sys/dev/hyperv/utilities/hv_util.c
+++ b/sys/dev/hyperv/utilities/hv_util.c
@@ -48,13 +48,16 @@
#define VMBUS_IC_BRSIZE (4 * PAGE_SIZE)
-CTASSERT(sizeof(struct vmbus_icmsg_negotiate) < VMBUS_IC_BRSIZE);
+#define VMBUS_IC_VERCNT 2
+#define VMBUS_IC_NEGOSZ \
+ __offsetof(struct vmbus_icmsg_negotiate, ic_ver[VMBUS_IC_VERCNT])
+CTASSERT(VMBUS_IC_NEGOSZ < VMBUS_IC_BRSIZE);
int
-vmbus_ic_negomsg(struct hv_util_sc *sc, void *data, int dlen)
+vmbus_ic_negomsg(struct hv_util_sc *sc, void *data, int *dlen0)
{
struct vmbus_icmsg_negotiate *nego;
- int cnt, major;
+ int cnt, major, dlen = *dlen0;
/*
* Preliminary message size verification
@@ -87,9 +90,13 @@ vmbus_ic_negomsg(struct hv_util_sc *sc, void *data, int dlen)
nego->ic_msgver_cnt = 1;
nego->ic_ver[1] = VMBUS_IC_VERSION(major, 0);
- /* Data contains two versions */
- nego->ic_hdr.ic_dsize = __offsetof(struct vmbus_icmsg_negotiate,
- ic_ver[2]) - sizeof(struct vmbus_icmsg_hdr);
+ /* Update data size */
+ nego->ic_hdr.ic_dsize = VMBUS_IC_NEGOSZ -
+ sizeof(struct vmbus_icmsg_hdr);
+
+ /* Update total size, if necessary */
+ if (dlen < VMBUS_IC_NEGOSZ)
+ *dlen0 = VMBUS_IC_NEGOSZ;
return 0;
}
OpenPOWER on IntegriCloud