[management] update reserved IP exclusion when generating peer IP (#8144)

This commit is contained in:
Pascal Fischer
2026-10-12 13:14:19 +02:00
committed by GitHub
parent cd22a9d4f1
commit 7006113897
6 changed files with 144 additions and 34 deletions
@@ -152,7 +152,7 @@ func calculateMaxHosts(prefix netip.Prefix) int64 {
maxHosts := int64(1) << hostBits
if prefix.Addr().Is4() {
maxHosts -= 2 // network and broadcast addresses
maxHosts -= 3 // network, client DNS resolver and broadcast addresses
}
return maxHosts
@@ -12,9 +12,9 @@ import (
"testing"
"time"
"go.uber.org/mock/gomock"
"github.com/gorilla/mux"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
nbcontext "github.com/netbirdio/netbird/management/server/context"
"github.com/netbirdio/netbird/management/server/mock_server"
@@ -469,9 +469,9 @@ func TestCalculateMaxHosts(t *testing.T) {
prefix string
min int64
}{
{"v4 /24", "100.64.0.0/24", 254},
{"v4 /16", "100.64.0.0/16", 65534},
{"v4 /28", "100.64.0.0/28", 14},
{"v4 /24", "100.64.0.0/24", 253},
{"v4 /16", "100.64.0.0/16", 65533},
{"v4 /28", "100.64.0.0/28", 13},
{"v6 /64", "fd00::/64", math.MaxInt64},
{"v6 /120", "fd00::/120", 256},
{"v6 /112", "fd00::/112", 65536},