Skip to content

Conversation

Ayush1325
Copy link
Contributor

Add support for binding and accepting TCP4 connections.

While testing, the following network options were used with QEMU + OVMF: -nic user,hostfwd=tcp::12345-:12345

The default localhost address on qemu seems to be 10.0.2.15.

UEFI spec does not seem to state that the TCP Handle returned by the Accept method has a ServiceBinding Protocol. So have made the ServiceBinding Protocol optional.

cc @nicholasbishop

@rustbot
Copy link
Collaborator

rustbot commented Aug 13, 2025

r? @ibraheemdev

rustbot has assigned @ibraheemdev.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 13, 2025
@ibraheemdev
Copy link
Member

Passing this along to someone else, who hopefully has more context. r? libs

@rustbot rustbot assigned thomcc and unassigned ibraheemdev Aug 19, 2025
@Ayush1325
Copy link
Contributor Author

@rustbot label +O-UEFI

@rustbot rustbot added the O-UEFI UEFI label Aug 29, 2025
@tgross35
Copy link
Contributor

tgross35 commented Sep 3, 2025

Thom is off the review rotation
r? libs

Also gentle ping @nicholasbishop for a review since we usually defer UEFI to you

@rustbot rustbot assigned tgross35 and unassigned thomcc Sep 3, 2025
Comment on lines 111 to 114
// The spec does not seem to state if we need to call ServiceBinding->DestroyChild for
// this handle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reference implementation that does or doesn't do this? Or a way to check whether or not the handle is valid after this call?

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 5, 2025
@bors
Copy link
Collaborator

bors commented Sep 11, 2025

☔ The latest upstream changes (presumably #146418) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link

@phip1611 phip1611 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM but left a few remarks

View changes since this review

@rustbot

This comment has been minimized.

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the waiting-on-author label isn't actually accurate?

This LGTM, with the note that if you are following some sort of reference implementation for #145339 (comment) then it would be good to mention what that is in a comment.

You should probably rebase before merge and verify that it still builds, since sys::net has had some changes in recent weeks. Also cc @nicholasbishop if you'd like to double check this.

View changes since this review

let completion_token =
tcp4::CompletionToken { event: evt.as_ptr(), status: Status::SUCCESS };
let mut listen_token =
tcp4::ListenToken { completion_token, new_child_handle: crate::ptr::null_mut() };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably just import crate::ptr, it's used a lot of places in this module and will likely wind up in more in the future. (totally optional here ofc)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

@rustbot
Copy link
Collaborator

rustbot commented Sep 24, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@Ayush1325
Copy link
Contributor Author

This LGTM, with the note that if you are following some sort of reference implementation for #145339 (comment) then it would be good to mention what that is in a comment.

So, just looked at the internals of edk2 again, and it does seem like I need to use service binding protocol to clean it up. From what I gather of the implementation of TcpServiceBindingDestroyChild, it seems like at least edk2 assumes there to be only one service binding protocol for both tcp4 and tcp6. In fact, no data from service binding protocol is passed or used to destroy the socket (other than then service binding protocol not being null).

So will adjust the PR once I get time.

@Ayush1325
Copy link
Contributor Author

I am now using the parent service binding protocol to handle in any connections accepted by TCP4. On EDK2, this is not really required, since there seems to be an assumption of a single service binding protocol for both TCP4 and TCP6. However, best to be safe.

I have also refactored service binding wrapper a bit. It's best to cleanup tcp4 protcol handles in it's own drop.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 24, 2025
Add support for binding and accepting TCP4 connections.

While testing, the following network options were used with QEMU + OVMF:
-nic user,hostfwd=tcp::12345-:12345

The default localhost address on qemu seems to be 10.0.2.15.

UEFI spec does not seem to state that the TCP Handle returned by the
Accept method has a ServiceBinding Protocol. So have made the
ServiceBinding Protocol optional.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-UEFI UEFI S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants