Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ COPY . .
RUN go build -o /bin/forwarder .

FROM build as test
CMD go test -test.v ./...
RUN apt-get update -y
RUN apt-get install -y iperf3
CMD go test -test.v ./... -bench=. -timeout 1h

FROM test as debug
WORKDIR /build/internal/tests/
Expand Down
6 changes: 5 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ require (
github.com/edwarnicke/grpcfd v0.1.0
github.com/edwarnicke/vpphelper v0.0.0-20210512223648-f914b171f679
github.com/golang/protobuf v1.4.3
github.com/google/uuid v1.1.2
github.com/kelseyhightower/envconfig v1.4.0
github.com/networkservicemesh/api v1.0.1-0.20210715134717-6e4a0f8eae3e
github.com/networkservicemesh/api v1.0.1-0.20210811070028-10403c0f20c8
github.com/networkservicemesh/sdk v0.5.1-0.20210811141837-74e4c2082439
github.com/networkservicemesh/sdk-kernel v0.0.0-20210811142215-bb74f8a3fbf2
github.com/networkservicemesh/sdk-vpp v0.0.0-20210811142610-6e7f2309d90c
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.7.0
Expand All @@ -24,3 +26,5 @@ require (
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae
google.golang.org/grpc v1.35.0
)

replace github.com/networkservicemesh/sdk-vpp => github.com/Mixaster995/sdk-vpp v0.0.0-20210811105653-31419cc454c9
9 changes: 6 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/HdrHistogram/hdrhistogram-go v1.0.1 h1:GX8GAYDuhlFQnI2fRDHQhTlkHMz8bEn0jTI6LJU0mpw=
github.com/HdrHistogram/hdrhistogram-go v1.0.1/go.mod h1:BWJ+nMSHY3L41Zj7CA3uXnloDp7xxV0YvstAE7nKTaM=
github.com/Mixaster995/sdk-vpp v0.0.0-20210811105653-31419cc454c9 h1:rjsdrCuMrIFgAgKoqBLwxzV57Aocfp8fTTKdmTKxAi8=
github.com/Mixaster995/sdk-vpp v0.0.0-20210811105653-31419cc454c9/go.mod h1:bIRy8a8ELFstX+/SotbrHKGwYcBrstDPc1r1Ga+19yg=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/OneOfOne/xxhash v1.2.3 h1:wS8NNaIgtzapuArKIAjsyXtEN/IUjQkbw90xszUdS40=
github.com/OneOfOne/xxhash v1.2.3/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
Expand Down Expand Up @@ -148,14 +150,15 @@ github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxzi
github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/nats-io/stan.go v0.6.0/go.mod h1:eIcD5bi3pqbHT/xIIvXMwvzXYElgouBvaVRftaE+eac=
github.com/networkservicemesh/api v1.0.1-0.20210715134717-6e4a0f8eae3e h1:cCRjV+1sOuOrCF/0IPXH2PJ1y7hEbuqX9k+OFnU7xhU=
github.com/networkservicemesh/api v1.0.1-0.20210715134717-6e4a0f8eae3e/go.mod h1:B6meq/SWjWR6bGXZdXPfbOeaBK+T1JayLdtEJQCsXKU=
github.com/networkservicemesh/api v1.0.1-0.20210811070028-10403c0f20c8 h1:kr2/dA/ktBgnChorXBwjn7fdpRKB+eJI2xCPNCGt3ws=
github.com/networkservicemesh/api v1.0.1-0.20210811070028-10403c0f20c8/go.mod h1:B6meq/SWjWR6bGXZdXPfbOeaBK+T1JayLdtEJQCsXKU=
github.com/networkservicemesh/sdk v0.5.1-0.20210811063905-15a33a429304/go.mod h1:7whufn2CIGBX+KW3U5b0IWB6f7bJJizY1vV1a5t2HXI=
github.com/networkservicemesh/sdk v0.5.1-0.20210811141837-74e4c2082439 h1:R8vF2CXIxEOnM1hTJP6ojKINImlaPfbnnRWBHAW3pv4=
github.com/networkservicemesh/sdk v0.5.1-0.20210811141837-74e4c2082439/go.mod h1:7whufn2CIGBX+KW3U5b0IWB6f7bJJizY1vV1a5t2HXI=
github.com/networkservicemesh/sdk-kernel v0.0.0-20210811064243-0548354e4811/go.mod h1:I/gLTrgmGShoKlObcvHpQ9J7fCjsPL8BIvfWkjaqk6g=
github.com/networkservicemesh/sdk-kernel v0.0.0-20210811142215-bb74f8a3fbf2 h1:MqmgdCjg63qufAAC7xYAqHvc0q0YmcgelCYss/Sgcp8=
github.com/networkservicemesh/sdk-kernel v0.0.0-20210811142215-bb74f8a3fbf2/go.mod h1:bov0+o/EGA/vPGiJ2jMqIkWJjHzTS4HZVOgE0n4CW0o=
github.com/networkservicemesh/sdk-vpp v0.0.0-20210811142610-6e7f2309d90c h1:ZSqJ1e+jyjk0jUPRLPhdjG6Ja2iJQA6b8HOXkyEnrss=
github.com/networkservicemesh/sdk-vpp v0.0.0-20210811142610-6e7f2309d90c/go.mod h1:yn8t+nidQq9Y0zRwp/LoMNcqkI0py/Hh4lEpdO3Z+KE=
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/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
Expand Down
18 changes: 18 additions & 0 deletions internal/imports/imports_linux.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions internal/tests/copyfile/server.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright (c) 2020 Doc.ai and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Package copyfile provides the necessary mechanisms to request and inject a kernel interface.
package copyfile

import (
"context"
"github.com/golang/protobuf/ptypes/empty"
"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/kernel"
"github.com/networkservicemesh/sdk/pkg/networkservice/core/next"
"net/url"
)

type copyFileServer struct{
name string
}

// NewServer - creates a NetworkServiceServer that requests a kernel interface and populates the netns inode
func NewServer(name string) networkservice.NetworkServiceServer {
return &copyFileServer{
name: name,
}
}

func (m *copyFileServer) Request(ctx context.Context, request *networkservice.NetworkServiceRequest) (*networkservice.Connection, error) {
if mechanism := kernel.ToMechanism(request.GetConnection().GetMechanism()); mechanism != nil {
//nsHandle, err := mechutils.ToNSHandle(mechanism)
//fd, err := syscall.Open("/run/netns/" + m.name, unix.O_RDONLY|unix.O_CLOEXEC, 0)
//if err != nil {
// return nil, err
//}
//filename := fmt.Sprintf("/proc/%d/fd/%d", os.Getpid(), fd)
mechanism.SetNetNSURL((&url.URL{Scheme: "file", Path: "/run/netns/" + m.name}).String())
}
return next.Server(ctx).Request(ctx, request)
}

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

Loading