Skip to content

Commit

Permalink
Fix go/issues/68082 for golang.org/x/net subproject
Browse files Browse the repository at this point in the history
  • Loading branch information
bobrofon committed Jul 28, 2024
1 parent c6dbd5e commit 5a20851
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ 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.




There are two implementations of the `net` package: one from the [Go standard library](https://pkg.go.dev/net) and another from the [golang.org/x/net](https://pkg.go.dev/golang.org/x/net) module. Both of these implementations have the same issues in the Android environment. The `anet` package should be compatible with both of them.

## Test Code
### net.Interface()
Expand Down
5 changes: 5 additions & 0 deletions interface_android.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func Interfaces() ([]net.Interface, error) {
}
if len(ift) != 0 {
zoneCache.update(ift, false)
zoneCacheX.update(ift, false)
}
return ift, nil
}
Expand Down Expand Up @@ -94,6 +95,7 @@ func InterfaceByName(name string) (*net.Interface, error) {
}
if len(ift) != 0 {
zoneCache.update(ift, false)
zoneCacheX.update(ift, false)
}
for _, ifi := range ift {
if name == ifi.Name {
Expand Down Expand Up @@ -144,6 +146,9 @@ type ipv6ZoneCache struct {
//go:linkname zoneCache net.zoneCache
var zoneCache ipv6ZoneCache

//go:linkname zoneCacheX golang.org/x/net/internal/socket.zoneCache
var zoneCacheX ipv6ZoneCache

// update refreshes the network interface information if the cache was last
// updated more than 1 minute ago, or if force is set. It reports whether the
// cache was updated.
Expand Down

0 comments on commit 5a20851

Please sign in to comment.