Linux legacy routing (#1774)

* Add Linux legacy routing if ip rule functionality is not available

* Ignore exclusion route errors if host has no route

* Exclude iOS from route manager

* Also retrieve IPv6 routes

* Ignore loopback addresses not being in the main table

* Ignore "not supported" errors on cleanup

* Fix regression in ListenUDP not using fwmarks
This commit is contained in:
Viktor Liu
2024-04-03 18:04:22 +02:00
committed by GitHub
parent 7938295190
commit bb0d5c5baf
9 changed files with 656 additions and 569 deletions

View File

@@ -1,8 +1,9 @@
//go:build !android
//go:build !android && !ios
package routemanager
import (
"errors"
"fmt"
"net/netip"
"sync"
@@ -53,6 +54,9 @@ func (rm *RouteManager) AddRouteRef(connID nbnet.ConnectionID, prefix netip.Pref
if ref.count == 0 {
log.Debugf("Adding route for prefix %s", prefix)
nexthop, intf, err := rm.addRoute(prefix)
if errors.Is(err, errRouteNotFound) {
return nil
}
if err != nil {
return fmt.Errorf("failed to add route for prefix %s: %w", prefix, err)
}