-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[Android] Fix NetworkInterface.GetAllNetworkInterfaces #76370
[Android] Fix NetworkInterface.GetAllNetworkInterfaces #76370
Conversation
…dotnet#71943)" This reverts commit 1de4a5c.
Tagging subscribers to 'arch-android': @steveisok, @akoeplinger Issue DetailsApparently, since Android API 30, the This PR fixes the allocation problem (see Reverts #71943 and restores the previous implementation from #62780
|
Tagging subscribers to this area: @dotnet/ncl Issue DetailsApparently, since Android API 30, the This PR fixes the allocation problem (see Reverts #71943 and restores the previous implementation from #62780
|
/azp run runtime-extra-platforms |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run runtime-extra-platforms |
Azure Pipelines successfully started running 1 pipeline(s). |
Co-authored-by: Alexander Köplinger <[email protected]>
/azp run runtime-extra-platforms |
Azure Pipelines successfully started running 1 pipeline(s). |
Failing tests are unrelated to this PR and many of them are known issues:
|
* Revert "[Android] Port getifaddrs implementation from Xamarin.Android (dotnet#71943)" This reverts commit 1de4a5c. * Fix allocating memory block for interfaces and addresses on recent Android SDKs * Detect loopback interface on Android * Add comment with explanation * Simplify the changes to be closer to the original code * Fix build * Fix typos Co-authored-by: Alexander Köplinger <[email protected]> * Improve comment * Indent using spaces instead of tabs * Remove check for ifaddrs.h * Add ANDROID_GETIFADDRS_WORKAROUND * Update comment Co-authored-by: Alexander Köplinger <[email protected]>
…erfaces (#76565) * [Android] Fix NetworkInterface.GetAllNetworkInterfaces (#76370) * Revert "[Android] Port getifaddrs implementation from Xamarin.Android (#71943)" This reverts commit 1de4a5c. * Fix allocating memory block for interfaces and addresses on recent Android SDKs * Detect loopback interface on Android * Add comment with explanation * Simplify the changes to be closer to the original code * Fix build * Fix typos Co-authored-by: Alexander Köplinger <[email protected]> * Improve comment * Indent using spaces instead of tabs * Remove check for ifaddrs.h * Add ANDROID_GETIFADDRS_WORKAROUND * Update comment Co-authored-by: Alexander Köplinger <[email protected]> * [Android] Fix NetworkInterface.GetAllNetworkInterfaces on API 21-23 (#76541) * Bring back pal_ifaddrs * Update the header file Co-authored-by: Alexander Köplinger <[email protected]>
/backport to release/6.0 |
Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/3283870988 |
@steveisok backporting to release/6.0 failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: Revert "[Android] Port getifaddrs implementation from Xamarin.Android (#71943)"
Using index info to reconstruct a base tree...
M src/mono/cmake/config.h.in
A src/native/libs/Common/pal_config.h.in
A src/native/libs/System.Native/CMakeLists.txt
A src/native/libs/System.Native/pal_ifaddrs.c
A src/native/libs/System.Native/pal_ifaddrs.h
A src/native/libs/System.Native/pal_interfaceaddresses.c
A src/native/libs/configure.cmake
Falling back to patching base and 3-way merge...
Auto-merging src/mono/cmake/config.h.in
Auto-merging src/libraries/Native/Unix/configure.cmake
Auto-merging src/libraries/Native/Unix/System.Native/pal_interfaceaddresses.c
CONFLICT (rename/delete): src/native/libs/System.Native/pal_ifaddrs.h deleted in Revert "[Android] Port getifaddrs implementation from Xamarin.Android (#71943)" and renamed to src/libraries/Native/Unix/System.Native/pal_ifaddrs.h in HEAD. Version HEAD of src/libraries/Native/Unix/System.Native/pal_ifaddrs.h left in tree.
CONFLICT (rename/delete): src/native/libs/System.Native/pal_ifaddrs.c deleted in Revert "[Android] Port getifaddrs implementation from Xamarin.Android (#71943)" and renamed to src/libraries/Native/Unix/System.Native/pal_ifaddrs.c in HEAD. Version HEAD of src/libraries/Native/Unix/System.Native/pal_ifaddrs.c left in tree.
Auto-merging src/libraries/Native/Unix/System.Native/CMakeLists.txt
Auto-merging src/libraries/Native/Unix/Common/pal_config.h.in
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Revert "[Android] Port getifaddrs implementation from Xamarin.Android (#71943)"
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128 Please backport manually! |
@simonrozsival When you have a moment, can you please try and backport this to release/6.0? |
* Revert "[Android] Port getifaddrs implementation from Xamarin.Android (dotnet#71943)" This reverts commit 1de4a5c. * Fix allocating memory block for interfaces and addresses on recent Android SDKs * Detect loopback interface on Android * Add comment with explanation * Simplify the changes to be closer to the original code * Fix build * Fix typos Co-authored-by: Alexander Köplinger <[email protected]> * Improve comment * Indent using spaces instead of tabs * Remove check for ifaddrs.h * Add ANDROID_GETIFADDRS_WORKAROUND * Update comment Co-authored-by: Alexander Köplinger <[email protected]>
…erfaces (#77260) * [Android] Fix NetworkInterface.GetAllNetworkInterfaces (#76370) * Revert "[Android] Port getifaddrs implementation from Xamarin.Android (#71943)" This reverts commit 1de4a5c. * Fix allocating memory block for interfaces and addresses on recent Android SDKs * Detect loopback interface on Android * Add comment with explanation * Simplify the changes to be closer to the original code * Fix build * Fix typos Co-authored-by: Alexander Köplinger <[email protected]> * Improve comment * Indent using spaces instead of tabs * Remove check for ifaddrs.h * Add ANDROID_GETIFADDRS_WORKAROUND * Update comment Co-authored-by: Alexander Köplinger <[email protected]> * [Android] Fix NetworkInterface.GetAllNetworkInterfaces on API 21-23 (#76541) * Bring back pal_ifaddrs * Update the header file Co-authored-by: Alexander Köplinger <[email protected]>
Apparently, since Android API 30, the
getifaddrs
function returns onlyAF_INET
andAF_INET6
addresses and doesn't return anyAF_PACKET
. The problem was that we allocated thememoryBlock
in such a way that theinterfaceList
and theaddressList
overlapped and in the end both contained invalid data. We replaced the default implementation ofgetifaddrs
with one from Xamarin (#71943) based on netlink but that turned out to be an insufficient fix and doesn't work on recent Android versions.This PR fixes the allocation problem (see
pal_interfaceaddresses.c:356-400
and removes the customgetifaddrs
implementation inpal_ifaddrs.h
andpal_ifaddrs.c
.Reverts #71943 and restores the previous implementation from #62780
Fixes #75809
Fixes #76493
Fixes dotnet/android#6973
Followed up by PR #76541