mirror of
https://github.com/netbirdio/go-netroute.git
synced 2026-05-22 17:11:07 -07:00
Check for cloned routes only on MacOS
BSD doesn't have support for cloned flags
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
//go:build dragonfly || freebsd || netbsd || openbsd
|
||||
|
||||
package netroute
|
||||
|
||||
func skipCloned(_ int, _ *rtInfo) bool {
|
||||
return false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package netroute
|
||||
|
||||
import "syscall"
|
||||
|
||||
func skipCloned(flags int, routeInfo *rtInfo) bool {
|
||||
return flags&syscall.RTF_CLONING != 0 && routeInfo.Dst.String() == "0.0.0.0/0" && routeInfo.Gateway == nil
|
||||
}
|
||||
+1
-1
@@ -115,7 +115,7 @@ func New() (routing.Router, error) {
|
||||
routeInfo.OutputIface = uint32(m.Index)
|
||||
|
||||
// skipping cloned default routes without gateway to avoid choosing a invalid default route
|
||||
if m.Flags&syscall.RTF_CLONING != 0 && routeInfo.Dst.String() == "0.0.0.0/0" && routeInfo.Gateway == nil {
|
||||
if skipCloned(m.Flags, routeInfo) {
|
||||
log.Tracef("skipping cloned default route without gateway: src: %s, dst: %s, interface idx: %d", routeInfo.Src, routeInfo.Dst, routeInfo.OutputIface)
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user