Skip to content

Commit

Permalink
Add latest IPv6 fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Glazychev <[email protected]>
  • Loading branch information
glazychev-art committed Feb 27, 2023
1 parent 4eef366 commit b02f84c
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,6 @@ issues:
- path: main.go
linters:
- revive
- path: vppinit/vppinit.go
linters:
- gocyclo
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/govpp v0.0.0-20230130211138-14ef5d20b1d0
github.com/edwarnicke/grpcfd v1.1.2
github.com/edwarnicke/vpphelper v0.0.0-20210225052320-b4f1f1aff45d
github.com/google/uuid v1.2.0
github.com/google/uuid v1.3.0
github.com/kelseyhightower/envconfig v1.4.0
github.com/networkservicemesh/api v1.7.2-0.20230123083145-4a6c3ec589e1
github.com/networkservicemesh/sdk v0.5.1-0.20230227075049-9a7d5a4b2da3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm4
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs=
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
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.

4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 Cisco and/or its affiliates.
// Copyright (c) 2022-2023 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -247,7 +247,7 @@ func main() {
tlsServerConfig := tlsconfig.MTLSServerConfig(source, source, tlsconfig.AuthorizeAny())
tlsServerConfig.MinVersion = tls.VersionTLS12

listenOn := &(url.URL{Scheme: "tcp", Host: config.TunnelIP.String() + ":"})
listenOn := &(url.URL{Scheme: "tcp", Host: net.JoinHostPort(config.TunnelIP.String(), "")})
server := createVl3Endpoint(
ctx,
config,
Expand Down
40 changes: 40 additions & 0 deletions vppinit/vppinit.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/edwarnicke/govpp/binapi/interface_types"
"github.com/edwarnicke/govpp/binapi/ip"
"github.com/edwarnicke/govpp/binapi/ip_neighbor"
"github.com/edwarnicke/govpp/binapi/vlib"
"github.com/pkg/errors"
"github.com/vishvananda/netlink"

Expand Down Expand Up @@ -73,6 +74,14 @@ func LinkToAfPacket(ctx context.Context, vppConn api.Connection, tunnelIP net.IP
return nil, aclErr
}

// Disable Router Advertisement on IPv6 tunnels
if tunnelIP.To4() == nil {
err = disableIPv6RA(ctx, vppConn, link)
if err != nil {
return nil, err
}
}

now := time.Now()
_, err = interfaces.NewServiceClient(vppConn).SwInterfaceSetFlags(ctx, &interfaces.SwInterfaceSetFlags{
SwIfIndex: swIfIndex,
Expand Down Expand Up @@ -314,3 +323,34 @@ func linkByIP(ctx context.Context, ipaddress net.IP) (netlink.Link, error) {
}
return nil, nil
}

func disableIPv6RA(ctx context.Context, vppConn api.Connection, link netlink.Link) error {
cmds := []string{
fmt.Sprintf("enable ip6 interface host-%s", link.Attrs().Name),
fmt.Sprintf("ip6 nd host-%s ra-cease ra-suppress", link.Attrs().Name),
}
for _, cmd := range cmds {
now := time.Now()
var reply, err = vlib.NewServiceClient(vppConn).CliInband(ctx, &vlib.CliInband{
Cmd: cmd,
})

if err != nil {
log.FromContext(ctx).
WithField("interface", fmt.Sprintf("host-%s", link.Attrs().Name)).
WithField("duration", time.Since(now)).
WithField("cmd", cmd).
WithField("vppapi", "CliInband").Error(err)
return err
}

log.FromContext(ctx).
WithField("interface", fmt.Sprintf("host-%s", link.Attrs().Name)).
WithField("cmd", cmd).
WithField("reply", reply.Reply).
WithField("duration", time.Since(now)).
WithField("vppapi", "CliInband").Debug("completed")
}

return nil
}

0 comments on commit b02f84c

Please sign in to comment.