Page MenuHomeFreeBSD

vtnet: Adjust for ethernet alignment.
ClosedPublic

Authored by imp on Dec 28 2023, 6:27 PM.
Tags
None
Referenced Files
F102576815: D43224.id.diff
Thu, Nov 14, 6:56 AM
Unknown Object (File)
Thu, Nov 7, 11:41 PM
Unknown Object (File)
Thu, Nov 7, 9:08 PM
Unknown Object (File)
Wed, Nov 6, 12:26 PM
Unknown Object (File)
Thu, Oct 24, 11:04 PM
Unknown Object (File)
Thu, Oct 17, 2:15 PM
Unknown Object (File)
Thu, Oct 17, 2:39 AM
Unknown Object (File)
Wed, Oct 16, 3:44 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 Skipped
Unit
Tests Skipped
Build Status
Buildable 55145
Build 52034: arc lint + arc unit

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.