-
Notifications
You must be signed in to change notification settings - Fork 13.4k
std: sys: net: uefi: Implement TCP4 connect #139254
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
Conversation
Ayush1325
commented
Apr 2, 2025
- Implement TCP4 connect using EFI_TCP4_PROTOCOL.
- Tested on QEMU setup with connecting to TCP server on host.
r? @Noratrieb rustbot has assigned @Noratrieb. Use |
c00e658
to
0f3036c
Compare
@rustbot label +O-UEFI |
efi::EVT_NOTIFY_SIGNAL, | ||
efi::TPL_CALLBACK, | ||
Some(toggle_atomic_flag), | ||
Some(unsafe { NonNull::new_unchecked(self.flag.as_ptr().cast()) }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes wait_for_flag
unsound – there is no guarantee that the structure will not be moved in the time between the calls, which would invalidate this pointer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I use Condvar then? Or is there a way to have Atomic on Heap or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd remove the flag, make the notification function a no-op and use CheckEvent
on the event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The event is of type Signal. The CheckEvent doc states the following
If Event is of type EVT_NOTIFY_SIGNAL, then EFI_INVALID_PARAMETER is returned.
The reason the event is of type Signal is because the tcp4 protocol connect doc states the following
The Event to signal after request is finished and Status field is updated by the EFI TCPv4 Protocol driver. The
type of Event must be EVT_NOTIFY_SIGNAL, and its Task Priority Level (TPL) must be lower than or equal to TPL_CALLBACK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I missed that. Then the easiest way is probably just to ensure that the flag outlives the event. Why not just inline wait_for_flag
and make flag
a local variable? Alternatively, make create_evt
unsafe
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I missed that. Then the easiest way is probably just to ensure that the flag outlives the event. Why not just inline
wait_for_flag
and makeflag
a local variable? Alternatively, makecreate_evt
unsafe
.
I would prefer not to inline wait_for_flag
since that will be repeated in almost all other implementations soon enough (read, write, close, etc). I have made create_evt
unsafe. Is that ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not the cleanest solution ever™, but I guess it's fine. In the future it might be nice to create a single global event for all "blocking" I/O calls in std
.
0f3036c
to
a1e459d
Compare
r? joboet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for not getting back to you for so long. This looks mostly fine to me.
efi::EVT_NOTIFY_SIGNAL, | ||
efi::TPL_CALLBACK, | ||
Some(toggle_atomic_flag), | ||
Some(unsafe { NonNull::new_unchecked(self.flag.as_ptr().cast()) }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not the cleanest solution ever™, but I guess it's fine. In the future it might be nice to create a single global event for all "blocking" I/O calls in std
.
a1e459d
to
3d0d7c6
Compare
- Implement TCP4 connect using EFI_TCP4_PROTOCOL. - Tested on QEMU setup with connecting to TCP server on host. Signed-off-by: Ayush Singh <[email protected]>
3d0d7c6
to
e21aab5
Compare
@rustbot ready |
@bors r+ |
Rollup of 6 pull requests Successful merges: - #137323 (Guarantee behavior of transmuting `Option::<T>::None` subject to NPO) - #139254 (std: sys: net: uefi: Implement TCP4 connect) - #141432 (refactor `CanonicalVarKind`) - #141480 (document some -Z flags as living in the rustc-dev-guide) - #141486 (rustdoc book: add argument explanation for `html_playground_url`) - #141496 (Enable `[issue-links]` and `[no-mentions]` in triagebot) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #139254 - Ayush1325:uefi-tcp4-connect, r=joboet std: sys: net: uefi: Implement TCP4 connect - Implement TCP4 connect using EFI_TCP4_PROTOCOL. - Tested on QEMU setup with connecting to TCP server on host.
std: sys: net: uefi: Implement TCP4 connect - Implement TCP4 connect using EFI_TCP4_PROTOCOL. - Tested on QEMU setup with connecting to TCP server on host.