diff --git a/go.mod b/go.mod index 2c00b07..4854706 100644 --- a/go.mod +++ b/go.mod @@ -11,4 +11,5 @@ require ( github.com/vishvananda/netlink v1.0.0 github.com/vishvananda/netns v0.0.0-20190625233234-7109fa855b0f // indirect github.com/whyrusleeping/mafmt v1.2.8 + golang.org/x/sys v0.0.0-20190526052359-791d8a0f4d09 ) diff --git a/netlink_linux.go b/netlink_linux.go new file mode 100644 index 0000000..a5f6ffe --- /dev/null +++ b/netlink_linux.go @@ -0,0 +1,10 @@ +// +build linux + +package libp2pquic + +import "golang.org/x/sys/unix" + +// We just need netlink_route here. +// note: We should avoid the use of netlink_xfrm or netlink_netfilter has it is +// not allowed by Android in his base policy. +var SupportedNlFamilies = []int{unix.NETLINK_ROUTE} diff --git a/netlink_other.go b/netlink_other.go new file mode 100644 index 0000000..58ad3ca --- /dev/null +++ b/netlink_other.go @@ -0,0 +1,8 @@ +// +build !linux + +package libp2pquic + +import "github.com/vishvananda/netlink/nl" + +// nl.SupportedNlFamilies is the default netlink families used by the netlink package +var SupportedNlFamilies = nl.SupportedNlFamilies diff --git a/reuse.go b/reuse.go index cb45aa2..c6415b4 100644 --- a/reuse.go +++ b/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 {