Skip to content

Commit

Permalink
refactor: Improve VPP handler versions and add VPP proxy support (#1593)
Browse files Browse the repository at this point in the history
* Use more specific VPP versions

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>

* Improve VPP handler versions and cleanup vppcalls packages

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>

* Remove comments

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>

* Fix logs and errors for telemetry

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>

* Add VPP proxy support and make version resolution more robust

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>

* Refactor vpp package to simplify vpp.Client interface

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>

* Rename vppmock_test.go

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>

* Print interface type in error log

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>

* Fix comment

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>

* Print interface name string

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>

* Handle errors

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
  • Loading branch information
ondrej-fabry committed Jan 8, 2020
1 parent 3dfa330 commit 0e2148d
Show file tree
Hide file tree
Showing 158 changed files with 1,423 additions and 920 deletions.
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ require (
github.com/howeyc/crc16 v0.0.0-20171223171357-2b2a61e366a6 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jhump/protoreflect v1.5.0
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/ligato/cn-infra v2.2.1-0.20191030081411-42c7431fdca1+incompatible
github.com/lunixbochs/struc v0.0.0-20190916212049-a5c72983bc42
github.com/mitchellh/go-homedir v0.0.0-20180523094522-3864e76763d9 // indirect
Expand All @@ -71,7 +72,7 @@ require (
github.com/prometheus/client_golang v0.9.3
github.com/rcrowley/go-metrics v0.0.0-20180503174638-e2704e165165 // indirect
github.com/satori/go.uuid v0.0.0-20181028125025-b2ce2384e17b // indirect
github.com/sirupsen/logrus v1.2.0
github.com/sirupsen/logrus v1.4.2
github.com/spf13/cobra v0.0.3
github.com/spf13/pflag v1.0.3
github.com/spf13/viper v1.4.0
Expand All @@ -83,8 +84,9 @@ require (
github.com/yuin/gopher-lua v0.0.0-20190514113301-1cd887cd7036 // indirect
go.etcd.io/bbolt v1.3.3 // indirect
go.uber.org/multierr v1.2.0 // indirect
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 // indirect
golang.org/x/net v0.0.0-20190522155817-f3200d17e092
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
golang.org/x/sys v0.0.0-20191210023423-ac6580df4449
golang.org/x/time v0.0.0-20190921001708-c4c64cad1fd0 // indirect
google.golang.org/grpc v1.24.0
gotest.tools v2.2.0+incompatible // indirect
Expand Down
11 changes: 11 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
Expand Down Expand Up @@ -275,6 +277,8 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg
github.com/sirupsen/logrus v1.0.0/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/soheilhy/cmux v0.1.4 h1:0HKaf1o97UwFjHH9o5XsHUOF+tqmdA7KEzXLpiyaw0E=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
Expand Down Expand Up @@ -329,6 +333,8 @@ golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3 h1:KYQXGkl6vs02hK7pK4eIbw
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 h1:ULYEB3JvPRE/IfO+9uO7vKV/xzVTO7XPAwm8xbf4w2g=
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand All @@ -340,6 +346,7 @@ golang.org/x/net v0.0.0-20181220203305-927f97764cc3 h1:eH6Eip3UpmR+yM/qI9Ijluzb1
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190522155817-f3200d17e092 h1:4QSRKanuywn15aTZvI/mIDEgPQpswuFndXpOj3rKEco=
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs=
Expand All @@ -362,6 +369,10 @@ golang.org/x/sys v0.0.0-20190204203706-41f3e6584952 h1:FDfvYgoVsA7TTZSbgiqjAbfPb
golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191210023423-ac6580df4449 h1:gSbV7h1NRL2G1xTg/owz62CST1oJBmxy4QpMMregXVQ=
golang.org/x/sys v0.0.0-20191210023423-ac6580df4449/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down
24 changes: 5 additions & 19 deletions plugins/configurator/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@
package configurator

import (
"git.fd.io/govpp.git/api"

"github.com/ligato/cn-infra/infra"
"github.com/ligato/cn-infra/rpc/grpc"
"github.com/ligato/cn-infra/servicelabel"
"github.com/ligato/cn-infra/utils/safeclose"

"go.ligato.io/vpp-agent/v2/plugins/govppmux"
iflinuxplugin "go.ligato.io/vpp-agent/v2/plugins/linux/ifplugin"
Expand Down Expand Up @@ -53,9 +50,6 @@ type Plugin struct {
Deps

configurator configuratorServer

// Channels
vppChan api.Channel
}

// Deps - dependencies of Plugin
Expand Down Expand Up @@ -107,16 +101,11 @@ func (p *Plugin) sendVppNotification(vppNotification *vpp.Notification) {

// Close does nothing.
func (p *Plugin) Close() error {
return safeclose.Close(p.vppChan)
return nil
}

// helper method initializes all VPP/Linux plugin handlers
func (p *Plugin) initHandlers() (err error) {
// VPP channels
if p.vppChan, err = p.VPP.NewAPIChannel(); err != nil {
return err
}

// VPP Indexes
ifIndexes := p.VPPIfPlugin.GetInterfaceIndex()
dhcpIndexes := p.VPPIfPlugin.GetDHCPIndex()
Expand All @@ -128,25 +117,22 @@ func (p *Plugin) initHandlers() (err error) {
linuxIfIndexes := p.LinuxIfPlugin.GetInterfaceIndex()

// VPP handlers

// core
p.configurator.ifHandler = ifvppcalls.CompatibleInterfaceVppHandler(p.VPP, p.Log)
if p.configurator.ifHandler == nil {
p.Log.Info("VPP Interface handler is not available, it will be skipped")
}
p.configurator.l2Handler = l2vppcalls.CompatibleL2VppHandler(p.vppChan, ifIndexes, bdIndexes, p.Log)
p.configurator.l2Handler = l2vppcalls.CompatibleL2VppHandler(p.VPP, ifIndexes, bdIndexes, p.Log)
if p.configurator.l2Handler == nil {
p.Log.Info("VPP L2 handler is not available, it will be skipped")
}
p.configurator.l3Handler = l3vppcalls.CompatibleL3VppHandler(p.vppChan, ifIndexes, vrfIndexes, p.AddrAlloc, p.Log)
p.configurator.l3Handler = l3vppcalls.CompatibleL3VppHandler(p.VPP, ifIndexes, vrfIndexes, p.AddrAlloc, p.Log)
if p.configurator.l3Handler == nil {
p.Log.Info("VPP L3 handler is not available, it will be skipped")
}
p.configurator.ipsecHandler = ipsecvppcalls.CompatibleIPSecVppHandler(p.vppChan, ifIndexes, p.Log)
p.configurator.ipsecHandler = ipsecvppcalls.CompatibleIPSecVppHandler(p.VPP, ifIndexes, p.Log)
if p.configurator.ipsecHandler == nil {
p.Log.Info("VPP IPSec handler is not available, it will be skipped")
}

// plugins
p.configurator.abfHandler = abfvppcalls.CompatibleABFHandler(p.VPP, aclIndexes, ifIndexes, p.Log)
if p.configurator.abfHandler == nil {
Expand All @@ -160,7 +146,7 @@ func (p *Plugin) initHandlers() (err error) {
if p.configurator.natHandler == nil {
p.Log.Info("VPP NAT handler is not available, it will be skipped")
}
p.configurator.puntHandler = puntvppcalls.CompatiblePuntVppHandler(p.vppChan, ifIndexes, p.Log)
p.configurator.puntHandler = puntvppcalls.CompatiblePuntVppHandler(p.VPP, ifIndexes, p.Log)
if p.configurator.puntHandler == nil {
p.Log.Info("VPP Punt handler is not available, it will be skipped")
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/govppmux/client_binapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"git.fd.io/govpp.git/core"
. "github.com/onsi/gomega"

"go.ligato.io/vpp-agent/v2/plugins/vpp/vppcallmock"
"go.ligato.io/vpp-agent/v2/plugins/vpp/vppmock"
)

func TestRequestRetry(t *testing.T) {
Expand Down Expand Up @@ -72,7 +72,7 @@ func TestRequestRetry(t *testing.T) {
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
ctx := vppcallmock.SetupTestCtx(t)
ctx := vppmock.SetupTestCtx(t)
defer ctx.TeardownTestCtx()

retryCfg := retryConfig{test.attempts, test.timeout}
Expand Down
13 changes: 6 additions & 7 deletions plugins/govppmux/client_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package govppmux
import (
"git.fd.io/govpp.git/adapter"
govppapi "git.fd.io/govpp.git/api"
govpp "git.fd.io/govpp.git/core"
)

// ListStats returns all stats names
Expand All @@ -38,39 +37,39 @@ func (p *Plugin) DumpStats(prefixes ...string) ([]adapter.StatEntry, error) {

// GetSystemStats retrieves system statistics of the connected VPP instance like Vector rate, Input rate, etc.
func (p *Plugin) GetSystemStats(stats *govppapi.SystemStats) error {
if p.statsConn == nil || p.statsConn.(*govpp.StatsConnection) == nil {
if p.statsConn == nil {
return nil
}
return p.statsConn.GetSystemStats(stats)
}

// GetNodeStats retrieves a list of Node VPP counters (vectors, clocks, ...)
func (p *Plugin) GetNodeStats(stats *govppapi.NodeStats) error {
if p.statsConn == nil || p.statsConn.(*govpp.StatsConnection) == nil {
if p.statsConn == nil {
return nil
}
return p.statsConn.GetNodeStats(stats)
}

// GetInterfaceStats retrieves all counters related to the VPP interfaces
func (p *Plugin) GetInterfaceStats(stats *govppapi.InterfaceStats) error {
if p.statsConn == nil || p.statsConn.(*govpp.StatsConnection) == nil {
if p.statsConn == nil {
return nil
}
return p.statsConn.GetInterfaceStats(stats)
}

// GetErrorStats retrieves VPP error counters
func (p *Plugin) GetErrorStats(stats *govppapi.ErrorStats) error {
if p.statsConn == nil || p.statsConn.(*govpp.StatsConnection) == nil {
if p.statsConn == nil {
return nil
}
return p.statsConn.GetErrorStats(stats)
}

// GetErrorStats retrieves VPP error counters
// GetBufferStats retrieves VPP error counters
func (p *Plugin) GetBufferStats(stats *govppapi.BufferStats) error {
if p.statsConn == nil || p.statsConn.(*govpp.StatsConnection) == nil {
if p.statsConn == nil {
return nil
}
return p.statsConn.GetBufferStats(stats)
Expand Down
4 changes: 4 additions & 0 deletions plugins/govppmux/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ type Config struct {
// Time between connection request resend attempts. Default is 1s.
RetryConnectTimeout time.Duration `json:"retry-connect-timeout"`

// Enable VPP proxy.
ProxyEnabled bool `json:"proxy-enabled"`

// Below are options used for VPP connection health checking.
HealthCheckProbeInterval time.Duration `json:"health-check-probe-interval"`
HealthCheckReplyTimeout time.Duration `json:"health-check-reply-timeout"`
Expand All @@ -66,6 +69,7 @@ func DefaultConfig() *Config {
ReplyTimeout: time.Second,
RetryRequestTimeout: 500 * time.Millisecond,
RetryConnectTimeout: time.Second,
ProxyEnabled: true,
}
}

Expand Down
3 changes: 3 additions & 0 deletions plugins/govppmux/govpp.conf
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ retry-connect-count: 3

# Defines time in nanoseconds between VPP connection retries (default is 1 second).
retry-connect-timeout: 1s

# Enable VPP proxy.
proxy-enabled: true
Loading

0 comments on commit 0e2148d

Please sign in to comment.