]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
vtnet: Account for the padding when selecting allocation size
authorWarner Losh <imp@FreeBSD.org>
Mon, 5 Feb 2024 05:43:39 +0000 (22:43 -0700)
committerWarner Losh <imp@FreeBSD.org>
Mon, 19 Feb 2024 06:59:46 +0000 (23:59 -0700)
commit67aff34d9ad00761b2e2b1197c4bc1e856bb6959
treea547b74c645bb53719ef73182b1b3fbd1adb81e5
parentfbbfcab6b850fd0125633cc87575b54f0929c1a8
vtnet: Account for the padding when selecting allocation size

While we account for the padding in the length of the mbuf we use, we do
not account for it when we 'guess' the size of the mbuf to allocate
based in the MTU of the device. This leads to a situation where we might
fail if the mtu is close to a bucket size (say 2018) such that the added
padding would push us over the edge for a full-sized packet. mtu of 2018
is super rare (2016 and 2020 would both work), but fix it none-the-less.
It's a shame we can't just set VTNET_RX_HEADER_PAD to 2 in this case. The 4
seems hard-coded somewhere I've not found documented (I think it's in the
protocol given the comments about VIRTIO_F_ANY_LAYOUT).

Sponsored by: Netflix
Reviewed by: bz
Differential Revision: https://reviews.freebsd.org/D43656

(cherry picked from commit d9e0e42627613b56abf0f8fa1ad601e5690d775c)
(cherry picked from commit 1dc264a126b13e0e20b13bbcd69451c5d4b63f7c)

Approved-by: re (cperciva)
sys/dev/virtio/network/if_vtnet.c
sys/dev/virtio/network/if_vtnetvar.h