feat: Add Seqpacket support#5595
Open
aerosouund wants to merge 31 commits intofirecracker-microvm:mainfrom
Open
feat: Add Seqpacket support#5595aerosouund wants to merge 31 commits intofirecracker-microvm:mainfrom
aerosouund wants to merge 31 commits intofirecracker-microvm:mainfrom
Conversation
9cb7f64 to
4988a5e
Compare
- Make the multiplexer use a VsockConnection<ConnBackend> for its conn_map values to forward calls to stream or seqpacket types. - Make the host sock a boxed implementation of the Socket trait which exposes the accept() method with different implementations for stream and seqpacket connections. - Globally replace the MuxerConnection type with a VsockConnection generic over a ConnBackend. - Make the init_pkt_hdr method add different type constants based on the vsock type. Signed-off-by: aerosouund <aerosound161@gmail.com>
Add a new field to the vsock api and modify functions that interact with a VsockDeviceConfig or a VsockUnixBackend. Signed-off-by: aerosouund <aerosound161@gmail.com>
add changelog entry for the modified field Signed-off-by: aerosouund <aerosound161@gmail.com>
- incoming length is a trait with a default implementation to read the size of an incoming message from a connection fd - read result stores the count of bytes read and whether or no another receive should be triggered - change the VsockChannel trait to return a ReadResult instead of null Signed-off-by: aerosouund <aerosound161@gmail.com>
- create a set_msg_eom function to set eom in the packet header Signed-off-by: aerosouund <aerosound161@gmail.com>
- make it start another loop iteration if it received a result with should_retrigger Signed-off-by: aerosouund <aerosound161@gmail.com>
- add connection_buffer and conn_buffer_wrote_bytes fields to the connection - when there's a seqpacket connection with incoming data check the length of the incoming message - if its small enough to fit in the packet buffer (1 memory page size) receive directly from the af_unix to the buffer - if its bigger, receive into a buffer then copy whatever you can fit into the buffer and mark that we should retrigger - if the buffer has data, don't read from the stream. iterate until you finish the buffer - don't use intermediate rx buffering for stream connections Signed-off-by: aerosouund <aerosound161@gmail.com> connection fix Signed-off-by: aerosouund <aerosound161@gmail.com> squash Signed-off-by: aerosouund <aerosound161@gmail.com>
- propagate conn_buffer_size to connections on creation to determine how big the rx intermediate buffer should be - if the result coming from the connection has should_retrigger push to the rx queue to mark that there's still data to be read from the buffer Signed-off-by: aerosouund <aerosound161@gmail.com>
- the setting should be persisted across snapshot and restore so the new vsock buffers have the same size Signed-off-by: aerosouund <aerosound161@gmail.com>
- if the incoming message is larger than the connection buffer we return VsockError::MessageTooLong Signed-off-by: aerosouund <aerosound161@gmail.com>
- add safety comments, clippy lint supressing for too many args, remove unnecessary casts and indent functions properly Signed-off-by: aerosouund <aerosound161@gmail.com>
- make the serialization of the conn_buffer_size skipped if its none Signed-off-by: aerosouund <aerosound161@gmail.com>
- make the field documented in the api and the readme Signed-off-by: aerosouund <aerosound161@gmail.com>
covering the following scenarios: - receiving a message larger than one memory page - receiving a message small enough to fit in one page - receiving a message exactly one memory page (should cause a single receive with eom) - receiving a message larger than the conn_buffer_size, should error Signed-off-by: aerosouund <aerosound161@gmail.com>
- prevent the caller from passing too large buffers. 256 is also the limit set by the linux kernel Signed-off-by: aerosouund <aerosound161@gmail.com>
- seqpacket sockets necessitate that you read the message in one go Signed-off-by: aerosouund <aerosound161@gmail.com>
- fix serialization error to make the field default to none Signed-off-by: aerosouund <aerosound161@gmail.com>
- seqpacket sockets necessitate a different flag set than whats currently in the seccomp rules. we need to add seqpacket with SOCK_CLOEXEC for testing to work Signed-off-by: aerosouund <aerosound161@gmail.com>
- use ioctl FIONBIO to make connections non blocking instead of relying on SOCK_NONBLOCK - fix UB where the addr variable was being dropped while a live pointer to it was being returned Signed-off-by: aerosouund <aerosound161@gmail.com>
- the functional tests use an echo server which is just a socat command. socat doesn't support seqpacket. - the program listens on a port and handles a connection in a separate thread Signed-off-by: aerosouund <aerosound161@gmail.com>
- can be stream or seqpacket. to facilitate seqpacket testing Signed-off-by: aerosouund <aerosound161@gmail.com>
- create a fixture to compile the vsock_seq_server program - create start_seqpacket_echo_server to run the program in the vm - create the check_guest_connections_seqpacket function to start a host side seqpacket server and connect to it from the guestn and check data hash - create h2g, g2h and overflow functional tests Signed-off-by: aerosouund <aerosound161@gmail.com>
- seqpacket was introduced in linux 5.14. any previous version would fail Signed-off-by: aerosouund <aerosound161@gmail.com>
- the api will return an error without this field in the payload Signed-off-by: aerosouund <aerosound161@gmail.com>
- the test_cycled_snapshot_restore test checks for its existence in the output Signed-off-by: aerosouund <aerosound161@gmail.com>
- add missing safety blocks - add missing lisence for the seqpacket c server - collapse if statement in vsock.rs Signed-off-by: aerosouund <aerosound161@gmail.com>
- fix test line spacing, import ordering, indentation, formatting function calls Signed-off-by: aerosouund <aerosound161@gmail.com>
- add python docstrings and arrange imports Signed-off-by: aerosouund <aerosound161@gmail.com>
Contributor
Author
|
@JamesC1305 fixed the merge conflicts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
There's currently no support for seqpacket based vsock connections in firecracker.
This PR adds it by creating an enum
ConnBackendthat implementsVsockConnectionBackendand make its variants a unix stream or a seqpacket connection. The actual connection is handled by a module for seqpacket based connection that leverages libc calls.It adds
vsock_typeas an api parameter to the vsock type.Reason
Fixes: #4822
License Acceptance
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following Developer
Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md.PR Checklist
tools/devtool checkbuild --allto verify that the PR passesbuild checks on all supported architectures.
tools/devtool checkstyleto verify that the PR passes theautomated style checks.
how they are solving the problem in a clear and encompassing way.
in the PR.
CHANGELOG.md.Runbook for Firecracker API changes.
integration tests.
TODO.rust-vmm.