diff --git a/go.mod b/go.mod index 8faec60..81ce51f 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/edwarnicke/grpcfd v1.1.2 github.com/kelseyhightower/envconfig v1.4.0 github.com/networkservicemesh/api v1.12.1-rc.1.0.20240301085602-d5e1eb84eeb4 - github.com/networkservicemesh/sdk v0.5.1-0.20240212105149-b1a3e26da857 + github.com/networkservicemesh/sdk v0.5.1-0.20240319090455-a9e38d90df62 github.com/networkservicemesh/sdk-vpp v0.0.0-20240315112915-61dd50668ab8 github.com/networkservicemesh/vpphelper v0.0.0-20240115135903-e2b961f768b6 github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index 168bdc6..c212e7b 100644 --- a/go.sum +++ b/go.sum @@ -131,8 +131,8 @@ github.com/networkservicemesh/api v1.12.1-rc.1.0.20240301085602-d5e1eb84eeb4 h1: github.com/networkservicemesh/api v1.12.1-rc.1.0.20240301085602-d5e1eb84eeb4/go.mod h1:E2yBac48+mMkMh6ODnsNyah4EE6rI08SMR9n+86Emxs= github.com/networkservicemesh/govpp v0.0.0-20240312165607-3c0a753ca3bf h1:K5lgSmjP5pjszXRP224r3Z1/Z791HY+fvZM7u4zAaSw= github.com/networkservicemesh/govpp v0.0.0-20240312165607-3c0a753ca3bf/go.mod h1:CwikXQ3p/y3j6+HbQQWXKv0f4LPyUd2vKTiViG93qWA= -github.com/networkservicemesh/sdk v0.5.1-0.20240212105149-b1a3e26da857 h1:5Yn1mbXvveGjAi4YAUZsxvpy9+4clcVRKXLEga30+RY= -github.com/networkservicemesh/sdk v0.5.1-0.20240212105149-b1a3e26da857/go.mod h1:rw2ug2AngItEh13ectyCGrxRhGTt/yvJt2SrysoU/Dc= +github.com/networkservicemesh/sdk v0.5.1-0.20240319090455-a9e38d90df62 h1:jdPqrC8tAmggVkqRTwV5IQTL/2MjNEi+jYznlyUwOoY= +github.com/networkservicemesh/sdk v0.5.1-0.20240319090455-a9e38d90df62/go.mod h1:rw2ug2AngItEh13ectyCGrxRhGTt/yvJt2SrysoU/Dc= github.com/networkservicemesh/sdk-kernel v0.0.0-20240212105448-f9f740175836 h1:izzgZmyDcgEElhNv4DbsKWoZ6mazueIlqLOvULq+t4k= github.com/networkservicemesh/sdk-kernel v0.0.0-20240212105448-f9f740175836/go.mod h1:xvmFv1R0zlB1pNtjWCiw0y7df+/XITxtSGDhQj7jAEs= github.com/networkservicemesh/sdk-vpp v0.0.0-20240315112915-61dd50668ab8 h1:L0k/g+dLhXOqy1qS3AqQhBt0bJdoTrWF7prmRvFjuz8= diff --git a/internal/imports/imports_linux.go b/internal/imports/imports_linux.go index 514c2e4..82b936e 100644 --- a/internal/imports/imports_linux.go +++ b/internal/imports/imports_linux.go @@ -21,6 +21,7 @@ import ( _ "github.com/networkservicemesh/sdk-vpp/pkg/networkservice/tag" _ "github.com/networkservicemesh/sdk-vpp/pkg/networkservice/up" _ "github.com/networkservicemesh/sdk-vpp/pkg/networkservice/vrf" + _ "github.com/networkservicemesh/sdk/pkg/ipam/strictvl3ipam" _ "github.com/networkservicemesh/sdk/pkg/networkservice/chains/client" _ "github.com/networkservicemesh/sdk/pkg/networkservice/chains/endpoint" _ "github.com/networkservicemesh/sdk/pkg/networkservice/common/authorize" diff --git a/main.go b/main.go index 079038d..39c950c 100644 --- a/main.go +++ b/main.go @@ -41,6 +41,7 @@ import ( "github.com/networkservicemesh/sdk-vpp/pkg/networkservice/mechanisms/memif" "github.com/networkservicemesh/sdk-vpp/pkg/networkservice/up" "github.com/networkservicemesh/sdk-vpp/pkg/networkservice/vrf" + "github.com/networkservicemesh/sdk/pkg/ipam/strictvl3ipam" "github.com/networkservicemesh/sdk/pkg/networkservice/chains/client" "github.com/networkservicemesh/sdk/pkg/networkservice/common/clientinfo" "github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/recvfd" @@ -514,6 +515,14 @@ func createVl3Client(ctx context.Context, config *Config, vppConn vpphelper.Conn ), ), ) + + var clientIpam vl3.IPAM + go func() { + for prefix := range prefixCh { + clientIpam.Reset(ctx, prefix.Prefix, prefix.ExcludePrefixes) + } + }() + c := client.NewClient( ctx, client.WithClientURL(&config.ConnectTo), @@ -521,7 +530,7 @@ func createVl3Client(ctx context.Context, config *Config, vppConn vpphelper.Conn client.WithAdditionalFunctionality( append( clientAdditionalFunctionality, - vl3.NewClient(ctx, prefixCh), + vl3.NewClient(ctx, &clientIpam), vl3dns.NewClient(config.dnsServerAddr, &config.dnsConfigs), up.NewClient(ctx, vppConn, up.WithLoadSwIfIndex(loopback.Load)), ipaddress.NewClient(vppConn, ipaddress.WithLoadSwIfIndex(loopback.Load)), @@ -546,6 +555,13 @@ func createVl3Client(ctx context.Context, config *Config, vppConn vpphelper.Conn func createVl3Endpoint(ctx context.Context, cancel context.CancelFunc, config *Config, vppConn vpphelper.Connection, tlsServerConfig *tls.Config, source x509svid.Source, loopOpts []loopback.Option, vrfOpts []vrf.Option, prefixCh <-chan *ipam.PrefixResponse) *grpc.Server { + var serverIpam vl3.IPAM + go func() { + for prefix := range prefixCh { + serverIpam.Reset(ctx, prefix.Prefix, prefix.ExcludePrefixes) + } + }() + vl3Endpoint := endpoint.NewServer(ctx, spiffejwt.TokenGeneratorFunc(source, config.MaxTokenLifetime), endpoint.WithName(config.Name), @@ -558,7 +574,7 @@ func createVl3Endpoint(ctx context.Context, cancel context.CancelFunc, config *C vl3dns.WithConfigs(&config.dnsConfigs), ), vl3mtu.NewServer(), - vl3.NewServer(ctx, prefixCh), + strictvl3ipam.NewServer(ctx, vl3.NewServer, &serverIpam), up.NewServer(ctx, vppConn, up.WithLoadSwIfIndex(loopback.Load)), ipaddress.NewServer(vppConn, ipaddress.WithLoadSwIfIndex(loopback.Load)), unnumbered.NewServer(vppConn, loopback.Load),