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

fix DualMode ReceiveFrom on macOS #78261

Merged
merged 6 commits into from
Nov 23, 2022
Merged

fix DualMode ReceiveFrom on macOS #78261

merged 6 commits into from
Nov 23, 2022

Conversation

wfurt
Copy link
Member

@wfurt wfurt commented Nov 12, 2022

fixes #26867
The ReceiveFrom works on macOs. The problem is that when the remote address is IPv4 on DualMode socket it comes back as plain old IPv4 so we fail to create the endpoint. It does come as IPv4Mapped Ipv6 address on Linux & Windows.
My initial fix was just to handle it as IPv4 but for consistency I decided to turn it into mapped address as well.
That should match LocalEndpoint and RemoteEndPoint on DualMode Socket that also comes as mapped addresses.

@wfurt wfurt requested a review from a team November 12, 2022 06:02
@wfurt wfurt self-assigned this Nov 12, 2022
@ghost
Copy link

ghost commented Nov 12, 2022

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

fixes #26867
The ReceiveFrom works on macOs. The problem is that when the remote address is IPv4 on DualMode socket it comes back as plain old IPv4 so we fail to create the endpoint. It does come as IPv4Mapped Ipv6 address on Linux & Windows.
My initial fix was just to handle it as IPv4 but for consistency I decided to turn it into mapped address as well.
That should match LocalEndpoint and RemoteEndPoint on DualMode Socket that also comes as mapped addresses.

Author: wfurt
Assignees: wfurt
Labels:

area-System.Net.Sockets, os-mac-os-x

Milestone: -

Co-authored-by: Ahmet Ibrahim AKSOY <aaksoy@microsoft.com>
Copy link
Member

@liveans liveans left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member

@antonfirsov antonfirsov left a comment

Choose a reason for hiding this comment

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

There are some accidental changes, otherwise LGTM.

Comment on lines 1402 to 1406
printf("%s:%d: recvmsg name %p %d socksize=%zd\n", __func__, __LINE__, header.msg_name, header.msg_namelen, sizeof(struct sockaddr_in6));
while ((res = recvmsg(fd, &header, socketFlags)) < 0 && errno == EINTR);

printf("%s:%d: recvmsg finished with %zd name %p %d\n", __func__, __LINE__, res, header.msg_name, header.msg_namelen);
printf("%s:%d: poer=%du addr (%s)\n", __func__, __LINE__, ((struct sockaddr_in*)header.msg_name)->sin_port, inet_ntoa(((struct sockaddr_in*)header.msg_name)->sin_addr));
Copy link
Member

Choose a reason for hiding this comment

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

Also looks like leftover from local debugging.

Copy link
Member Author

Choose a reason for hiding this comment

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

Where do you see it @antonfirsov. This was removed yesterday in 70a11fa

Copy link
Member

@antonfirsov antonfirsov Nov 23, 2022

Choose a reason for hiding this comment

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

No idea how I ended up commenting on the outdated variant.

@wfurt wfurt merged commit 38bcdd2 into dotnet:main Nov 23, 2022
@wfurt wfurt deleted the receiveFromMac branch November 23, 2022 17:52
@ghost ghost locked as resolved and limited conversation to collaborators Dec 23, 2022
@karelz karelz added this to the 8.0.0 milestone Mar 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sockets.ReceiveFrom should use recvfrom?
4 participants