diff --git a/hscontrol/mapper/mapper_test.go b/hscontrol/mapper/mapper_test.go index 0fc797a7..e8bb5398 100644 --- a/hscontrol/mapper/mapper_test.go +++ b/hscontrol/mapper/mapper_test.go @@ -169,6 +169,9 @@ func Test_fullMapResponse(t *testing.T) { tsaddr.AllIPv4(), netip.MustParsePrefix("192.168.0.0/24"), }, + PrimaryRoutes: []netip.Prefix{ + netip.MustParsePrefix("192.168.0.0/24"), + }, HomeDERP: 0, LegacyDERPString: "127.3.3.40:0", Hostinfo: hiview(tailcfg.Hostinfo{ diff --git a/hscontrol/mapper/tail_test.go b/hscontrol/mapper/tail_test.go index 919ea43c..fa6925a3 100644 --- a/hscontrol/mapper/tail_test.go +++ b/hscontrol/mapper/tail_test.go @@ -67,8 +67,6 @@ func TestTailNode(t *testing.T) { want: &tailcfg.Node{ Name: "empty", StableID: "0", - Addresses: []netip.Prefix{}, - AllowedIPs: []netip.Prefix{}, HomeDERP: 0, LegacyDERPString: "127.3.3.40:0", Hostinfo: hiview(tailcfg.Hostinfo{}), @@ -143,6 +141,9 @@ func TestTailNode(t *testing.T) { tsaddr.AllIPv4(), netip.MustParsePrefix("192.168.0.0/24"), }, + PrimaryRoutes: []netip.Prefix{ + netip.MustParsePrefix("192.168.0.0/24"), + }, HomeDERP: 0, LegacyDERPString: "127.3.3.40:0", Hostinfo: hiview(tailcfg.Hostinfo{ @@ -156,10 +157,6 @@ func TestTailNode(t *testing.T) { Tags: []string{}, - PrimaryRoutes: []netip.Prefix{ - netip.MustParsePrefix("192.168.0.0/24"), - }, - LastSeen: &lastSeen, MachineAuthorized: true, diff --git a/hscontrol/routes/primary.go b/hscontrol/routes/primary.go index 1045b129..869332ab 100644 --- a/hscontrol/routes/primary.go +++ b/hscontrol/routes/primary.go @@ -11,6 +11,7 @@ import ( "github.com/juanfont/headscale/hscontrol/types" "github.com/juanfont/headscale/hscontrol/util" xmaps "golang.org/x/exp/maps" + "tailscale.com/net/tsaddr" "tailscale.com/util/set" ) @@ -152,6 +153,7 @@ func (pr *PrimaryRoutes) PrimaryRoutes(id types.NodeID) []netip.Prefix { } } + tsaddr.SortPrefixes(routes) return routes } diff --git a/integration/route_test.go b/integration/route_test.go index 54d9aab7..aba8df96 100644 --- a/integration/route_test.go +++ b/integration/route_test.go @@ -222,7 +222,7 @@ func TestHASubnetRouterFailover(t *testing.T) { scenario, err := NewScenario(spec) require.NoErrorf(t, err, "failed to create scenario: %s", err) - // defer scenario.ShutdownAssertNoPanics(t) + defer scenario.ShutdownAssertNoPanics(t) err = scenario.CreateHeadscaleEnv( []tsic.Option{tsic.WithAcceptRoutes()},