mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 21:27:31 +00:00
wgengine/router: start using netlink instead of 'ip' on Linux
Converts up, down, add/del addresses, add/del routes. Not yet done: rules. Updates #391 Change-Id: I02554ca07046d18f838e04a626ba99bbd35266fb Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
7b87c04861
commit
dc2fbf5877
@@ -15,6 +15,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/vishvananda/netlink"
|
||||
"golang.zx2c4.com/wireguard/tun"
|
||||
"inet.af/netaddr"
|
||||
"tailscale.com/tstest"
|
||||
@@ -708,3 +709,27 @@ func TestDelRouteIdempotent(t *testing.T) {
|
||||
t.Logf("Log output:\n%s", out)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDebugListLinks(t *testing.T) {
|
||||
links, err := netlink.LinkList()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, ln := range links {
|
||||
t.Logf("Link: %+v", ln)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDebugListRoutes(t *testing.T) {
|
||||
// We need to pass a non-nil route to RouteListFiltered, along
|
||||
// with the netlink.RT_FILTER_TABLE bit set in the filter
|
||||
// mask, otherwise it ignores non-main routes.
|
||||
filter := &netlink.Route{}
|
||||
routes, err := netlink.RouteListFiltered(netlink.FAMILY_ALL, filter, netlink.RT_FILTER_TABLE)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, r := range routes {
|
||||
t.Logf("Route: %+v", r)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user