From 59bb711ff9edadc37836eb64a5d9843e92b7feed Mon Sep 17 00:00:00 2001 From: NikitaSkrynnik Date: Tue, 19 Mar 2024 17:30:34 +0700 Subject: [PATCH 1/3] use strictvl3ipam chain element Signed-off-by: NikitaSkrynnik --- go.mod | 2 +- go.sum | 2 ++ main.go | 21 +++++++++++++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) 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..9e1318d 100644 --- a/go.sum +++ b/go.sum @@ -133,6 +133,8 @@ github.com/networkservicemesh/govpp v0.0.0-20240312165607-3c0a753ca3bf h1:K5lgSm 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/main.go b/main.go index 079038d..2a7e771 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 ipam vl3.IPAM + go func() { + for prefix := range prefixCh { + ipam.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, &ipam), vl3dns.NewClient(config.dnsServerAddr, &config.dnsConfigs), up.NewClient(ctx, vppConn, up.WithLoadSwIfIndex(loopback.Load)), ipaddress.NewClient(vppConn, ipaddress.WithLoadSwIfIndex(loopback.Load)), @@ -546,6 +555,14 @@ 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 ipam vl3.IPAM + go func() { + for prefix := range prefixCh { + ipam.Reset(ctx, prefix.Prefix, prefix.ExcludePrefixes) + } + }() + vl3Endpoint := endpoint.NewServer(ctx, spiffejwt.TokenGeneratorFunc(source, config.MaxTokenLifetime), endpoint.WithName(config.Name), @@ -558,7 +575,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, &ipam), up.NewServer(ctx, vppConn, up.WithLoadSwIfIndex(loopback.Load)), ipaddress.NewServer(vppConn, ipaddress.WithLoadSwIfIndex(loopback.Load)), unnumbered.NewServer(vppConn, loopback.Load), From 6a0528328ae5bec93d3eec86a7e71e7325be6ed6 Mon Sep 17 00:00:00 2001 From: NikitaSkrynnik Date: Tue, 19 Mar 2024 17:38:43 +0700 Subject: [PATCH 2/3] fix CI Signed-off-by: NikitaSkrynnik --- go.sum | 2 -- internal/imports/imports_linux.go | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/go.sum b/go.sum index 9e1318d..c212e7b 100644 --- a/go.sum +++ b/go.sum @@ -131,8 +131,6 @@ 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= 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" From 73ca401dbd684b099b50c32b19130c0ddeb63876 Mon Sep 17 00:00:00 2001 From: NikitaSkrynnik Date: Tue, 19 Mar 2024 17:43:06 +0700 Subject: [PATCH 3/3] fix go linter issues Signed-off-by: NikitaSkrynnik --- main.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 2a7e771..39c950c 100644 --- a/main.go +++ b/main.go @@ -516,10 +516,10 @@ func createVl3Client(ctx context.Context, config *Config, vppConn vpphelper.Conn ), ) - var ipam vl3.IPAM + var clientIpam vl3.IPAM go func() { for prefix := range prefixCh { - ipam.Reset(ctx, prefix.Prefix, prefix.ExcludePrefixes) + clientIpam.Reset(ctx, prefix.Prefix, prefix.ExcludePrefixes) } }() @@ -530,7 +530,7 @@ func createVl3Client(ctx context.Context, config *Config, vppConn vpphelper.Conn client.WithAdditionalFunctionality( append( clientAdditionalFunctionality, - vl3.NewClient(ctx, &ipam), + 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)), @@ -555,11 +555,10 @@ 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 ipam vl3.IPAM + var serverIpam vl3.IPAM go func() { for prefix := range prefixCh { - ipam.Reset(ctx, prefix.Prefix, prefix.ExcludePrefixes) + serverIpam.Reset(ctx, prefix.Prefix, prefix.ExcludePrefixes) } }() @@ -575,7 +574,7 @@ func createVl3Endpoint(ctx context.Context, cancel context.CancelFunc, config *C vl3dns.WithConfigs(&config.dnsConfigs), ), vl3mtu.NewServer(), - strictvl3ipam.NewServer(ctx, vl3.NewServer, &ipam), + 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),