Skip to content

Commit

Permalink
Merge pull request #363 from Nordix/refactor-chains-options-pattern
Browse files Browse the repository at this point in the history
Refactor forwarder to use updated Options pattern from sdk-ovs
  • Loading branch information
denis-tingaikin authored Apr 22, 2024
2 parents ab2b01e + 659e841 commit 0d838b5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ require (
github.com/kelseyhightower/envconfig v1.4.0
github.com/networkservicemesh/api v1.13.1-0.20240411170402-f357d8c715a2
github.com/networkservicemesh/sdk v0.5.1-0.20240418094831-608b1b518564
github.com/networkservicemesh/sdk-k8s v0.0.0-20240418095920-671945331706
github.com/networkservicemesh/sdk-ovs v0.0.0-20240418100955-9074299d90cb
github.com/networkservicemesh/sdk-k8s v0.0.0-20240411170828-cb1ee2e11b80
github.com/networkservicemesh/sdk-ovs v0.0.0-20240418152653-d21bcac77d10
github.com/networkservicemesh/sdk-sriov v0.0.0-20240418100345-53b4eee751d5
github.com/ovn-org/ovn-kubernetes/go-controller v0.0.0-20210826171620-f06c53111a31
github.com/pkg/errors v0.9.1
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -404,12 +404,12 @@ github.com/networkservicemesh/api v1.13.1-0.20240411170402-f357d8c715a2 h1:R3qJR
github.com/networkservicemesh/api v1.13.1-0.20240411170402-f357d8c715a2/go.mod h1:B8FmS3XZ7NZY7ZEtdcNg2NHYppDHlr4kl4eecdZN9eI=
github.com/networkservicemesh/sdk v0.5.1-0.20240418094831-608b1b518564 h1:QEAVhzA0X7YXUvfzx72F/wanN68FqTHM0lN4Msfvwh0=
github.com/networkservicemesh/sdk v0.5.1-0.20240418094831-608b1b518564/go.mod h1:ERwrGiimSHeUGwgwhgYLl7B/vkYgmIwxZmrQJzJ6hcQ=
github.com/networkservicemesh/sdk-k8s v0.0.0-20240418095920-671945331706 h1:2E+tZ2QKs/1NJCsn7POtDy5sb3ds4zLAyowfty5KPsQ=
github.com/networkservicemesh/sdk-k8s v0.0.0-20240418095920-671945331706/go.mod h1:pyMim9f/Y1GSShtz5eI5vLUItYnurbqH/kYd3oMmhxk=
github.com/networkservicemesh/sdk-k8s v0.0.0-20240411170828-cb1ee2e11b80 h1:EL3HNWhKg+NUTaqsIhiG1Tgf+nv+rl35C4lWDUNvHDc=
github.com/networkservicemesh/sdk-k8s v0.0.0-20240411170828-cb1ee2e11b80/go.mod h1:WhBobGFD9KmSg88HmwvuoZTh4rL2jd8Sb+96BLlKjgk=
github.com/networkservicemesh/sdk-kernel v0.0.0-20240418095606-2a4c66902432 h1:cCTF9FNDcsJ6qacwnAFcL+QbmFHMtp3u4R49ebRvTT4=
github.com/networkservicemesh/sdk-kernel v0.0.0-20240418095606-2a4c66902432/go.mod h1:0I6XLdyHngMeIfl+qmT4UMF78lPpxOPAgOG3y1tjM98=
github.com/networkservicemesh/sdk-ovs v0.0.0-20240418100955-9074299d90cb h1:qr9nIiel/ybp1c8FBqfqtw47DxYFufHb9Z5bsegyd+I=
github.com/networkservicemesh/sdk-ovs v0.0.0-20240418100955-9074299d90cb/go.mod h1:1MbOF7vcvPCVfx6El7XpZjgJIZuf8PZuES8dX4008rw=
github.com/networkservicemesh/sdk-ovs v0.0.0-20240418152653-d21bcac77d10 h1:aIBJcQpoCOO7uaEYM1ATvCxqem29DSnkcRiOqmeP5KI=
github.com/networkservicemesh/sdk-ovs v0.0.0-20240418152653-d21bcac77d10/go.mod h1:WYghXt3MSjILrkGNQ6r02dpo0QABmq13M+6T5nerzL8=
github.com/networkservicemesh/sdk-sriov v0.0.0-20240418100345-53b4eee751d5 h1:4wbJPcfFvElP4fCnlElEMcKlXckUYWqvZHuAB8nkNWc=
github.com/networkservicemesh/sdk-sriov v0.0.0-20240418100345-53b4eee751d5/go.mod h1:FjCG2SNQD0BdTnSg9PcVZmwtOGPh8O1EbTKukNpDUnk=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
Expand Down
30 changes: 16 additions & 14 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ func createInterposeEndpoint(ctx context.Context, config *Config, tlsClientConfi
}

func createKernelInterposeEndpoint(ctx context.Context, config *Config, tlsConfig *tls.Config, source x509svid.Source,
egressTunnelIP net.IP, l2cMap map[string]*ovsutil.L2ConnectionPoint) (endpoint.Endpoint, error) {
egressTunnelIP net.IP, l2cMap map[string]*ovsutil.L2ConnectionPoint,
) (endpoint.Endpoint, error) {
var spiffeidmap genericsync.Map[spiffeid.ID, *genericsync.Map[string, struct{}]]

dialOptions := append(
Expand All @@ -350,22 +351,23 @@ func createKernelInterposeEndpoint(ctx context.Context, config *Config, tlsConfi
grpcfd.WithChainUnaryInterceptor())
return forwarder.NewKernelServer(
ctx,
config.Name,
authorize.NewServer(authorize.WithSpiffeIDConnectionMap(&spiffeidmap)),
monitorauthorize.NewMonitorConnectionServer(monitorauthorize.WithSpiffeIDConnectionMap(&spiffeidmap)),
spiffejwt.TokenGeneratorFunc(source, config.MaxTokenLifetime),
&config.ConnectTo,
config.BridgeName,
egressTunnelIP,
config.DialTimeout,
l2cMap,
forwarder.WithName(config.Name),
forwarder.WithBridgeName(config.BridgeName),
forwarder.WithAuthorizeServer(authorize.NewServer(authorize.WithSpiffeIDConnectionMap(&spiffeidmap))),
forwarder.WithAuthorizeMonitorConnectionServer(monitorauthorize.NewMonitorConnectionServer(monitorauthorize.WithSpiffeIDConnectionMap(&spiffeidmap))),
forwarder.WithClientURL(&config.ConnectTo),
forwarder.WithDialTimeout(config.DialTimeout),
forwarder.WithVxlanOptions(vxlan.WithPort(config.VxlanPort)),
forwarder.WithDialOptions(dialOptions...),
)
}

func createSriovInterposeEndpoint(ctx context.Context, config *Config, tlsConfig *tls.Config, source x509svid.Source,
egressTunnelIP net.IP, l2cMap map[string]*ovsutil.L2ConnectionPoint) (endpoint.Endpoint, error) {
egressTunnelIP net.IP, l2cMap map[string]*ovsutil.L2ConnectionPoint,
) (endpoint.Endpoint, error) {
sriovConfig, err := sriovconfig.ReadConfig(ctx, config.SRIOVConfigFile)
if err != nil {
return nil, err
Expand Down Expand Up @@ -412,18 +414,18 @@ func createSriovInterposeEndpoint(ctx context.Context, config *Config, tlsConfig

return forwarder.NewSriovServer(
ctx,
config.Name,
authorize.NewServer(authorize.WithSpiffeIDConnectionMap(&spiffeidmap)),
monitorauthorize.NewMonitorConnectionServer(monitorauthorize.WithSpiffeIDConnectionMap(&spiffeidmap)),
spiffejwt.TokenGeneratorFunc(source, config.MaxTokenLifetime),
&config.ConnectTo,
config.BridgeName,
egressTunnelIP,
pciPool,
resourcePool,
sriovConfig,
config.DialTimeout,
l2cMap,
forwarder.WithName(config.Name),
forwarder.WithBridgeName(config.BridgeName),
forwarder.WithAuthorizeServer(authorize.NewServer(authorize.WithSpiffeIDConnectionMap(&spiffeidmap))),
forwarder.WithAuthorizeMonitorConnectionServer(monitorauthorize.NewMonitorConnectionServer(monitorauthorize.WithSpiffeIDConnectionMap(&spiffeidmap))),
forwarder.WithClientURL(&config.ConnectTo),
forwarder.WithDialTimeout(config.DialTimeout),
forwarder.WithVxlanOptions(vxlan.WithPort(config.VxlanPort)),
forwarder.WithDialOptions(dialOptions...),
)
Expand Down

0 comments on commit 0d838b5

Please sign in to comment.