Browse Source

fix(android): use specific netlink families for android

Android doesn't allow netlink_xfrm & netlink_nflog in his base policy in enforce
mode. (see [here](3aa1c1725e/public/app.te (396)))
this cause a _permission denied_ when NewTransport method is called on android,
however it's look like that only *netlink route* is needed, so we just have to limit netlink
families support on android build to NETLINK_ROUTE only when netlink.NewHandle is called.
pull/1424/head
Guilhem Fanton 5 years ago
parent
commit
70edc02c26
  1. 8
      p2p/transport/quic/netlink_android.go
  2. 8
      p2p/transport/quic/netlink_other.go
  3. 2
      p2p/transport/quic/reuse.go

8
p2p/transport/quic/netlink_android.go

@ -0,0 +1,8 @@
// +build android
package libp2pquic
import "golang.org/x/sys/unix"
// Android doesn't allow netlink_xfrm and netlink_netfilter in his base policy
var SupportedNlFamilies = []int{unix.NETLINK_ROUTE}

8
p2p/transport/quic/netlink_other.go

@ -0,0 +1,8 @@
// +build !android
package libp2pquic
import "github.com/vishvananda/netlink/nl"
// nl.SupportedNlFamilies is the default netlink families used by the netlink package
var SupportedNlFamilies = nl.SupportedNlFamilies

2
p2p/transport/quic/reuse.go

@ -62,7 +62,7 @@ type reuse struct {
func newReuse() (*reuse, error) {
// On non-Linux systems, this will return ErrNotImplemented.
handle, err := netlink.NewHandle()
handle, err := netlink.NewHandle(SupportedNlFamilies...)
if err == netlink.ErrNotImplemented {
handle = nil
} else if err != nil {

Loading…
Cancel
Save