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: get network card interface in Android 11 environment #61088

Closed
wants to merge 1 commit into from

Conversation

wlynxg
Copy link

@wlynxg wlynxg commented Jun 30, 2023

For #40569

Fix: In response to the modifications made to the permissions for accessing system MAC addresses in Android 11, ordinary applications encounter several main issues when using NETLINK sockets:

  • Not allowing bind operations on NETLINK sockets.
  • Not permitting the use of the RTM_GETLINK functionality.

For detailed information, please refer to: https://developer.android.com/training/articles/user-data-ids#mac-11-plus

As a result of the aforementioned reasons, using net.Interfaces() and net.InterfaceAddrs() from the Go net package in the Android environment leads to the route ip+net: netlinkrib: permission denied error.

You can find specific issue details here: #40569

To address the issue of using the Go net package in the Android environment, we have made partial modifications to its source code to ensure proper functionality on Android.

I have fully resolved the issues with net.InterfaceAddrs().

However, for net.Interfaces(), we have only addressed some problems, as the following issues still remain:

  • It can only return interfaces with IP addresses.
  • It cannot return hardware MAC addresses.

Nevertheless, the fixed net.Interfaces() function now aligns with the Android API's NetworkInterface.getNetworkInterfaces() and can be used normally in most scenarios.

The specific fix logic includes:

Removing the Bind() operation on Netlink sockets in the NetlinkRIB() function.
Using ioctl based on the Index number returned by RTM_GETADDR to retrieve the network card's name, MTU, and flags.

@google-cla
Copy link

google-cla bot commented Jun 30, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@wlynxg wlynxg closed this Jun 30, 2023
@hopwesley
Copy link

package gobind/gobind
imports fmt
imports os
imports internal/poll
imports internal/syscall/unix
imports syscall
imports os: import cycle not allowed
package gobind/gobind
imports fmt
imports os
imports internal/poll
imports internal/syscall/unix
imports syscall
imports os: import cycle not allowed
package gobind/gobind
imports fmt
imports os
imports internal/poll
imports internal/syscall/unix
imports syscall
imports os: import cycle not allowed
package gobind/gobind
imports fmt
imports os
imports internal/poll
imports internal/syscall/unix
imports syscall
imports os: import cycle not allowed

@wlynxg
Copy link
Author

wlynxg commented Oct 8, 2023

package gobind/gobind imports fmt imports os imports internal/poll imports internal/syscall/unix imports syscall imports os: import cycle not allowed package gobind/gobind imports fmt imports os imports internal/poll imports internal/syscall/unix imports syscall imports os: import cycle not allowed package gobind/gobind imports fmt imports os imports internal/poll imports internal/syscall/unix imports syscall imports os: import cycle not allowed package gobind/gobind imports fmt imports os imports internal/poll imports internal/syscall/unix imports syscall imports os: import cycle not allowed

This pull was a mistake on my part, the correct one is this: #61089

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants