Skip to content
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
merged 6 commits into from
May 13, 2020

Conversation

MagnusS
Copy link
Member

@MagnusS MagnusS commented Mar 19, 2020

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.

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 <magnus@skjegstad.com>
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 <magnus@skjegstad.com>
@MagnusS
Copy link
Member Author

MagnusS commented Mar 19, 2020

(Fixes #20 and #18)

Some of the libraries were only needed for tests, so move them
to the tests dune file

Signed-off-by: Magnus Skjegstad <magnus@skjegstad.com>
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.
MagnusS referenced this pull request Apr 30, 2020
Fix Makefile, remove dead code
@MagnusS MagnusS merged commit e33e44c into mirage:master May 13, 2020
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant