Skip to content

Add initial version of the TCP wrapper#2595

Merged
stevenengler merged 3 commits intoshadow:mainfrom
stevenengler:wrap-tcp-rust
Dec 9, 2022
Merged

Add initial version of the TCP wrapper#2595
stevenengler merged 3 commits intoshadow:mainfrom
stevenengler:wrap-tcp-rust

Conversation

@stevenengler
Copy link
Copy Markdown
Contributor

For most syscalls, we simply call the C syscall handler from the rust syscall handler just like we did before. This lets us incrementally add support for individual syscalls for this TcpSocket wrapper.

The LegacyCallbackQueue prevents circular borrows when running event listeners. For the close() syscall, this prevents a panic where the syscall handler mutably borrows the TcpSocket, the inner C TCP object changes to the CLOSED state, an epoll event listener callback is run, and the callback takes a shared borrow of the TcpSocket. Just like we do with the rust file objects, the callback queue allows us to delay callbacks until later.

A temporary LegacyCallbackQueue is stored as a thread-local so that the LegacyDescriptor can access it without us having to update large amounts of C code to pass it through to everywhere we need it. Since we're deprecating/removing the C code, it's not worth the effort / possible breakage to update it.

For most syscalls, we simply call the C syscall handler from the rust syscall
handler just like we did before. This lets us incrementally add support for
individual syscalls for this `TcpSocket` wrapper.
This causes shadow to panic when TCP sockets are closed. This is fixed in the
next commit.
The `LegacyCallbackQueue` prevents circular borrows when running event
listeners. For the `close()` syscall, this prevents the panic where the syscall
handler mutably borrows the `TcpSocket`, the inner C `TCP` object changes to
the `CLOSED` state, an epoll event listener callback is run, and the callback
takes a shared borrow of the `TcpSocket`.

A temporary `LegacyCallbackQueue` is stored as a thread-local so that the
`LegacyDescriptor` can access it without us having to update large amounts of C
code to pass it through to everywhere we need it. Since we're
deprecating/removing the C code, it's not worth the effort / possible breakage
to update it.
@stevenengler stevenengler self-assigned this Dec 9, 2022
@github-actions github-actions bot added the Component: Main Composing the core Shadow executable label Dec 9, 2022
@codecov
Copy link
Copy Markdown

codecov bot commented Dec 9, 2022

Codecov Report

Base: 0.00% // Head: 66.67% // Increases project coverage by +66.67% 🎉

Coverage data is based on head (eff74fe) compared to base (1806dcf).
Patch coverage: 76.82% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff            @@
##           main    #2595       +/-   ##
=========================================
+ Coverage      0   66.67%   +66.67%     
=========================================
  Files         0      198      +198     
  Lines         0    29323    +29323     
  Branches      0     5773     +5773     
=========================================
+ Hits          0    19551    +19551     
- Misses        0     5222     +5222     
- Partials      0     4550     +4550     
Flag Coverage Δ
tests 66.67% <76.82%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/main/host/host.rs 80.78% <ø> (ø)
src/main/utility/mod.rs 52.98% <ø> (ø)
src/main/host/process.rs 65.62% <50.00%> (ø)
src/main/host/syscall/handler/ioctl.rs 29.41% <50.00%> (ø)
src/main/host/syscall/handler/socket.rs 65.47% <67.74%> (ø)
src/main/host/syscall/handler/unistd.rs 53.90% <69.23%> (ø)
src/main/host/descriptor/mod.rs 66.80% <76.92%> (ø)
src/main/utility/legacy_callback_queue.rs 78.84% <78.84%> (ø)
src/main/host/descriptor/socket/inet/tcp.rs 63.63% <87.23%> (ø)
...rc/test/threads/test_threads_group_leader_exits.rs 11.11% <0.00%> (ø)
... and 196 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@stevenengler stevenengler merged commit bd64424 into shadow:main Dec 9, 2022
@stevenengler stevenengler deleted the wrap-tcp-rust branch December 9, 2022 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Main Composing the core Shadow executable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants