Skip to content

Commit

Permalink
Merge pull request #309 from NikitaSkrynnik/use-strict
Browse files Browse the repository at this point in the history
Use strictvl3ipam chain element
  • Loading branch information
denis-tingaikin authored Mar 20, 2024
2 parents f2e73a9 + 73ca401 commit fddcee5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/edwarnicke/grpcfd v1.1.2
github.com/kelseyhightower/envconfig v1.4.0
github.com/networkservicemesh/api v1.12.1-rc.1.0.20240301085602-d5e1eb84eeb4
github.com/networkservicemesh/sdk v0.5.1-0.20240212105149-b1a3e26da857
github.com/networkservicemesh/sdk v0.5.1-0.20240319090455-a9e38d90df62
github.com/networkservicemesh/sdk-vpp v0.0.0-20240315112915-61dd50668ab8
github.com/networkservicemesh/vpphelper v0.0.0-20240115135903-e2b961f768b6
github.com/pkg/errors v0.9.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ github.com/networkservicemesh/api v1.12.1-rc.1.0.20240301085602-d5e1eb84eeb4 h1:
github.com/networkservicemesh/api v1.12.1-rc.1.0.20240301085602-d5e1eb84eeb4/go.mod h1:E2yBac48+mMkMh6ODnsNyah4EE6rI08SMR9n+86Emxs=
github.com/networkservicemesh/govpp v0.0.0-20240312165607-3c0a753ca3bf h1:K5lgSmjP5pjszXRP224r3Z1/Z791HY+fvZM7u4zAaSw=
github.com/networkservicemesh/govpp v0.0.0-20240312165607-3c0a753ca3bf/go.mod h1:CwikXQ3p/y3j6+HbQQWXKv0f4LPyUd2vKTiViG93qWA=
github.com/networkservicemesh/sdk v0.5.1-0.20240212105149-b1a3e26da857 h1:5Yn1mbXvveGjAi4YAUZsxvpy9+4clcVRKXLEga30+RY=
github.com/networkservicemesh/sdk v0.5.1-0.20240212105149-b1a3e26da857/go.mod h1:rw2ug2AngItEh13ectyCGrxRhGTt/yvJt2SrysoU/Dc=
github.com/networkservicemesh/sdk v0.5.1-0.20240319090455-a9e38d90df62 h1:jdPqrC8tAmggVkqRTwV5IQTL/2MjNEi+jYznlyUwOoY=
github.com/networkservicemesh/sdk v0.5.1-0.20240319090455-a9e38d90df62/go.mod h1:rw2ug2AngItEh13ectyCGrxRhGTt/yvJt2SrysoU/Dc=
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-vpp v0.0.0-20240315112915-61dd50668ab8 h1:L0k/g+dLhXOqy1qS3AqQhBt0bJdoTrWF7prmRvFjuz8=
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.

20 changes: 18 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
"github.com/networkservicemesh/sdk-vpp/pkg/networkservice/mechanisms/memif"
"github.com/networkservicemesh/sdk-vpp/pkg/networkservice/up"
"github.com/networkservicemesh/sdk-vpp/pkg/networkservice/vrf"
"github.com/networkservicemesh/sdk/pkg/ipam/strictvl3ipam"
"github.com/networkservicemesh/sdk/pkg/networkservice/chains/client"
"github.com/networkservicemesh/sdk/pkg/networkservice/common/clientinfo"
"github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/recvfd"
Expand Down Expand Up @@ -514,14 +515,22 @@ func createVl3Client(ctx context.Context, config *Config, vppConn vpphelper.Conn
),
),
)

var clientIpam vl3.IPAM
go func() {
for prefix := range prefixCh {
clientIpam.Reset(ctx, prefix.Prefix, prefix.ExcludePrefixes)
}
}()

c := client.NewClient(
ctx,
client.WithClientURL(&config.ConnectTo),
client.WithName(config.Name),
client.WithAdditionalFunctionality(
append(
clientAdditionalFunctionality,
vl3.NewClient(ctx, prefixCh),
vl3.NewClient(ctx, &clientIpam),
vl3dns.NewClient(config.dnsServerAddr, &config.dnsConfigs),
up.NewClient(ctx, vppConn, up.WithLoadSwIfIndex(loopback.Load)),
ipaddress.NewClient(vppConn, ipaddress.WithLoadSwIfIndex(loopback.Load)),
Expand All @@ -546,6 +555,13 @@ func createVl3Client(ctx context.Context, config *Config, vppConn vpphelper.Conn

func createVl3Endpoint(ctx context.Context, cancel context.CancelFunc, config *Config, vppConn vpphelper.Connection, tlsServerConfig *tls.Config,
source x509svid.Source, loopOpts []loopback.Option, vrfOpts []vrf.Option, prefixCh <-chan *ipam.PrefixResponse) *grpc.Server {
var serverIpam vl3.IPAM
go func() {
for prefix := range prefixCh {
serverIpam.Reset(ctx, prefix.Prefix, prefix.ExcludePrefixes)
}
}()

vl3Endpoint := endpoint.NewServer(ctx,
spiffejwt.TokenGeneratorFunc(source, config.MaxTokenLifetime),
endpoint.WithName(config.Name),
Expand All @@ -558,7 +574,7 @@ func createVl3Endpoint(ctx context.Context, cancel context.CancelFunc, config *C
vl3dns.WithConfigs(&config.dnsConfigs),
),
vl3mtu.NewServer(),
vl3.NewServer(ctx, prefixCh),
strictvl3ipam.NewServer(ctx, vl3.NewServer, &serverIpam),
up.NewServer(ctx, vppConn, up.WithLoadSwIfIndex(loopback.Load)),
ipaddress.NewServer(vppConn, ipaddress.WithLoadSwIfIndex(loopback.Load)),
unnumbered.NewServer(vppConn, loopback.Load),
Expand Down

0 comments on commit fddcee5

Please sign in to comment.