Skip to content

Commit

Permalink
important fix
Browse files Browse the repository at this point in the history
Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>
  • Loading branch information
NikitaSkrynnik committed Jun 27, 2024
1 parent de32d39 commit e97b5be
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 8 deletions.
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ require (
google.golang.org/protobuf v1.33.0
)

replace github.com/networkservicemesh/sdk => ../sdk

replace github.com/networkservicemesh/sdk-kernel => ../sdk-kernel

require (
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/OneOfOne/xxhash v1.2.8 // indirect
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,6 @@ github.com/networkservicemesh/api v1.13.1-0.20240424210452-d0df98851760 h1:EaWGg
github.com/networkservicemesh/api v1.13.1-0.20240424210452-d0df98851760/go.mod h1:B8FmS3XZ7NZY7ZEtdcNg2NHYppDHlr4kl4eecdZN9eI=
github.com/networkservicemesh/govpp v0.0.0-20240328101142-8a444680fbba h1:7B6X6N7rwJNpnfsUlBavxuZdYqTx8nAKwxVS/AkuX1o=
github.com/networkservicemesh/govpp v0.0.0-20240328101142-8a444680fbba/go.mod h1:CwikXQ3p/y3j6+HbQQWXKv0f4LPyUd2vKTiViG93qWA=
github.com/networkservicemesh/sdk v0.5.1-0.20240604143537-e3eed82dc1b4 h1:6FTn6PPMFCF/awAgvzMJwa+WC6wlbveGvGdGKjRXqoM=
github.com/networkservicemesh/sdk v0.5.1-0.20240604143537-e3eed82dc1b4/go.mod h1:soFR6Mg5LTVvEI0zXNcbWoBnn4hqUK7ItZBQJ3Jbszo=
github.com/networkservicemesh/sdk-kernel v0.0.0-20240604150951-293bea632223 h1:1p0VW8jSSYYLdWpcC29lu7wGBcmZf/s/PlLVJi4oGT8=
github.com/networkservicemesh/sdk-kernel v0.0.0-20240604150951-293bea632223/go.mod h1:106yEon0olXuKYX721JqSQycpiuRMeQ/h4WiID2qIHw=
github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8=
github.com/open-policy-agent/opa v0.44.0 h1:sEZthsrWBqIN+ShTMJ0Hcz6a3GkYsY4FaB2S/ou2hZk=
github.com/open-policy-agent/opa v0.44.0/go.mod h1:YpJaFIk5pq89n/k72c1lVvfvR5uopdJft2tMg1CW/yU=
Expand Down
53 changes: 50 additions & 3 deletions pkg/networkservice/chains/forwarder/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ import (
"sync"
"time"

"github.com/golang/protobuf/ptypes/empty"
"github.com/google/uuid"
"go.fd.io/govpp/api"
"google.golang.org/grpc"

"github.com/networkservicemesh/api/pkg/api/networkservice"
ipsecapi "github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/ipsec"
Expand All @@ -49,6 +51,7 @@ import (
"github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/sendfd"
"github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanismtranslation"
"github.com/networkservicemesh/sdk/pkg/networkservice/common/roundrobin"
"github.com/networkservicemesh/sdk/pkg/networkservice/core/next"
"github.com/networkservicemesh/sdk/pkg/tools/log"
authmonitor "github.com/networkservicemesh/sdk/pkg/tools/monitorconnection/authorize"
"github.com/networkservicemesh/sdk/pkg/tools/token"
Expand All @@ -68,7 +71,6 @@ import (
"github.com/networkservicemesh/sdk-vpp/pkg/networkservice/mechanisms/vlan"
"github.com/networkservicemesh/sdk-vpp/pkg/networkservice/mechanisms/vxlan"
"github.com/networkservicemesh/sdk-vpp/pkg/networkservice/mechanisms/wireguard"
"github.com/networkservicemesh/sdk-vpp/pkg/networkservice/metrics"
"github.com/networkservicemesh/sdk-vpp/pkg/networkservice/nsmonitor"
"github.com/networkservicemesh/sdk-vpp/pkg/networkservice/pinhole"
"github.com/networkservicemesh/sdk-vpp/pkg/networkservice/tag"
Expand All @@ -77,6 +79,51 @@ import (
"github.com/networkservicemesh/sdk-vpp/pkg/networkservice/xconnect/l2bridgedomain"
)

type closeServer struct {
}

// NewServer - returns server chain element to recv FDs over the connection (if possible) for any Mechanism.Parameters[common.InodeURL]
// url of scheme 'inode'.
func NewCloseServer() networkservice.NetworkServiceServer {
return &closeServer{}
}

func (r *closeServer) Request(ctx context.Context, request *networkservice.NetworkServiceRequest) (*networkservice.Connection, error) {
conn, err := next.Server(ctx).Request(ctx, request)
if err != nil || ctx.Err() != nil {
r.Close(context.Background(), request.Connection)
return nil, err
}

return conn, err
}

func (r *closeServer) Close(ctx context.Context, conn *networkservice.Connection) (*empty.Empty, error) {
return next.Server(ctx).Close(ctx, conn)
}

type closeClient struct {
}

// NewClient - returns client chain element to recv FDs over the connection (if possible) for any Mechanism.Parameters[common.InodeURL]
// url of scheme 'inode'.
func NewCloseClient() networkservice.NetworkServiceClient {
return &closeClient{}
}

func (r *closeClient) Request(ctx context.Context, request *networkservice.NetworkServiceRequest, opts ...grpc.CallOption) (*networkservice.Connection, error) {
conn, err := next.Client(ctx).Request(ctx, request, opts...)
if err != nil || ctx.Err() != nil {
r.Close(context.Background(), request.Connection, opts...)
return nil, err
}
return conn, err
}

func (r *closeClient) Close(ctx context.Context, conn *networkservice.Connection, opts ...grpc.CallOption) (*empty.Empty, error) {
return next.Client(ctx).Close(ctx, conn, opts...)
}

type xconnectNSServer struct {
endpoint.Endpoint
}
Expand Down Expand Up @@ -117,9 +164,9 @@ func NewServer(ctx context.Context, tokenGenerator token.GeneratorFunc, vppConn
additionalFunctionality := []networkservice.NetworkServiceServer{
recvfd.NewServer(),
sendfd.NewServer(),
NewCloseServer(),
discover.NewServer(nsClient, nseClient),
roundrobin.NewServer(),
metrics.NewServer(ctx, vppConn, opts.statsOpts...),
up.NewServer(ctx, vppConn),
xconnect.NewServer(vppConn),
l2bridgedomain.NewServer(vppConn),
Expand All @@ -146,10 +193,10 @@ func NewServer(ctx context.Context, tokenGenerator token.GeneratorFunc, vppConn
client.WithDialTimeout(opts.dialTimeout),
client.WithAdditionalFunctionality(
append([]networkservice.NetworkServiceClient{
NewCloseClient(),
cleanup.NewClient(ctx, opts.cleanupOpts...),
mechanismtranslation.NewClient(),
connectioncontextkernel.NewClient(),
metrics.NewClient(ctx, vppConn, opts.statsOpts...),
up.NewClient(ctx, vppConn),
mtu.NewClient(vppConn),
tag.NewClient(ctx, vppConn),
Expand Down
2 changes: 1 addition & 1 deletion pkg/networkservice/mechanisms/kernel/kerneltap/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func del(ctx context.Context, conn *networkservice.Connection, vppConn api.Conne
return nil
}
now := time.Now()
_, err := tapv2.NewServiceClient(vppConn).TapDeleteV2(ctx, &tapv2.TapDeleteV2{
_, err := tapv2.NewServiceClient(vppConn).TapDeleteV2(context.Background(), &tapv2.TapDeleteV2{
SwIfIndex: swIfIndex,
})
if err != nil {
Expand Down

0 comments on commit e97b5be

Please sign in to comment.