From ee291fd8995b3d0d4bbe2c6e65427873d99eba42 Mon Sep 17 00:00:00 2001 From: Periyasamy Palanisamy Date: Mon, 2 Aug 2021 14:26:02 +0200 Subject: [PATCH] align chain elements Signed-off-by: Periyasamy Palanisamy --- go.mod | 4 +- go.sum | 9 ++-- .../chains/xconnectns/server.go | 49 +++++++++++-------- pkg/networkservice/mechanisms/vxlan/client.go | 4 +- 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/go.mod b/go.mod index 5ce0713..4598255 100644 --- a/go.mod +++ b/go.mod @@ -7,8 +7,8 @@ require ( github.com/golang/protobuf v1.4.3 github.com/networkservicemesh/api v1.0.1-0.20210715134717-6e4a0f8eae3e github.com/networkservicemesh/sdk v0.5.1-0.20210725184904-92b282404ca1 - github.com/networkservicemesh/sdk-kernel v0.0.0-20210727122423-52b6ec54ac4f - github.com/networkservicemesh/sdk-sriov v0.0.0-20210729153428-9d7b7ece0db0 + github.com/networkservicemesh/sdk-kernel v0.0.0-20210802032320-0b6bf83339f7 + github.com/networkservicemesh/sdk-sriov v0.0.0-20210802032626-e07974262d2a github.com/ovn-org/ovn-kubernetes/go-controller v0.0.0-20210526211758-faa6b74b102b github.com/pkg/errors v0.9.1 github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852 diff --git a/go.sum b/go.sum index 8d7fe17..6584ce7 100644 --- a/go.sum +++ b/go.sum @@ -410,11 +410,10 @@ github.com/networkservicemesh/api v1.0.1-0.20210715134717-6e4a0f8eae3e h1:cCRjV+ github.com/networkservicemesh/api v1.0.1-0.20210715134717-6e4a0f8eae3e/go.mod h1:B6meq/SWjWR6bGXZdXPfbOeaBK+T1JayLdtEJQCsXKU= github.com/networkservicemesh/sdk v0.5.1-0.20210725184904-92b282404ca1 h1:yu7Xnu+KwQasCw3Vt7siN2e8Nr2gSjwicDj14Ug7/iU= github.com/networkservicemesh/sdk v0.5.1-0.20210725184904-92b282404ca1/go.mod h1:7whufn2CIGBX+KW3U5b0IWB6f7bJJizY1vV1a5t2HXI= -github.com/networkservicemesh/sdk-kernel v0.0.0-20210725185450-edd90899d7be/go.mod h1:keuHPx4uM38mogyvKx22q3D6Pb2yYSnjazD+wAHVoh8= -github.com/networkservicemesh/sdk-kernel v0.0.0-20210727122423-52b6ec54ac4f h1:W6lWglf4oE/X0KI1jD2TxqFPOK+8pnQP+Pr9xBFBpNg= -github.com/networkservicemesh/sdk-kernel v0.0.0-20210727122423-52b6ec54ac4f/go.mod h1:keuHPx4uM38mogyvKx22q3D6Pb2yYSnjazD+wAHVoh8= -github.com/networkservicemesh/sdk-sriov v0.0.0-20210729153428-9d7b7ece0db0 h1:0pI9RJOm1COqzzRnzIsITyv9hZDlI4W4XutbdusHtGM= -github.com/networkservicemesh/sdk-sriov v0.0.0-20210729153428-9d7b7ece0db0/go.mod h1:raou4nyaHdmQ4psqB/7aXH6yBlwM1BQmCxUMBIMnYDg= +github.com/networkservicemesh/sdk-kernel v0.0.0-20210802032320-0b6bf83339f7 h1:c67BY7rI//jcpFku3p4Oo3kvDoR3ONPpF7L+LJlSnUw= +github.com/networkservicemesh/sdk-kernel v0.0.0-20210802032320-0b6bf83339f7/go.mod h1:keuHPx4uM38mogyvKx22q3D6Pb2yYSnjazD+wAHVoh8= +github.com/networkservicemesh/sdk-sriov v0.0.0-20210802032626-e07974262d2a h1:gSHuyBIZ1fSflAg5UJh26LxbXxuVxtyMJ8FWirwib84= +github.com/networkservicemesh/sdk-sriov v0.0.0-20210802032626-e07974262d2a/go.mod h1:GWk2QcPcV6NeGXLaZjwm37331pxPeikmThHmO33I8iE= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= diff --git a/pkg/networkservice/chains/xconnectns/server.go b/pkg/networkservice/chains/xconnectns/server.go index abdaf13..cc94bb3 100644 --- a/pkg/networkservice/chains/xconnectns/server.go +++ b/pkg/networkservice/chains/xconnectns/server.go @@ -40,12 +40,15 @@ import ( "github.com/networkservicemesh/sdk/pkg/networkservice/chains/endpoint" "github.com/networkservicemesh/sdk/pkg/networkservice/common/clienturl" "github.com/networkservicemesh/sdk/pkg/networkservice/common/connect" + "github.com/networkservicemesh/sdk/pkg/networkservice/common/heal" "github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms" "github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/recvfd" "github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/sendfd" "github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanismtranslation" + "github.com/networkservicemesh/sdk/pkg/networkservice/core/adapters" "github.com/networkservicemesh/sdk/pkg/networkservice/core/chain" "github.com/networkservicemesh/sdk/pkg/networkservice/utils/metadata" + "github.com/networkservicemesh/sdk/pkg/tools/addressof" "github.com/networkservicemesh/sdk/pkg/tools/token" "google.golang.org/grpc" @@ -76,9 +79,20 @@ func NewSriovServer(ctx context.Context, name string, authzServer networkservice additionalFunctionality := []networkservice.NetworkServiceServer{ metadata.NewServer(), recvfd.NewServer(), + sendfd.NewServer(), vfconfig.NewServer(), // Statically set the url we use to the unix file socket for the NSMgr clienturl.NewServer(clientURL), + mechanisms.NewServer(map[string]networkservice.NetworkServiceServer{ + kernelmech.MECHANISM: chain.NewNetworkServiceServer( + kernel.NewServer(bridgeName), + resourcepool.NewServer(sriov.KernelDriver, resourceLock, pciPool, resourcePool, sriovConfig), + rename.NewServer(), + ), + vxlanmech.MECHANISM: vxlan.NewServer(tunnelIP, bridgeName, vxlanInterfacesMutex, vxlanInterfaces), + }), + inject.NewServer(), + connectioncontextkernel.NewServer(), connect.NewServer(ctx, client.NewClientFactory( client.WithName(name), @@ -86,6 +100,7 @@ func NewSriovServer(ctx context.Context, name string, authzServer networkservice mechanismtranslation.NewClient(), connectioncontextkernel.NewClient(), inject.NewClient(), + rename.NewClient(), // mechanisms kernel.NewClient(bridgeName), resourcepool.NewClient(sriov.KernelDriver, resourceLock, pciPool, resourcePool, sriovConfig), @@ -98,18 +113,7 @@ func NewSriovServer(ctx context.Context, name string, authzServer networkservice ), connect.WithDialOptions(clientDialOptions...), ), - mechanisms.NewServer(map[string]networkservice.NetworkServiceServer{ - kernelmech.MECHANISM: chain.NewNetworkServiceServer( - kernel.NewServer(bridgeName), - resourcepool.NewServer(sriov.KernelDriver, resourceLock, pciPool, resourcePool, sriovConfig), - rename.NewServer(), - ), - vxlanmech.MECHANISM: vxlan.NewServer(tunnelIP, bridgeName, vxlanInterfacesMutex, vxlanInterfaces), - }), - inject.NewServer(), - connectioncontextkernel.NewServer(), l2ovsconnect.NewServer(bridgeName), - sendfd.NewServer(), } rv.Endpoint = endpoint.NewServer(ctx, tokenGenerator, @@ -135,8 +139,21 @@ func NewKernelServer(ctx context.Context, name string, authzServer networkservic additionalFunctionality := []networkservice.NetworkServiceServer{ metadata.NewServer(), recvfd.NewServer(), + sendfd.NewServer(), // Statically set the url we use to the unix file socket for the NSMgr clienturl.NewServer(clientURL), + heal.NewServer(ctx, + heal.WithOnHeal(addressof.NetworkServiceClient(adapters.NewServerToClient(rv))), + heal.WithOnRestore(heal.OnRestoreIgnore)), + mechanisms.NewServer(map[string]networkservice.NetworkServiceServer{ + kernelmech.MECHANISM: chain.NewNetworkServiceServer( + kernel.NewServer(bridgeName), + rename.NewServer(), + ), + vxlanmech.MECHANISM: vxlan.NewServer(tunnelIP, bridgeName, vxlanInterfacesMutex, vxlanInterfaces), + }), + inject.NewServer(), + connectioncontextkernel.NewServer(), connect.NewServer(ctx, client.NewClientFactory( client.WithName(name), @@ -153,17 +170,7 @@ func NewKernelServer(ctx context.Context, name string, authzServer networkservic ), connect.WithDialOptions(clientDialOptions...), ), - mechanisms.NewServer(map[string]networkservice.NetworkServiceServer{ - kernelmech.MECHANISM: chain.NewNetworkServiceServer( - kernel.NewServer(bridgeName), - rename.NewServer(), - ), - vxlanmech.MECHANISM: vxlan.NewServer(tunnelIP, bridgeName, vxlanInterfacesMutex, vxlanInterfaces), - }), - inject.NewServer(), - connectioncontextkernel.NewServer(), l2ovsconnect.NewServer(bridgeName), - sendfd.NewServer(), } rv.Endpoint = endpoint.NewServer(ctx, tokenGenerator, diff --git a/pkg/networkservice/mechanisms/vxlan/client.go b/pkg/networkservice/mechanisms/vxlan/client.go index c8a1063..5582b35 100644 --- a/pkg/networkservice/mechanisms/vxlan/client.go +++ b/pkg/networkservice/mechanisms/vxlan/client.go @@ -59,8 +59,8 @@ func (c *vxlanClient) Request(ctx context.Context, request *networkservice.Netwo if err != nil { return nil, err } - if err = add(ctx, logger, request.Connection, c.bridgeName, c.vxlanInterfacesMutex, c.vxlanInterfacesMap, true); err != nil { - _ = remove(request.Connection, c.bridgeName, c.vxlanInterfacesMutex, c.vxlanInterfacesMap, true) + if err = add(ctx, logger, conn, c.bridgeName, c.vxlanInterfacesMutex, c.vxlanInterfacesMap, true); err != nil { + _ = remove(conn, c.bridgeName, c.vxlanInterfacesMutex, c.vxlanInterfacesMap, true) if _, closeErr := next.Client(ctx).Close(ctx, conn, opts...); closeErr != nil { logger.Errorf("failed to close failed connection: %s %s", conn.GetId(), closeErr.Error()) }