Skip to content

Commit

Permalink
Make VXLAN port configurable
Browse files Browse the repository at this point in the history
Issue: #340

Signed-off-by: Laszlo Kiraly <laszlo.kiraly@est.tech>
  • Loading branch information
ljkiraly committed Mar 21, 2024
1 parent 388bf8e commit 3674a70
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 25 deletions.
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ require (
github.com/networkservicemesh/api v1.11.1-0.20231031152153-730abd666985
github.com/networkservicemesh/sdk v0.5.1-0.20240321094816-f5e9a5c9a229
github.com/networkservicemesh/sdk-k8s v0.0.0-20240321095238-ab68813f840b
github.com/networkservicemesh/sdk-ovs v0.0.0-20240212110616-e5da7f792803
github.com/networkservicemesh/sdk-sriov v0.0.0-20240212110157-32204092822a
github.com/networkservicemesh/sdk-ovs v0.0.0-20240319143704-12d73931586b
github.com/networkservicemesh/sdk-sriov v0.0.0-20240319091109-93b591c8e299
github.com/ovn-org/ovn-kubernetes/go-controller v0.0.0-20210826171620-f06c53111a31
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.9.0
Expand Down Expand Up @@ -44,7 +44,6 @@ require (
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,10 @@ github.com/networkservicemesh/sdk-k8s v0.0.0-20240321095238-ab68813f840b h1:qGYl
github.com/networkservicemesh/sdk-k8s v0.0.0-20240321095238-ab68813f840b/go.mod h1:haGuQj/ogkpUeTNq4v1ySY6Pj+AwhFlDvH3f5IqajY0=
github.com/networkservicemesh/sdk-kernel v0.0.0-20240212105448-f9f740175836 h1:izzgZmyDcgEElhNv4DbsKWoZ6mazueIlqLOvULq+t4k=
github.com/networkservicemesh/sdk-kernel v0.0.0-20240212105448-f9f740175836/go.mod h1:xvmFv1R0zlB1pNtjWCiw0y7df+/XITxtSGDhQj7jAEs=
github.com/networkservicemesh/sdk-ovs v0.0.0-20240212110616-e5da7f792803 h1:37EW1eTTZUwldd3pZDuKY3km3Lc/PojfxmXF8MaajnU=
github.com/networkservicemesh/sdk-ovs v0.0.0-20240212110616-e5da7f792803/go.mod h1:+Vb4mrXJGtHOXo2fitF/7kBqWstDHZaQqlXBxw9VcHU=
github.com/networkservicemesh/sdk-sriov v0.0.0-20240212110157-32204092822a h1:R9tmLBVm8c80OPxUZyGT1RdvBE3N2EXNd56bFcwAoE4=
github.com/networkservicemesh/sdk-sriov v0.0.0-20240212110157-32204092822a/go.mod h1:lTP/g0pAmkYW+RqVRiHdA0gylXD0hrTT0hXyzhi4iPY=
github.com/networkservicemesh/sdk-ovs v0.0.0-20240319143704-12d73931586b h1:OCBHNJwlBqQQAkICO1Uv0cgRdR0WIzdLI84uKeUvdnI=
github.com/networkservicemesh/sdk-ovs v0.0.0-20240319143704-12d73931586b/go.mod h1:JP9MVi/jfln5D5KBQqHukKznRm77lgGVGuFGeOqsPZw=
github.com/networkservicemesh/sdk-sriov v0.0.0-20240319091109-93b591c8e299 h1:0PAjNvCfu80Mo4BrztAdcr5G9zSM+mGbW8+nkT9zH8Q=
github.com/networkservicemesh/sdk-sriov v0.0.0-20240319091109-93b591c8e299/go.mod h1:GKmM0Fwc02OFHyvOOvPAyUD+M4766DvGUamw214saVk=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
Expand Down
49 changes: 31 additions & 18 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2021-2023 Nordix Foundation.
// Copyright (c) 2021-2024 Nordix Foundation.
//
// Copyright (c) 2023 Cisco Foundation.
// Copyright (c) 2023-2024 Cisco Foundation.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -42,6 +42,7 @@ import (
k8sdeviceplugin "github.com/networkservicemesh/sdk-k8s/pkg/tools/deviceplugin"
k8spodresources "github.com/networkservicemesh/sdk-k8s/pkg/tools/podresources"
"github.com/networkservicemesh/sdk-ovs/pkg/networkservice/chains/forwarder"
"github.com/networkservicemesh/sdk-ovs/pkg/networkservice/mechanisms/vxlan"
ovsutil "github.com/networkservicemesh/sdk-ovs/pkg/tools/utils"
sriovconfig "github.com/networkservicemesh/sdk-sriov/pkg/sriov/config"
"github.com/networkservicemesh/sdk-sriov/pkg/sriov/pci"
Expand Down Expand Up @@ -81,6 +82,7 @@ type Config struct {
NSName string `default:"forwarder" desc:"Name of Network Service to Register with Registry"`
BridgeName string `default:"br-nsm" desc:"Name of the OvS bridge"`
TunnelIP string `desc:"IP or CIDR to use for tunnels" split_words:"true"`
VxlanPort uint16 `default:"4789" desc:"VXLAN port to use" split_words:"true"`
ConnectTo url.URL `default:"unix:///connect.to.socket" desc:"url to connect to" split_words:"true"`
DialTimeout time.Duration `default:"50ms" desc:"Timeout for the dial the next endpoint" split_words:"true"`
MaxTokenLifetime time.Duration `default:"24h" desc:"maximum lifetime of tokens" split_words:"true"`
Expand Down Expand Up @@ -335,6 +337,17 @@ func createKernelInterposeEndpoint(ctx context.Context, config *Config, tlsConfi
egressTunnelIP net.IP, l2cMap map[string]*ovsutil.L2ConnectionPoint) (endpoint.Endpoint, error) {
var spiffeidmap genericsync.Map[spiffeid.ID, *genericsync.Map[string, struct{}]]

dialOptions := append(
tracing.WithTracingDial(),
grpc.WithBlock(),
grpc.WithTransportCredentials(
grpcfd.TransportCredentials(credentials.NewTLS(tlsConfig))),
grpc.WithDefaultCallOptions(
grpc.WaitForReady(true),
grpc.PerRPCCredentials(token.NewPerRPCCredentials(spiffejwt.TokenGeneratorFunc(source, config.MaxTokenLifetime))),
),
grpcfd.WithChainStreamInterceptor(),
grpcfd.WithChainUnaryInterceptor())
return forwarder.NewKernelServer(
ctx,
config.Name,
Expand All @@ -346,14 +359,8 @@ func createKernelInterposeEndpoint(ctx context.Context, config *Config, tlsConfi
egressTunnelIP,
config.DialTimeout,
l2cMap,
grpc.WithBlock(),
grpc.WithTransportCredentials(
grpcfd.TransportCredentials(credentials.NewTLS(tlsConfig))),
grpc.WithDefaultCallOptions(
grpc.PerRPCCredentials(token.NewPerRPCCredentials(spiffejwt.TokenGeneratorFunc(source, config.MaxTokenLifetime))),
),
grpcfd.WithChainStreamInterceptor(),
grpcfd.WithChainUnaryInterceptor(),
forwarder.WithVxlanOptions(vxlan.WithPort(config.VxlanPort)),
forwarder.WithDialOptions(dialOptions...),
)
}

Expand Down Expand Up @@ -391,6 +398,18 @@ func createSriovInterposeEndpoint(ctx context.Context, config *Config, tlsConfig

var spiffeidmap genericsync.Map[spiffeid.ID, *genericsync.Map[string, struct{}]]

dialOptions := append(
tracing.WithTracingDial(),
grpc.WithBlock(),
grpc.WithTransportCredentials(
grpcfd.TransportCredentials(credentials.NewTLS(tlsConfig))),
grpc.WithDefaultCallOptions(
grpc.WaitForReady(true),
grpc.PerRPCCredentials(token.NewPerRPCCredentials(spiffejwt.TokenGeneratorFunc(source, config.MaxTokenLifetime))),
),
grpcfd.WithChainStreamInterceptor(),
grpcfd.WithChainUnaryInterceptor())

return forwarder.NewSriovServer(
ctx,
config.Name,
Expand All @@ -405,14 +424,8 @@ func createSriovInterposeEndpoint(ctx context.Context, config *Config, tlsConfig
sriovConfig,
config.DialTimeout,
l2cMap,
grpc.WithBlock(),
grpc.WithTransportCredentials(
grpcfd.TransportCredentials(credentials.NewTLS(tlsConfig))),
grpc.WithDefaultCallOptions(
grpc.PerRPCCredentials(token.NewPerRPCCredentials(spiffejwt.TokenGeneratorFunc(source, config.MaxTokenLifetime))),
),
grpcfd.WithChainStreamInterceptor(),
grpcfd.WithChainUnaryInterceptor(),
forwarder.WithVxlanOptions(vxlan.WithPort(config.VxlanPort)),
forwarder.WithDialOptions(dialOptions...),
)
}

Expand Down

0 comments on commit 3674a70

Please sign in to comment.