diff --git a/.golangci.yml b/.golangci.yml index 014a71d..89bc561 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -166,3 +166,7 @@ issues: exclude-use-default: false max-issues-per-linter: 0 max-same-issues: 0 + exclude-rules: + - path: vppinit/vppinit.go + linters: + - gocyclo diff --git a/Dockerfile b/Dockerfile index 75117c8..7a7833f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG VPP_VERSION=v22.06-rc0-147-g1c5485ab8 +ARG VPP_VERSION=v22.06-rc0-150-gd38fa55fa FROM ghcr.io/edwarnicke/govpp/vpp:${VPP_VERSION} as go COPY --from=golang:1.18.2-buster /usr/local/go/ /go ENV PATH ${PATH}:/go/bin diff --git a/go.mod b/go.mod index 48ae66d..9892128 100644 --- a/go.mod +++ b/go.mod @@ -5,13 +5,13 @@ go 1.18 require ( git.fd.io/govpp.git v0.3.6-0.20210927044411-385ccc0d8ba9 github.com/antonfisher/nested-logrus-formatter v1.3.1 - github.com/edwarnicke/govpp v0.0.0-20220509171552-731995b8f574 + github.com/edwarnicke/govpp v0.0.0-20221023154218-ef9a6adf6930 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.4.1-0.20220711153918-a59689088578 - github.com/networkservicemesh/sdk v0.5.1-0.20221013082556-9ae27f8b63af + github.com/networkservicemesh/sdk v0.5.1-0.20221031083615-fac60b46dace github.com/networkservicemesh/sdk-kernel v0.0.0-20221013082925-354d38e71cde github.com/networkservicemesh/sdk-vpp v0.0.0-20221013083414-db9c967a253d github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index e19f7d4..c1cabb6 100644 --- a/go.sum +++ b/go.sum @@ -80,8 +80,8 @@ github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8 github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/edwarnicke/exechelper v1.0.2 h1:dD49Ui2U0FBFxxhalnKw6vLS0P0TkgnXBRvKL/xmC5w= github.com/edwarnicke/exechelper v1.0.2/go.mod h1:/T271jtNX/ND4De6pa2aRy2+8sNtyCDB1A2pp4M+fUs= -github.com/edwarnicke/govpp v0.0.0-20220509171552-731995b8f574 h1:2lYhLBDjflBOPJLd/42txk9QlSkVep6p1vKzlvkCKOI= -github.com/edwarnicke/govpp v0.0.0-20220509171552-731995b8f574/go.mod h1:kHDnxA+SSNFeMEHz7xvhub1zvx4mOTRlWWRCay2n5NM= +github.com/edwarnicke/govpp v0.0.0-20221023154218-ef9a6adf6930 h1:/gS3gW7jV6ljzWcnHGxu1Yn1guxtwq8IuwJpK5TUl1w= +github.com/edwarnicke/govpp v0.0.0-20221023154218-ef9a6adf6930/go.mod h1:kHDnxA+SSNFeMEHz7xvhub1zvx4mOTRlWWRCay2n5NM= github.com/edwarnicke/grpcfd v1.1.2 h1:2b8kCABQ1+JjSKGDoHadqSW7whCeTXMqtyo6jmB5B8k= github.com/edwarnicke/grpcfd v1.1.2/go.mod h1:rHihB9YvNMixz8rS+ZbwosI2kj65VLkeyYAI2M+/cGA= github.com/edwarnicke/log v1.0.0 h1:T6uRNCmR99GTt/CpRr2Gz8eGW8fm0HMThDNGdNxPaGk= @@ -180,8 +180,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= @@ -217,8 +217,8 @@ github.com/miekg/dns v1.1.50 h1:DQUfb9uc6smULcREF09Uc+/Gd46YWqJd5DbpPE9xkcA= github.com/mikioh/ipaddr v0.0.0-20190404000644-d465c8ab6721/go.mod h1:Ickgr2WtCLZ2MDGd4Gr0geeCH5HybhRJbonOgQpvSxc= github.com/networkservicemesh/api v1.4.1-0.20220711153918-a59689088578 h1:2MZD6SGFULqTgMKA8BFy7F+ldRErAyxsWht7oCwCVRM= github.com/networkservicemesh/api v1.4.1-0.20220711153918-a59689088578/go.mod h1:hOF2844BSstH1311oDMDgqqXS+kdc77htZNPRKl9mf8= -github.com/networkservicemesh/sdk v0.5.1-0.20221013082556-9ae27f8b63af h1:6X3VF4J+jWYWYsQ+Nnx/B0dSFWh79X8SmoaOeEiucuI= -github.com/networkservicemesh/sdk v0.5.1-0.20221013082556-9ae27f8b63af/go.mod h1:YnWv4wspKOtfFsc7kC5tfs7n95Snj3C0MRCal7yytVE= +github.com/networkservicemesh/sdk v0.5.1-0.20221031083615-fac60b46dace h1:ct4bWeeEScl+OkLmWtttmWSjxK7r6itZ438l9rPESto= +github.com/networkservicemesh/sdk v0.5.1-0.20221031083615-fac60b46dace/go.mod h1:YnWv4wspKOtfFsc7kC5tfs7n95Snj3C0MRCal7yytVE= github.com/networkservicemesh/sdk-kernel v0.0.0-20221013082925-354d38e71cde h1:uCpQ4qqDs/RE30uKUR2pWQITNgOuSjNO5uEez0uteEU= github.com/networkservicemesh/sdk-kernel v0.0.0-20221013082925-354d38e71cde/go.mod h1:bcTM2B6ehXCJLl8Mg5DLQgt+xM2Xolf9P9BVQKDv0IA= github.com/networkservicemesh/sdk-vpp v0.0.0-20221013083414-db9c967a253d h1:sIVWteQt7n0d6yKE27a3hnMgdlwNm048YoSRJY2wlu4= diff --git a/internal/imports/imports_linux.go b/internal/imports/imports_linux.go index 5d9710e..b8d5843 100644 --- a/internal/imports/imports_linux.go +++ b/internal/imports/imports_linux.go @@ -16,6 +16,7 @@ import ( _ "github.com/edwarnicke/govpp/binapi/ip" _ "github.com/edwarnicke/govpp/binapi/ip_neighbor" _ "github.com/edwarnicke/govpp/binapi/ip_types" + _ "github.com/edwarnicke/govpp/binapi/vlib" _ "github.com/edwarnicke/grpcfd" _ "github.com/edwarnicke/vpphelper" _ "github.com/google/uuid" diff --git a/main.go b/main.go index 88512ed..b2156e4 100644 --- a/main.go +++ b/main.go @@ -245,7 +245,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, diff --git a/vppinit/vppinit.go b/vppinit/vppinit.go index f950a94..ff14d42 100644 --- a/vppinit/vppinit.go +++ b/vppinit/vppinit.go @@ -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" @@ -69,6 +70,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, @@ -311,3 +320,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 +}