Skip to content

Commit

Permalink
Update vpphelper manually (#1213)
Browse files Browse the repository at this point in the history
Signed-off-by: NikitaSkrynnik <[email protected]>
  • Loading branch information
NikitaSkrynnik authored Nov 29, 2024
1 parent 3a77aef commit 4d41019
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 33 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ docker build .
* `NSM_VPP_API_SOCKET` - filename of socket to connect to existing VPP instance.
* `NSM_VPP_INIT` - type of VPP initialization. Must be AF_XDP, AF_PACKET or NONE
* `NSM_VPP_INIT_PARAMS` - Configuration file path containing VPP API parameters for initialization
* `NSM_VPP_MIN_OPERATION_TIMEOUT` - minimum timeout for every vpp operation
* `NSM_RESOURCE_POLL_TIMEOUT` - device plugin polling timeout
* `NSM_DEVICE_PLUGIN_PATH` - path to the device plugin directory
* `NSM_POD_RESOURCES_PATH` - path to the pod resources directory
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/networkservicemesh/sdk-kernel v0.0.0-20241126090835-89a3b4302060
github.com/networkservicemesh/sdk-sriov v0.0.0-20241126091246-f52c0d79803b
github.com/networkservicemesh/sdk-vpp v0.0.0-20241106142209-3dbe273c826b
github.com/networkservicemesh/vpphelper v0.0.0-20240115135903-e2b961f768b6
github.com/networkservicemesh/vpphelper v0.0.0-20241128104352-f48814525b60
github.com/pkg/errors v0.9.1
github.com/safchain/ethtool v0.3.0
github.com/sirupsen/logrus v1.9.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ github.com/networkservicemesh/sdk-sriov v0.0.0-20241126091246-f52c0d79803b h1:G+
github.com/networkservicemesh/sdk-sriov v0.0.0-20241126091246-f52c0d79803b/go.mod h1:CEKlRXbbf4rJzk3gMoPOPebIHu+Vmf529uhQK3O1gdw=
github.com/networkservicemesh/sdk-vpp v0.0.0-20241106142209-3dbe273c826b h1:oB4ZLVpDYcXF5F6gDh0NwZff3Nei3UONyzwn+FXSkZg=
github.com/networkservicemesh/sdk-vpp v0.0.0-20241106142209-3dbe273c826b/go.mod h1:vXXFWTK5XHuuKUY07lY+rdmNi8w7l2F34nEQRLtC3EA=
github.com/networkservicemesh/vpphelper v0.0.0-20240115135903-e2b961f768b6 h1:o+enN5yCikNXZN+hO+JjE+aLxBWq9+GMVF9GSQtpwMI=
github.com/networkservicemesh/vpphelper v0.0.0-20240115135903-e2b961f768b6/go.mod h1:n6+8PnoDvWj6WMryfU3J8HOCusgysFjQ0kGLfrcsDEM=
github.com/networkservicemesh/vpphelper v0.0.0-20241128104352-f48814525b60 h1:Yx5Do9XvsfY0S7d6yh7msHA+LdniP9JfYt+KgaWkEfA=
github.com/networkservicemesh/vpphelper v0.0.0-20241128104352-f48814525b60/go.mod h1:Qc5x5poZk5cVzcHk4ZIL6+NMC95uoitsmmnl7X9V/Yw=
github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8=
github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ=
github.com/open-policy-agent/opa v0.44.0 h1:sEZthsrWBqIN+ShTMJ0Hcz6a3GkYsY4FaB2S/ou2hZk=
Expand Down
11 changes: 6 additions & 5 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ type Config struct {
PrometheusListenOn string `default:":8081" desc:"Prometheus URL to ListenAndServe" split_words:"true"`
PrometheusServerHeaderTimeout time.Duration `default:"5s" desc:"Timeout for how long the Prometheus server waits for complete request headers from the client" split_words:"true"`

TunnelIP net.IP `desc:"IP to use for tunnels" split_words:"true"`
VxlanPort uint16 `default:"0" desc:"VXLAN port to use" split_words:"true"`
VppAPISocket string `default:"/var/run/vpp/external/vpp-api.sock" desc:"filename of socket to connect to existing VPP instance. If empty a VPP instance is run in forwarder" split_words:"true"`
VppInit vppinit.Func `default:"AF_PACKET" desc:"type of VPP initialization. Must be AF_XDP, AF_PACKET or NONE" split_words:"true"`
VppInitParams string `desc:"Configuration file path containing VPP API parameters for initialization" split_words:"true"`
TunnelIP net.IP `desc:"IP to use for tunnels" split_words:"true"`
VxlanPort uint16 `default:"0" desc:"VXLAN port to use" split_words:"true"`
VppAPISocket string `default:"/var/run/vpp/external/vpp-api.sock" desc:"filename of socket to connect to existing VPP instance. If empty a VPP instance is run in forwarder" split_words:"true"`
VppInit vppinit.Func `default:"AF_PACKET" desc:"type of VPP initialization. Must be AF_XDP, AF_PACKET or NONE" split_words:"true"`
VppInitParams string `desc:"Configuration file path containing VPP API parameters for initialization" split_words:"true"`
VPPMinOperationTimeout time.Duration `default:"2s" desc:"minimum timeout for every vpp operation" split_words:"true"`

ResourcePollTimeout time.Duration `default:"30s" desc:"device plugin polling timeout" split_words:"true"`
DevicePluginPath string `default:"/var/lib/kubelet/device-plugins/" desc:"path to the device plugin directory" split_words:"true"`
Expand Down
1 change: 1 addition & 0 deletions internal/imports/imports_linux.go

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

11 changes: 5 additions & 6 deletions internal/tests/suite_ipsec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ import (
"context"
"net"

"go.fd.io/govpp/api"
"google.golang.org/grpc"

"github.com/networkservicemesh/vpphelper"

"github.com/networkservicemesh/api/pkg/api/networkservice"
ipsecapi "github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/ipsec"

Expand All @@ -47,14 +46,14 @@ import (

type ipsecVerifiableEndpoint struct {
ctx context.Context
vppConn vpphelper.Connection
vppConn api.Connection
endpoint.Endpoint
}

func newIpsecVerifiableEndpoint(ctx context.Context,
prefix1, prefix2 *net.IPNet,
tokenGenerator token.GeneratorFunc,
vppConn vpphelper.Connection) verifiableEndpoint {
vppConn api.Connection) verifiableEndpoint {
rv := &ipsecVerifiableEndpoint{
ctx: ctx,
vppConn: vppConn,
Expand Down Expand Up @@ -94,14 +93,14 @@ func (v *ipsecVerifiableEndpoint) VerifyClose(_ *networkservice.Connection) erro

type ipsecVerifiableClient struct {
ctx context.Context
vppConn vpphelper.Connection
vppConn api.Connection
networkservice.NetworkServiceClient
}

func newIpsecVerifiableClient(
ctx context.Context,
sutCC grpc.ClientConnInterface,
vppConn vpphelper.Connection,
vppConn api.Connection,
) verifiableClient {
return &ipsecVerifiableClient{
ctx: ctx,
Expand Down
8 changes: 3 additions & 5 deletions internal/tests/suite_memif_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2023 Cisco and/or its affiliates.
// Copyright (c) 2020-2024 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -29,8 +29,6 @@ import (
"go.fd.io/govpp/api"
"go.fd.io/govpp/binapi/vlib"

"github.com/networkservicemesh/vpphelper"

"github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms"
"github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/sendfd"
"github.com/networkservicemesh/sdk/pkg/networkservice/core/chain"
Expand Down Expand Up @@ -63,7 +61,7 @@ type memifVerifiableEndpoint struct {
func newMemifVerifiableEndpoint(ctx context.Context,
prefix1, prefix2 *net.IPNet,
tokenGenerator token.GeneratorFunc,
vppConn vpphelper.Connection,
vppConn api.Connection,
) verifiableEndpoint {
return &memifVerifiableEndpoint{
ctx: ctx,
Expand Down Expand Up @@ -110,7 +108,7 @@ type memifVerifiableClient struct {
networkservice.NetworkServiceClient
}

func newMemifVerifiableClient(ctx context.Context, sutCC grpc.ClientConnInterface, vppConn vpphelper.Connection) verifiableClient {
func newMemifVerifiableClient(ctx context.Context, sutCC grpc.ClientConnInterface, vppConn api.Connection) verifiableClient {
rv := &memifVerifiableClient{
ctx: ctx,
vppConn: vppConn,
Expand Down
5 changes: 3 additions & 2 deletions internal/tests/suite_setup_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2023 Cisco and/or its affiliates.
// Copyright (c) 2020-2024 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -32,6 +32,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/spiffe/go-spiffe/v2/spiffetls/tlsconfig"
"github.com/spiffe/go-spiffe/v2/workloadapi"
"go.fd.io/govpp/api"
"go.fd.io/govpp/binapi/vpe"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
Expand Down Expand Up @@ -204,7 +205,7 @@ func (f *ForwarderTestSuite) SetupSuite() {
// ********************************************************************************
}

func (f *ForwarderTestSuite) createVpp(ctx context.Context, name string) (vppConn vpphelper.Connection, vppRoot string, errCh <-chan error) {
func (f *ForwarderTestSuite) createVpp(ctx context.Context, name string) (vppConn api.Connection, vppRoot string, errCh <-chan error) {
now := time.Now()
var err error
vppRoot, err = os.MkdirTemp("", fmt.Sprintf("%s-", name))
Expand Down
9 changes: 4 additions & 5 deletions internal/tests/suite_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2023 Cisco and/or its affiliates.
// Copyright (c) 2020-2024 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand All @@ -25,10 +25,9 @@ import (
"github.com/spiffe/go-spiffe/v2/bundle/x509bundle"
"github.com/spiffe/go-spiffe/v2/svid/x509svid"
"github.com/stretchr/testify/suite"
"go.fd.io/govpp/api"
"google.golang.org/grpc"

"github.com/networkservicemesh/vpphelper"

"github.com/networkservicemesh/api/pkg/api/registry"

"github.com/networkservicemesh/cmd-forwarder-vpp/internal/config"
Expand All @@ -51,12 +50,12 @@ type ForwarderTestSuite struct {
x509bundle x509bundle.Source

// vppServer stuff
vppServerConn vpphelper.Connection
vppServerConn api.Connection
vppServerRoot string
vppServerErrCh <-chan error

// vppClient stuff
vppClientConn vpphelper.Connection
vppClientConn api.Connection
vppClientRoot string
vppClientErrCh <-chan error

Expand Down
11 changes: 5 additions & 6 deletions internal/tests/suite_wireguard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ import (
"context"
"net"

"go.fd.io/govpp/api"
"google.golang.org/grpc"

"github.com/networkservicemesh/vpphelper"

"github.com/networkservicemesh/sdk/pkg/networkservice/chains/client"

"github.com/networkservicemesh/sdk/pkg/networkservice/common/authorize"
Expand All @@ -48,14 +47,14 @@ import (

type wireguardVerifiableEndpoint struct {
ctx context.Context
vppConn vpphelper.Connection
vppConn api.Connection
endpoint.Endpoint
}

func newWireguardVerifiableEndpoint(ctx context.Context,
prefix1, prefix2 *net.IPNet,
tokenGenerator token.GeneratorFunc,
vppConn vpphelper.Connection) verifiableEndpoint {
vppConn api.Connection) verifiableEndpoint {
rv := &wireguardVerifiableEndpoint{
ctx: ctx,
vppConn: vppConn,
Expand Down Expand Up @@ -95,14 +94,14 @@ func (v *wireguardVerifiableEndpoint) VerifyClose(_ *networkservice.Connection)

type wireguardVerifiableClient struct {
ctx context.Context
vppConn vpphelper.Connection
vppConn api.Connection
networkservice.NetworkServiceClient
}

func newWireguardVerifiableClient(
ctx context.Context,
sutCC grpc.ClientConnInterface,
vppConn vpphelper.Connection,
vppConn api.Connection,
) verifiableClient {
return &wireguardVerifiableClient{
ctx: ctx,
Expand Down
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ import (
"github.com/spiffe/go-spiffe/v2/spiffeid"
"github.com/spiffe/go-spiffe/v2/spiffetls/tlsconfig"
"github.com/spiffe/go-spiffe/v2/workloadapi"
"go.fd.io/govpp/api"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"

"github.com/networkservicemesh/vpphelper"
"github.com/networkservicemesh/vpphelper/extendtimeout"

registryapi "github.com/networkservicemesh/api/pkg/api/registry"
"github.com/networkservicemesh/sdk-k8s/pkg/tools/deviceplugin"
Expand Down Expand Up @@ -174,7 +176,7 @@ func main() {
// ********************************************************************************
now = time.Now()

var vppConn vpphelper.Connection
var vppConn api.Connection
var vppErrCh <-chan error
var metricsOpts []metrics.Option
cleanupDoneCh := make(chan struct{})
Expand Down Expand Up @@ -202,6 +204,7 @@ func main() {
log.FromContext(ctx).Info("local vpp is being used")
}

vppConn = extendtimeout.NewConnection(vppConn, cfg.VPPMinOperationTimeout)
log.FromContext(ctx).WithField("duration", time.Since(now)).Info("completed phase 2: run vpp and get a connection to it")

// ********************************************************************************
Expand Down

0 comments on commit 4d41019

Please sign in to comment.