Index: head/sys/dev/hyperv/vmbus/vmbus_chan.c =================================================================== --- head/sys/dev/hyperv/vmbus/vmbus_chan.c +++ head/sys/dev/hyperv/vmbus/vmbus_chan.c @@ -926,28 +926,28 @@ int vmbus_chan_recv_pkt(struct vmbus_channel *chan, - struct vmbus_chanpkt_hdr *pkt0, int *pktlen0) + struct vmbus_chanpkt_hdr *pkt, int *pktlen0) { - struct vmbus_chanpkt_hdr pkt; - int error, pktlen; + int error, pktlen, pkt_hlen; - error = vmbus_rxbr_peek(&chan->ch_rxbr, &pkt, sizeof(pkt)); + pkt_hlen = sizeof(*pkt); + error = vmbus_rxbr_peek(&chan->ch_rxbr, pkt, pkt_hlen); if (error) return (error); - if (__predict_false(pkt.cph_hlen < VMBUS_CHANPKT_HLEN_MIN)) { - vmbus_chan_printf(chan, "invalid hlen %u\n", pkt.cph_hlen); + if (__predict_false(pkt->cph_hlen < VMBUS_CHANPKT_HLEN_MIN)) { + vmbus_chan_printf(chan, "invalid hlen %u\n", pkt->cph_hlen); /* XXX this channel is dead actually. */ return (EIO); } - if (__predict_false(pkt.cph_hlen > pkt.cph_tlen)) { + if (__predict_false(pkt->cph_hlen > pkt->cph_tlen)) { vmbus_chan_printf(chan, "invalid hlen %u and tlen %u\n", - pkt.cph_hlen, pkt.cph_tlen); + pkt->cph_hlen, pkt->cph_tlen); /* XXX this channel is dead actually. */ return (EIO); } - pktlen = VMBUS_CHANPKT_GETLEN(pkt.cph_tlen); + pktlen = VMBUS_CHANPKT_GETLEN(pkt->cph_tlen); if (*pktlen0 < pktlen) { /* Return the size of this packet. */ *pktlen0 = pktlen; @@ -955,8 +955,12 @@ } *pktlen0 = pktlen; - /* Include packet header */ - error = vmbus_rxbr_read(&chan->ch_rxbr, pkt0, pktlen, 0); + /* + * Skip the fixed-size packet header, which has been filled + * by the above vmbus_rxbr_peek(). + */ + error = vmbus_rxbr_read(&chan->ch_rxbr, pkt + 1, + pktlen - pkt_hlen, pkt_hlen); KASSERT(!error, ("vmbus_rxbr_read failed")); return (0);