-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Vnetif_stack, connect test and other helper functions #30
Merged
Conversation
This file contains 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
This commit adds support for creating the V4 stack directly from the library (Vnetif_stack). Previously we only provided the netif layer, so the stack had to be assembled manually. The Vnetif.connect function now accepts an optional monitor function. This function can be used to capture packets as they are read/written by the virtual interface. Packets can also be captured by connecting another interface to the backend and observe traffic from there, but this may result in a different ordering when the listen functions are called in async (which they usually are). By capturing on the interface we're able to see the traffic in the same order as it is sent/received. An unlock_on_listen mutex can now be passed to Vnetif.connect. If specified, the mutex will be unlocked if the listen function is called on the interface. This is useful for tests where a client thread waits for a server to listen for new connections. The client can now wait for the lock to unlock instead of sleeping. Signed-off-by: Magnus Skjegstad <[email protected]>
Add a basic connect test based on the earlier connect example. Uses the netif mutex to wait for client to connect. Signed-off-by: Magnus Skjegstad <[email protected]>
Some of the libraries were only needed for tests, so move them to the tests dune file Signed-off-by: Magnus Skjegstad <[email protected]>
Vnetif_stack is now bundled in its own package to avoid a circular dependency on tcpip, which uses regular Vnetif for testing. Tests are currently only available for the mirage-vnetif-stack package, as they use tcpip to establish a connection. Also cleans up the main opam file to remove unused dependencies.
dinosaure
added a commit
to dinosaure/opam-repository
that referenced
this pull request
Mar 22, 2022
CHANGES: - add option for capturing packets directly on the interface (mirage/mirage-vnetif#30, @MagnusS) - add option for unlocking a mutex when the interface is in listen mode (mirage/mirage-vnetif#30, @MagnusS) - add package mirage-vnetif-stack to provide a preassembled ipv4 stack (mirage/mirage-vnetif#30, @MagnusS) - add initial connect test for the vnetif-stack (mirage/mirage-vnetif#30, @MagnusS) - clean up opam dependencies (mirage/mirage-vnetif#30, @MagnusS) - drop mirage protocols and adapt to arp, ipaddr, tcpip interface changes (mirage/mirage-vnetif#33, @MisterDA)
dinosaure
added a commit
to dinosaure/opam-repository
that referenced
this pull request
Mar 22, 2022
CHANGES: - add option for capturing packets directly on the interface (mirage/mirage-vnetif#30, @MagnusS) - add option for unlocking a mutex when the interface is in listen mode (mirage/mirage-vnetif#30, @MagnusS) - add package mirage-vnetif-stack to provide a preassembled ipv4 stack (mirage/mirage-vnetif#30, @MagnusS) - add initial connect test for the vnetif-stack (mirage/mirage-vnetif#30, @MagnusS) - clean up opam dependencies (mirage/mirage-vnetif#30, @MagnusS) - drop mirage protocols and adapt to arp, ipaddr, tcpip interface changes (mirage/mirage-vnetif#33, @MisterDA)
dinosaure
added a commit
to dinosaure/opam-repository
that referenced
this pull request
Mar 22, 2022
CHANGES: - add option for capturing packets directly on the interface (mirage/mirage-vnetif#30, @MagnusS) - add option for unlocking a mutex when the interface is in listen mode (mirage/mirage-vnetif#30, @MagnusS) - add package mirage-vnetif-stack to provide a preassembled ipv4 stack (mirage/mirage-vnetif#30, @MagnusS) - add initial connect test for the vnetif-stack (mirage/mirage-vnetif#30, @MagnusS) - clean up opam dependencies (mirage/mirage-vnetif#30, @MagnusS) - drop mirage protocols and adapt to arp, ipaddr, tcpip interface changes (mirage/mirage-vnetif#33, @MisterDA) - restore old behavior of `mirage-vnetif` to avoid breaking changes (f0b8341, @dinosaure)
dinosaure
added a commit
to dinosaure/opam-repository
that referenced
this pull request
Mar 22, 2022
CHANGES: - add option for capturing packets directly on the interface (mirage/mirage-vnetif#30, @MagnusS) - add option for unlocking a mutex when the interface is in listen mode (mirage/mirage-vnetif#30, @MagnusS) - add package mirage-vnetif-stack to provide a preassembled ipv4 stack (mirage/mirage-vnetif#30, @MagnusS) - add initial connect test for the vnetif-stack (mirage/mirage-vnetif#30, @MagnusS) - clean up opam dependencies (mirage/mirage-vnetif#30, @MagnusS) - drop mirage protocols and adapt to arp, ipaddr, tcpip interface changes (mirage/mirage-vnetif#33, @MisterDA) - restore old behavior of `mirage-vnetif` to avoid breaking changes (f0b8341, @dinosaure)
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.
This PR adds support for creating the V4 stack directly from the library (Vnetif_stack). Previously we only provided the netif layer, so the stack had to be assembled manually by the caller. This adds a new dependency on tcpip, which also depends on mirage-vnetif for tests, so this may have to be resolved before release.
The Vnetif.connect function now accepts an optional monitor function. This function can be used to capture packets as they are read/written by the virtual interface. Packets can also be captured by connecting another interface to the backend and observe traffic from there (as is done in mirage-tcpip), but this may result in a different ordering when the listen functions are called in async (which they usually are). By capturing on the interface we're able to see the traffic in the same order as it is sent/received.
An unlock_on_listen mutex can now be passed to Vnetif.connect. If specified, the mutex will be unlocked if the listen function is called on the interface. This is useful for tests where a client thread waits for a server to listen for new connections. The client can now wait for the lock to unlock instead of sleeping.
Also adds a basic connect test based on the earlier connect example which uses the netif mutex to wait for client to connect instead of sleeping.