Skip to content

[iOS] Make sure IPGlobalProperties and NetworkInterface.GetIsNetworkAvailable methods return the correct info #57096

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

Merged
merged 2 commits into from
Sep 16, 2021

Conversation

steveisok
Copy link
Member

This change makes sure some of the IPGlobalProperties stop throwing exceptions and return the correct values.

  • GetIPv4GlobalStatistics, GetIcmpV4Statistics, GetTcpIPv4Statistics, GetUdpIPv4Statistics no longer throw NetworkInformationException.

  • GetActiveTcpConnections no longer returns TcpConnectionInformation instances only with the State of Unknown.

  • GetActiveTcpListeners return the correct IPEndPoint details for the IPV6 loopback.

  • NetworkInterface.GetIsNetworkAvailable no longer returns false for every call.

The reason these methods were behaving incorrectly on iOS is due to Apple not including the public headers for icmp_var.h, ip_var.h, tcp_fsm.h, if_media.h, and udp_var.h in the iOS SDK. This would lead to, for example, pal_tcpstate.c always returning TcpState_Unknown even if the underlying native value was TCPS_ESTABLISHED. This change includes the missing public headers in our build.

Fixes #36890

…vailable methods return the correct info

This change makes sure some of the IPGlobalProperties stop throwing exceptions and return the correct values.

- GetIPv4GlobalStatistics, GetIcmpV4Statistics, GetTcpIPv4Statistics, GetUdpIPv4Statistics no longer throw NetworkInformationException.

- GetActiveTcpConnections no longer returns TcpConnectionInformation instances only with the State of Unknown.

- GetActiveTcpListeners return the correct IPEndPoint details for the IPV6 loopback.

- NetworkInterface.GetIsNetworkAvailable no longer returns false for every call.

The reason these methods were behaving incorrectly on iOS is due to Apple not including the public headers for icmp_var.h, ip_var.h, tcp_fsm.h, if_media.h, and udp_var.h in the iOS SDK.  This would lead to, for example, pal_tcpstate.c always returning TcpState_Unknown even if the underlying native value was TCPS_ESTABLISHED. This change includes the missing public headers in our build.

Fixes dotnet#36890
@ghost ghost added the area-System.Net label Aug 9, 2021
@ghost
Copy link

ghost commented Aug 9, 2021

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

Issue Details

This change makes sure some of the IPGlobalProperties stop throwing exceptions and return the correct values.

  • GetIPv4GlobalStatistics, GetIcmpV4Statistics, GetTcpIPv4Statistics, GetUdpIPv4Statistics no longer throw NetworkInformationException.

  • GetActiveTcpConnections no longer returns TcpConnectionInformation instances only with the State of Unknown.

  • GetActiveTcpListeners return the correct IPEndPoint details for the IPV6 loopback.

  • NetworkInterface.GetIsNetworkAvailable no longer returns false for every call.

The reason these methods were behaving incorrectly on iOS is due to Apple not including the public headers for icmp_var.h, ip_var.h, tcp_fsm.h, if_media.h, and udp_var.h in the iOS SDK. This would lead to, for example, pal_tcpstate.c always returning TcpState_Unknown even if the underlying native value was TCPS_ESTABLISHED. This change includes the missing public headers in our build.

Fixes #36890

Author: steveisok
Assignees: -
Labels:

area-System.Net

Milestone: -

Copy link
Member

@wfurt wfurt left a comment

Choose a reason for hiding this comment

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

LGTM.

I'm wondering if we would know if the headers ever change and the structures no longer match....

* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
Copy link
Member

Choose a reason for hiding this comment

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

Just want to make sure this license is compatible with our repo...

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Just curious, why is it necessary to commit the Apple headers? Aren't they available in their SDK during build, similar to winnt.h etc?

@omajid do you consider this an acceptable license? I assume so since as @steveisok points out we already have such code.

Copy link
Member

@omajid omajid Sep 7, 2021

Choose a reason for hiding this comment

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

I wasn't sure, so I went looking.

https://www.gnu.org/philosophy/apsl.en.html says:

The Apple Public Source License (APSL) version 2.0 qualifies as a free software license.

It's in the OSI list too: https://opensource.org/licenses/APSL-2.0

Fedora considers this license as okay too: https://fedoraproject.org/wiki/Licensing:Main#Good_Licenses (search for "APSL 2.0" in the table). Red Hat legal has approved it for RHEL as well.

All this is for the 2.0 variant. The opinion on 1.x seems to be that it's not acceptable.

Copy link
Member Author

Choose a reason for hiding this comment

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

Just curious, why is it necessary to commit the Apple headers? Aren't they available in their SDK during build, similar to winnt.h etc?

@omajid do you consider this an acceptable license? I assume so since as @steveisok points out we already have such code.

It's unknown exactly why they are excluded from the iOS SDK. The likely explanation is that Apple can more easily move on from supporting them.

@danmoseley danmoseley added the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Aug 12, 2021
@danmoseley
Copy link
Member

Marking no merge while we check with @richlander . Since I'm fixing another incorrect license in a PR at the moment!

@karelz karelz added this to the 7.0.0 milestone Aug 20, 2021
@karelz karelz added the os-ios Apple iOS label Aug 24, 2021
@steveisok
Copy link
Member Author

@richlander Can you give this a look as I'd like to make sure the licensing is ok before merging.

@karelz
Copy link
Member

karelz commented Sep 6, 2021

@steveisok any update here?

@steveisok
Copy link
Member Author

@karelz I'm waiting on the go-ahead from @richlander re: the license files.

@richlander
Copy link
Member

LGTM. It looks like @omajid is also happy so that covers it.

@steveisok steveisok merged commit 7073360 into dotnet:main Sep 16, 2021
@steveisok steveisok removed the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Sep 16, 2021
@steveisok
Copy link
Member Author

/backport to release/6.0

@github-actions
Copy link
Contributor

Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/1242351574

@steveisok
Copy link
Member Author

/backport to release/6.0-rc2

@github-actions
Copy link
Contributor

Started backporting to release/6.0-rc2: https://github.com/dotnet/runtime/actions/runs/1245525236

steveisok pushed a commit that referenced this pull request Sep 21, 2021
…face.GetIsNetworkAvailable methods return the correct info (#59258)

Backport of #57096

This change makes sure some of the IPGlobalProperties stop throwing exceptions and return the correct values.

GetIPv4GlobalStatistics, GetIcmpV4Statistics, GetTcpIPv4Statistics, GetUdpIPv4Statistics no longer throw NetworkInformationException.

GetActiveTcpConnections no longer returns TcpConnectionInformation instances only with the State of Unknown.

GetActiveTcpListeners return the correct IPEndPoint details for the IPV6 loopback.

NetworkInterface.GetIsNetworkAvailable no longer returns false for every call.

The reason these methods were behaving incorrectly on iOS is due to Apple not including the public headers for icmp_var.h, ip_var.h, tcp_fsm.h, if_media.h, and udp_var.h in the iOS SDK. This would lead to, for example, pal_tcpstate.c always returning TcpState_Unknown even if the underlying native value was TCPS_ESTABLISHED. This change includes the missing public headers in our build.

Fixes #36890
@ghost ghost locked as resolved and limited conversation to collaborators Nov 3, 2021
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.

System.Net.NetworkInformation.Functional.Tests fail on iOS
7 participants