Page MenuHomeFreeBSD

vtnet: Adjust for ethernet alignment.
ClosedPublic

Authored by imp on Dec 28 2023, 6:27 PM.
Tags
None
Referenced Files
Unknown Object (File)
May 11 2024, 11:24 AM
Unknown Object (File)
May 9 2024, 10:54 PM
Unknown Object (File)
May 9 2024, 10:50 PM
Unknown Object (File)
May 9 2024, 10:35 PM
Unknown Object (File)
May 9 2024, 6:21 PM
Unknown Object (File)
May 9 2024, 2:22 PM
Unknown Object (File)
May 1 2024, 7:20 AM
Unknown Object (File)
May 1 2024, 7:20 AM
Subscribers
None

Details

Summary

If the header that we add to the packet's size is 0 % 4 and we're
strictly aligning, then we need to adjust where we store the header so
the packet that follows will have it's struct ip header properly
aligned. We do this on allocation (and when we check the length of the
mbufs in the lro_nomrg case). We can't just adjust the clustersz in the
softc, because it's also used to allocate the mbufs and it needs to be
the proper size for that. Since we otherwise use the size of the mbuf
(or sometimes the smaller size of the received packet) to compute how
much we can buffer, this ensures no overflows. The 2 byte adjustment
also does not affect how many packets we can receive in the lro_nomrg
case.

Sponsored by: Netflix

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

imp requested review of this revision.Dec 28 2023, 6:27 PM
imp created this revision.
sys/dev/virtio/network/if_vtnet.c
1579

This is for 2 reasons. (1) the assert below checks m_len which will be this value and (2) we set m_len back to this value if we can't allocate.

1933

Maybe I should just drop this piece... I had code here and comments, but they were deleted before the final patch.

Drop cosmetic change to comments.

We can't just adjust the clustersz in the softc, because it's also used to allocate the mbufs and it needs to be the proper size for that.

But there is only one place (vtnet_rx_alloc_buf()) that allocates clusters using clustersz, so wouldn't that be a better place to adjust the size, rather than vtnet_rxq_replace_lro_nomrg_buf() (and any other future code which wants to know the true cluster size)?

sys/dev/virtio/network/if_vtnet.c
1537

This should be __NO_STRICT_ALIGNMENT.

1542

This doesn't compile - I guess you mean to access the softc field here?

sys/dev/virtio/network/if_vtnet.c
1542

Derp. Yes. now how did I test that (my scrollback is gone, but I'm guessing I tested the old hackish version again)

spell strict_alignment correctly.

This revision is now accepted and ready to land.Jan 23 2024, 4:52 AM
This revision was automatically updated to reflect the committed changes.