diff --git a/go.mod b/go.mod index ceee902..faa0c70 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.6.2-0.20221205183940-84c7ff837cdd - github.com/networkservicemesh/sdk v0.5.1-0.20221219152652-beec79b7ec9d + github.com/networkservicemesh/sdk v0.5.1-0.20230109230417-1492e69a650d github.com/networkservicemesh/sdk-sriov v0.0.0-20221219180322-513bee7f52b7 github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.9.0 diff --git a/go.sum b/go.sum index f70e479..1461d71 100644 --- a/go.sum +++ b/go.sum @@ -196,8 +196,8 @@ github.com/miekg/dns v1.1.50 h1:DQUfb9uc6smULcREF09Uc+/Gd46YWqJd5DbpPE9xkcA= github.com/miekg/dns v1.1.50/go.mod h1:e3IlAVfNqAllflbibAZEWOXOQ+Ynzk/dDozDxY7XnME= github.com/networkservicemesh/api v1.6.2-0.20221205183940-84c7ff837cdd h1:26HR90HrJFZHIPPP3SCLGNRpPCMFoEnSSZfhHH8MPSo= github.com/networkservicemesh/api v1.6.2-0.20221205183940-84c7ff837cdd/go.mod h1:hOF2844BSstH1311oDMDgqqXS+kdc77htZNPRKl9mf8= -github.com/networkservicemesh/sdk v0.5.1-0.20221219152652-beec79b7ec9d h1:cx0Z/xWuoW0JS3VmA+5Ckg5g+iirB7RJglGDnJzmGEo= -github.com/networkservicemesh/sdk v0.5.1-0.20221219152652-beec79b7ec9d/go.mod h1:++MSpR2wuFlCpCYoR6lELxJ4ILKd650vDQ8d9CtGAzA= +github.com/networkservicemesh/sdk v0.5.1-0.20230109230417-1492e69a650d h1:1EhczRkzfkutymvDj5XYinD68omLpFk2F2kJdhzYG+U= +github.com/networkservicemesh/sdk v0.5.1-0.20230109230417-1492e69a650d/go.mod h1:++MSpR2wuFlCpCYoR6lELxJ4ILKd650vDQ8d9CtGAzA= github.com/networkservicemesh/sdk-sriov v0.0.0-20221219180322-513bee7f52b7 h1:warFgkj/xEmiV/KK33MQzOY/D54KHP4duCn+dSQf+0I= github.com/networkservicemesh/sdk-sriov v0.0.0-20221219180322-513bee7f52b7/go.mod h1:uClz/S+Ty0doAV+ZKL+gg0PBkY9F6vyelPG40K4VVxw= github.com/open-policy-agent/opa v0.44.0 h1:sEZthsrWBqIN+ShTMJ0Hcz6a3GkYsY4FaB2S/ou2hZk= diff --git a/internal/pkg/imports/imports_linux.go b/internal/pkg/imports/imports_linux.go index 3458031..b59b4b5 100644 --- a/internal/pkg/imports/imports_linux.go +++ b/internal/pkg/imports/imports_linux.go @@ -25,8 +25,7 @@ import ( _ "github.com/networkservicemesh/sdk/pkg/networkservice/common/onidle" _ "github.com/networkservicemesh/sdk/pkg/networkservice/common/policyroute" _ "github.com/networkservicemesh/sdk/pkg/networkservice/connectioncontext/dnscontext" - _ "github.com/networkservicemesh/sdk/pkg/networkservice/core/chain" - _ "github.com/networkservicemesh/sdk/pkg/networkservice/ipam/point2pointipam" + _ "github.com/networkservicemesh/sdk/pkg/networkservice/ipam/groupipam" _ "github.com/networkservicemesh/sdk/pkg/registry/chains/client" _ "github.com/networkservicemesh/sdk/pkg/registry/common/authorize" _ "github.com/networkservicemesh/sdk/pkg/registry/common/begin" @@ -65,7 +64,6 @@ import ( _ "google.golang.org/grpc/credentials" _ "google.golang.org/grpc/health/grpc_health_v1" _ "gopkg.in/yaml.v2" - _ "net" _ "net/url" _ "os" _ "os/signal" diff --git a/main.go b/main.go index 525f469..8577b92 100644 --- a/main.go +++ b/main.go @@ -1,5 +1,5 @@ -// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. -// Copyright (c) 2021-2022 Nordix and/or its affiliates. +// Copyright (c) 2020-2023 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2023 Nordix and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -24,7 +24,6 @@ import ( "context" "crypto/tls" "fmt" - "net" "net/url" "os" "os/signal" @@ -61,8 +60,7 @@ import ( "github.com/networkservicemesh/sdk/pkg/networkservice/common/onidle" "github.com/networkservicemesh/sdk/pkg/networkservice/common/policyroute" "github.com/networkservicemesh/sdk/pkg/networkservice/connectioncontext/dnscontext" - "github.com/networkservicemesh/sdk/pkg/networkservice/core/chain" - "github.com/networkservicemesh/sdk/pkg/networkservice/ipam/point2pointipam" + "github.com/networkservicemesh/sdk/pkg/networkservice/ipam/groupipam" registryclient "github.com/networkservicemesh/sdk/pkg/registry/chains/client" registryauthorize "github.com/networkservicemesh/sdk/pkg/registry/common/authorize" "github.com/networkservicemesh/sdk/pkg/registry/common/clientinfo" @@ -140,10 +138,9 @@ func main() { log.FromContext(ctx).Infof("the phases include:") log.FromContext(ctx).Infof("1: get config from environment") log.FromContext(ctx).Infof("2: retrieve spiffe svid") - log.FromContext(ctx).Infof("3: create icmp server ipam") - log.FromContext(ctx).Infof("4: create icmp server nse") - log.FromContext(ctx).Infof("5: create grpc and mount nse") - log.FromContext(ctx).Infof("6: register nse with nsm") + log.FromContext(ctx).Infof("3: create icmp server nse") + log.FromContext(ctx).Infof("4: create grpc and mount nse") + log.FromContext(ctx).Infof("5: register nse with nsm") log.FromContext(ctx).Infof("a final success message with start time duration") starttime := time.Now() @@ -197,15 +194,7 @@ func main() { tlsServerConfig.MinVersion = tls.VersionTLS12 // ******************************************************************************** - log.FromContext(ctx).Infof("executing phase 3: creating icmp server ipam") - // ******************************************************************************** - - ipamChain := getIPAMChain(config.CidrPrefix) - - log.FromContext(ctx).Infof("network prefixes parsed successfully") - - // ******************************************************************************** - log.FromContext(ctx).Infof("executing phase 4: create icmp-server network service endpoint") + log.FromContext(ctx).Infof("executing phase 3: create icmp-server network service endpoint") // ******************************************************************************** tokenServer := getSriovTokenServerChainElement(ctx) @@ -216,7 +205,7 @@ func main() { endpoint.WithAuthorizeServer(authorize.NewServer()), endpoint.WithAdditionalFunctionality( onidle.NewServer(ctx, cancel, config.IdleTimeout), - ipamChain, + groupipam.NewServer(config.CidrPrefix), policyroute.NewServer(newPolicyRoutesGetter(ctx, config.PBRConfigPath).Get), recvfd.NewServer(), mechanisms.NewServer(map[string]networkservice.NetworkServiceServer{ @@ -229,7 +218,7 @@ func main() { ), ) // ******************************************************************************** - log.FromContext(ctx).Infof("executing phase 5: create grpc server and register icmp-server") + log.FromContext(ctx).Infof("executing phase 4: create grpc server and register icmp-server") // ******************************************************************************** options := append( tracing.WithTracing(), @@ -254,7 +243,7 @@ func main() { log.FromContext(ctx).Infof("grpc server started") // ******************************************************************************** - log.FromContext(ctx).Infof("executing phase 6: register nse with nsm") + log.FromContext(ctx).Infof("executing phase 5: register nse with nsm") // ******************************************************************************** clientOptions := append( tracing.WithTracingDial(), @@ -405,11 +394,3 @@ type policyRoutesGetter struct { ctx context.Context policyRoutes atomic.Value } - -func getIPAMChain(cIDRGroups [][]*net.IPNet) networkservice.NetworkServiceServer { - var ipamchain []networkservice.NetworkServiceServer - for _, cidrGroup := range cIDRGroups { - ipamchain = append(ipamchain, point2pointipam.NewServer(cidrGroup...)) - } - return chain.NewNetworkServiceServer(ipamchain...) -} diff --git a/suite_setup_test.go b/suite_setup_test.go index 81af61f..86ff3af 100644 --- a/suite_setup_test.go +++ b/suite_setup_test.go @@ -1,6 +1,6 @@ -// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2023 Doc.ai and/or its affiliates. // -// Copyright (c) 2020-2022 Cisco and/or its affiliates. +// Copyright (c) 2020-2023 Cisco and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -119,7 +119,7 @@ func (f *TestSuite) SetupSuite() { registrybegin.NewNetworkServiceEndpointRegistryServer(), updatepath.NewNetworkServiceEndpointRegistryServer(spiffejwt.TokenGeneratorFunc(source, f.config.MaxTokenLifetime)), authorize.NewNetworkServiceEndpointRegistryServer(), - expire.NewNetworkServiceEndpointRegistryServer(f.ctx, time.Minute), + expire.NewNetworkServiceEndpointRegistryServer(f.ctx, expire.WithDefaultExpiration(time.Minute)), registryrecvfd.NewNetworkServiceEndpointRegistryServer(), memrg, )