Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vpp19.08 updated to rc0.581-g3eea9de89 #1407

Merged
merged 9 commits into from
Jul 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/vpp-agent-ctl/data/ifplugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func (ctl *VppAgentCtlImpl) PutTap() error {
Link: &interfaces.Interface_Tap{
Tap: &interfaces.TapLink{
HostIfName: "tap-host",
Version: 2,
},
},
}
Expand Down
25 changes: 25 additions & 0 deletions cmd/vpp-agent-ctl/data/l3plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ type L3Ctl interface {
SetIPScanNeigh() error
// UnsetIPScanNeigh removes VPP IP scan neighbor configuration from the ETCD
UnsetIPScanNeigh() error
// PutVrf puts VPP VRF to the ETCD
PutVrf() error
// UnsetVrf removes VPP VRF configuration from the ETCD
DeleteVrf() error
// CreateLinuxArp puts linux ARP entry configuration to the ETCD
PutLinuxArp() error
// DeleteLinuxArp removes Linux ARP entry configuration from the ETCD
Expand Down Expand Up @@ -243,6 +247,27 @@ func (ctl *VppAgentCtlImpl) UnsetIPScanNeigh() error {
return err
}

// PutVrf puts VPP VRF to the ETCD
func (ctl *VppAgentCtlImpl) PutVrf() error {
vrf := &l3.VrfTable{
Label: "vrf1",
Id: 1,
Protocol: l3.VrfTable_IPV4,
}

ctl.Log.Info("VRF set")
return ctl.broker.Put(l3.VrfTableKey(vrf.Id, vrf.Protocol), vrf)
}

// DeleteVrf removes VPP VRF configuration from the ETCD
func (ctl *VppAgentCtlImpl) DeleteVrf() error {
vrf := l3.VrfTableKey(1, l3.VrfTable_IPV4)

ctl.Log.Info("VRF unset")
_, err := ctl.broker.Delete(vrf)
return err
}

// PutLinuxArp puts linux ARP entry configuration to the ETCD
func (ctl *VppAgentCtlImpl) PutLinuxArp() error {
linuxArp := &linuxL3.ARPEntry{
Expand Down
4 changes: 4 additions & 0 deletions cmd/vpp-agent-ctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ func do(ctl data.VppAgentCtl) {
err = ctl.SetIPScanNeigh()
case "-ipscand":
err = ctl.UnsetIPScanNeigh()
case "-vrf":
err = ctl.PutVrf()
case "-vrfd":
err = ctl.DeleteVrf()
// Linux L3 plugin
case "-lroute":
err = ctl.PutLinuxRoute()
Expand Down
2 changes: 2 additions & 0 deletions plugins/configurator/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/ligato/vpp-agent/plugins/vpp/aclplugin"
"github.com/ligato/vpp-agent/plugins/vpp/ifplugin"
"github.com/ligato/vpp-agent/plugins/vpp/l2plugin"
"github.com/ligato/vpp-agent/plugins/vpp/l3plugin"
)

// DefaultPlugin is default instance of Plugin
Expand All @@ -37,6 +38,7 @@ func NewPlugin(opts ...Option) *Plugin {
p.VPPACLPlugin = &aclplugin.DefaultPlugin
p.VPPIfPlugin = &ifplugin.DefaultPlugin
p.VPPL2Plugin = &l2plugin.DefaultPlugin
p.VPPL3Plugin = &l3plugin.DefaultPlugin

for _, o := range opts {
o(p)
Expand Down
5 changes: 4 additions & 1 deletion plugins/configurator/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
ipsecvppcalls "github.com/ligato/vpp-agent/plugins/vpp/ipsecplugin/vppcalls"
"github.com/ligato/vpp-agent/plugins/vpp/l2plugin"
l2vppcalls "github.com/ligato/vpp-agent/plugins/vpp/l2plugin/vppcalls"
"github.com/ligato/vpp-agent/plugins/vpp/l3plugin"
l3vppcalls "github.com/ligato/vpp-agent/plugins/vpp/l3plugin/vppcalls"
natvppcalls "github.com/ligato/vpp-agent/plugins/vpp/natplugin/vppcalls"
puntvppcalls "github.com/ligato/vpp-agent/plugins/vpp/puntplugin/vppcalls"
Expand All @@ -59,6 +60,7 @@ type Deps struct {
VPPACLPlugin aclplugin.API
VPPIfPlugin ifplugin.API
VPPL2Plugin *l2plugin.L2Plugin
VPPL3Plugin l3plugin.API
}

// Init sets plugin child loggers
Expand Down Expand Up @@ -107,6 +109,7 @@ func (p *Plugin) initHandlers() (err error) {
dhcpIndexes := p.VPPIfPlugin.GetDHCPIndex()
bdIndexes := p.VPPL2Plugin.GetBDIndex()
aclIndexes := p.VPPACLPlugin.GetACLIndex() // TODO: make ACL optional
vrfIndexes := p.VPPL3Plugin.GetVRFIndex()

// VPP handlers

Expand All @@ -119,7 +122,7 @@ func (p *Plugin) initHandlers() (err error) {
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, p.Log)
p.configurator.l3Handler = l3vppcalls.CompatibleL3VppHandler(p.vppChan, ifIndexes, vrfIndexes, p.Log)
if p.configurator.l3Handler == nil {
p.Log.Info("VPP L3 handler is not available, it will be skipped")
}
Expand Down
2 changes: 2 additions & 0 deletions plugins/restapi/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package restapi

import (
"github.com/ligato/cn-infra/rpc/rest"
"github.com/ligato/vpp-agent/plugins/vpp/l3plugin"

"github.com/ligato/vpp-agent/plugins/govppmux"
"github.com/ligato/vpp-agent/plugins/vpp/aclplugin"
Expand All @@ -36,6 +37,7 @@ func NewPlugin(opts ...Option) *Plugin {
p.VPPACLPlugin = &aclplugin.DefaultPlugin
p.VPPIfPlugin = &ifplugin.DefaultPlugin
p.VPPL2Plugin = &l2plugin.DefaultPlugin
p.VPPL3Plugin = &l3plugin.DefaultPlugin

for _, o := range opts {
o(p)
Expand Down
5 changes: 4 additions & 1 deletion plugins/restapi/plugin_restapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
ipsecvppcalls "github.com/ligato/vpp-agent/plugins/vpp/ipsecplugin/vppcalls"
"github.com/ligato/vpp-agent/plugins/vpp/l2plugin"
l2vppcalls "github.com/ligato/vpp-agent/plugins/vpp/l2plugin/vppcalls"
"github.com/ligato/vpp-agent/plugins/vpp/l3plugin"
l3vppcalls "github.com/ligato/vpp-agent/plugins/vpp/l3plugin/vppcalls"
natvppcalls "github.com/ligato/vpp-agent/plugins/vpp/natplugin/vppcalls"
puntvppcalls "github.com/ligato/vpp-agent/plugins/vpp/puntplugin/vppcalls"
Expand Down Expand Up @@ -86,6 +87,7 @@ type Deps struct {
VPPACLPlugin aclplugin.API
VPPIfPlugin ifplugin.API
VPPL2Plugin *l2plugin.L2Plugin
VPPL3Plugin *l3plugin.L3Plugin
}

// index defines map of main index page entries
Expand All @@ -111,6 +113,7 @@ func (p *Plugin) Init() (err error) {
bdIndexes := p.VPPL2Plugin.GetBDIndex()
dhcpIndexes := p.VPPIfPlugin.GetDHCPIndex()
aclIndexes := p.VPPACLPlugin.GetACLIndex() // TODO: make ACL optional
vrfIndexes := p.VPPL3Plugin.GetVRFIndex()

// Initialize VPP handlers
p.vpeHandler = vpevppcalls.CompatibleVpeHandler(p.vppChan)
Expand All @@ -131,7 +134,7 @@ func (p *Plugin) Init() (err error) {
if p.l2Handler == nil {
p.Log.Info("VPP L2 handler is not available, it will be skipped")
}
p.l3Handler = l3vppcalls.CompatibleL3VppHandler(p.vppChan, ifIndexes, p.Log)
p.l3Handler = l3vppcalls.CompatibleL3VppHandler(p.vppChan, ifIndexes, vrfIndexes, p.Log)
if p.l3Handler == nil {
p.Log.Info("VPP L3 handler is not available, it will be skipped")
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/vpp/abfplugin/vppcalls/abf_vppcalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ var Versions = map[string]HandlerVersion{}

type HandlerVersion struct {
Msgs []govppapi.Message
New func(govppapi.Channel, aclidx.ACLMetadataIndex, ifaceidx.IfaceMetadataIndex) ABFVppAPI
New func(govppapi.Channel, aclidx.ACLMetadataIndex, ifaceidx.IfaceMetadataIndex, logging.Logger) ABFVppAPI
}

func CompatibleABFVppHandler(ch govppapi.Channel, aclIdx aclidx.ACLMetadataIndex, ifIdx ifaceidx.IfaceMetadataIndex, log logging.Logger) ABFVppAPI {
Expand All @@ -77,7 +77,7 @@ func CompatibleABFVppHandler(ch govppapi.Channel, aclIdx aclidx.ACLMetadataIndex
continue
}
log.Debug("found compatible version:", ver)
return h.New(ch, aclIdx, ifIdx)
return h.New(ch, aclIdx, ifIdx, log)
}
panic("no compatible version available")
}
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,6 @@ func abfTestSetup(t *testing.T) (*vppcallmock.TestCtx, vppcalls.ABFVppAPI, iface
log := logrus.NewLogger("test-log")
aclIdx := aclidx.NewACLIndex(log, "acl-index")
ifIdx := ifaceidx.NewIfaceIndex(log, "if-index")
abfHandler := NewABFVppHandler(ctx.MockChannel, aclIdx, ifIdx)
abfHandler := NewABFVppHandler(ctx.MockChannel, aclIdx, ifIdx, log)
return ctx, abfHandler, ifIdx
}
11 changes: 7 additions & 4 deletions plugins/vpp/abfplugin/vppcalls/vpp1901/vppcalls_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package vpp1901

import (
govppapi "git.fd.io/govpp.git/api"
"github.com/ligato/cn-infra/logging"

"github.com/ligato/vpp-agent/plugins/vpp/abfplugin/vppcalls"
"github.com/ligato/vpp-agent/plugins/vpp/aclplugin/aclidx"
Expand All @@ -29,24 +30,26 @@ func init() {

vppcalls.Versions["vpp1901"] = vppcalls.HandlerVersion{
Msgs: msgs,
New: func(ch govppapi.Channel, aclIndexes aclidx.ACLMetadataIndex, ifIndexes ifaceidx.IfaceMetadataIndex) vppcalls.ABFVppAPI {
return NewABFVppHandler(ch, aclIndexes, ifIndexes)
New: func(ch govppapi.Channel, aclIndexes aclidx.ACLMetadataIndex, ifIndexes ifaceidx.IfaceMetadataIndex, log logging.Logger) vppcalls.ABFVppAPI {
return NewABFVppHandler(ch, aclIndexes, ifIndexes, log)
},
}
}

// ABFVppHandler is accessor for abfrelated vppcalls methods
// ABFVppHandler is accessor for abf-related vppcalls methods
type ABFVppHandler struct {
callsChannel govppapi.Channel
aclIndexes aclidx.ACLMetadataIndex
ifIndexes ifaceidx.IfaceMetadataIndex
log logging.Logger
}

// NewABFVppHandler returns new ABFVppHandler.
func NewABFVppHandler(calls govppapi.Channel, aclIdx aclidx.ACLMetadataIndex, ifIdx ifaceidx.IfaceMetadataIndex) *ABFVppHandler {
func NewABFVppHandler(calls govppapi.Channel, aclIdx aclidx.ACLMetadataIndex, ifIdx ifaceidx.IfaceMetadataIndex, log logging.Logger) *ABFVppHandler {
return &ABFVppHandler{
callsChannel: calls,
aclIndexes: aclIdx,
ifIndexes: ifIdx,
log: log,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,6 @@ func abfTestSetup(t *testing.T) (*vppcallmock.TestCtx, vppcalls.ABFVppAPI, iface
log := logrus.NewLogger("test-log")
aclIdx := aclidx.NewACLIndex(log, "acl-index")
ifIdx := ifaceidx.NewIfaceIndex(log, "if-index")
abfHandler := NewABFVppHandler(ctx.MockChannel, aclIdx, ifIdx)
abfHandler := NewABFVppHandler(ctx.MockChannel, aclIdx, ifIdx, log)
return ctx, abfHandler, ifIdx
}
11 changes: 7 additions & 4 deletions plugins/vpp/abfplugin/vppcalls/vpp1904/vppcalls_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package vpp1904

import (
govppapi "git.fd.io/govpp.git/api"
"github.com/ligato/cn-infra/logging"

"github.com/ligato/vpp-agent/plugins/vpp/abfplugin/vppcalls"
"github.com/ligato/vpp-agent/plugins/vpp/aclplugin/aclidx"
Expand All @@ -29,24 +30,26 @@ func init() {

vppcalls.Versions["vpp1904"] = vppcalls.HandlerVersion{
Msgs: msgs,
New: func(ch govppapi.Channel, aclIndexes aclidx.ACLMetadataIndex, ifIndexes ifaceidx.IfaceMetadataIndex) vppcalls.ABFVppAPI {
return NewABFVppHandler(ch, aclIndexes, ifIndexes)
New: func(ch govppapi.Channel, aclIndexes aclidx.ACLMetadataIndex, ifIndexes ifaceidx.IfaceMetadataIndex, log logging.Logger) vppcalls.ABFVppAPI {
return NewABFVppHandler(ch, aclIndexes, ifIndexes, log)
},
}
}

// ABFVppHandler is accessor for abfrelated vppcalls methods
// ABFVppHandler is accessor for abf-related vppcalls methods
type ABFVppHandler struct {
callsChannel govppapi.Channel
aclIndexes aclidx.ACLMetadataIndex
ifIndexes ifaceidx.IfaceMetadataIndex
log logging.Logger
}

// NewABFVppHandler returns new ABFVppHandler.
func NewABFVppHandler(calls govppapi.Channel, aclIdx aclidx.ACLMetadataIndex, ifIdx ifaceidx.IfaceMetadataIndex) *ABFVppHandler {
func NewABFVppHandler(calls govppapi.Channel, aclIdx aclidx.ACLMetadataIndex, ifIdx ifaceidx.IfaceMetadataIndex, log logging.Logger) *ABFVppHandler {
return &ABFVppHandler{
callsChannel: calls,
aclIndexes: aclIdx,
ifIndexes: ifIdx,
log: log,
}
}
59 changes: 47 additions & 12 deletions plugins/vpp/abfplugin/vppcalls/vpp1908/abf_vppcalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ import (
"github.com/ligato/vpp-agent/plugins/vpp/binapi/vpp1908/abf"
)

const (
// NextHopViaLabelUnset constant has to be assigned into the field next hop via label
// in abf_policy_add_del binary message if next hop via label is not defined.
NextHopViaLabelUnset uint32 = 0xfffff + 1

// ClassifyTableIndexUnset is a default value for field classify_table_index
// in abf_policy_add_del binary message.
ClassifyTableIndexUnset = ^uint32(0)
)

// GetAbfVersion retrieves version of the VPP ABF plugin
func (h *ABFVppHandler) GetAbfVersion() (ver string, err error) {
req := &abf.AbfPluginGetVersion{}
Expand Down Expand Up @@ -115,6 +125,7 @@ func (h *ABFVppHandler) abfAddDelPolicy(policyID, aclID uint32, abfPaths []*vpp_
}

func (h *ABFVppHandler) toFibPaths(abfPaths []*vpp_abf.ABF_ForwardingPath) (fibPaths []abf.FibPath) {
var err error
for _, abfPath := range abfPaths {
// fib path interface
ifData, exists := h.ifIndexes.LookupByName(abfPath.InterfaceName)
Expand All @@ -126,26 +137,50 @@ func (h *ABFVppHandler) toFibPaths(abfPaths []*vpp_abf.ABF_ForwardingPath) (fibP
SwIfIndex: ifData.SwIfIndex,
Weight: uint8(abfPath.Weight),
Preference: uint8(abfPath.Preference),
IsDvr: boolToUint(abfPath.Dvr),
Type: setFibPathType(abfPath.Dvr),
}

// next hop IP
nextHop := net.ParseIP(abfPath.NextHopIp)
if nextHop.To4() == nil {
nextHop = nextHop.To16()
fibPath.Afi = 1
} else {
nextHop = nextHop.To4()
fibPath.Afi = 0
if fibPath.Nh, fibPath.Proto, err = setFibPathNhAndProto(abfPath.NextHopIp); err != nil {
h.log.Errorf("ABF path next hop error: %v", err)
}
fibPath.NextHop = nextHop

fibPaths = append(fibPaths, fibPath)
}

return fibPaths
}

// supported cases are DVR and normal
func setFibPathType(isDvr bool) abf.FibPathType {
if isDvr {
return abf.FIB_API_PATH_TYPE_DVR
}
return abf.FIB_API_PATH_TYPE_NORMAL
}

// resolve IP address and return FIB path next hop (IP address) and IPv4/IPv6 version
func setFibPathNhAndProto(ipStr string) (nh abf.FibPathNh, proto abf.FibPathNhProto, err error) {
netIP := net.ParseIP(ipStr)
if netIP == nil {
return nh, proto, errors.Errorf("failed to parse next hop IP address %s", ipStr)
}
var au abf.AddressUnion
if ipv4 := netIP.To4(); ipv4 == nil {
var address abf.IP6Address
proto = abf.FIB_API_PATH_NH_PROTO_IP6
copy(address[:], netIP[:])
au.SetIP6(address)
} else {
var address abf.IP4Address
proto = abf.FIB_API_PATH_NH_PROTO_IP4
copy(address[:], netIP[12:])
au.SetIP4(address)
}
return abf.FibPathNh{
Address: au,
ViaLabel: NextHopViaLabelUnset,
ClassifyTableIndex: ClassifyTableIndexUnset,
}, proto, nil
}

func boolToUint(input bool) uint8 {
if input {
return 1
Expand Down
10 changes: 5 additions & 5 deletions plugins/vpp/abfplugin/vppcalls/vpp1908/abf_vppcalls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ func TestAddABFPolicy(t *testing.T) {
Expect(req.Policy.ACLIndex).To(Equal(uint32(2)))
Expect(req.Policy.NPaths).To(Equal(uint8(2)))
Expect(req.Policy.Paths[0].SwIfIndex).To(Equal(uint32(5)))
Expect(req.Policy.Paths[0].NextHop[:4]).To(BeEquivalentTo(net.ParseIP("10.0.0.1").To4()))
Expect(req.Policy.Paths[0].Nh.Address.GetIP4()).To(BeEquivalentTo(abf.IP4Address([4]uint8{10, 0, 0, 1})))
Expect(req.Policy.Paths[1].SwIfIndex).To(Equal(uint32(10)))
Expect(req.Policy.Paths[1].NextHop).To(BeEquivalentTo(net.ParseIP("ffff::").To16()))
Expect(req.Policy.Paths[1].Nh.Address.GetIP6()).To(BeEquivalentTo(abf.IP6Address([16]uint8{255, 255})))
}

func TestAddABFPolicyError(t *testing.T) {
Expand Down Expand Up @@ -124,9 +124,9 @@ func TestDeleteABFPolicy(t *testing.T) {
Expect(req.Policy.PolicyID).To(Equal(uint32(1)))
Expect(req.Policy.NPaths).To(Equal(uint8(2)))
Expect(req.Policy.Paths[0].SwIfIndex).To(Equal(uint32(5)))
Expect(req.Policy.Paths[0].NextHop[:4]).To(BeEquivalentTo(net.ParseIP("10.0.0.1").To4()))
Expect(req.Policy.Paths[0].Nh.Address.XXX_UnionData[:4]).To(BeEquivalentTo(net.ParseIP("10.0.0.1").To4()))
Expect(req.Policy.Paths[1].SwIfIndex).To(Equal(uint32(10)))
Expect(req.Policy.Paths[1].NextHop).To(BeEquivalentTo(net.ParseIP("ffff::").To16()))
Expect(req.Policy.Paths[1].Nh.Address.XXX_UnionData[:]).To(BeEquivalentTo(net.ParseIP("ffff::").To16()))
}

func TestDeleteABFPolicyError(t *testing.T) {
Expand Down Expand Up @@ -271,6 +271,6 @@ func abfTestSetup(t *testing.T) (*vppcallmock.TestCtx, vppcalls.ABFVppAPI, iface
log := logrus.NewLogger("test-log")
aclIdx := aclidx.NewACLIndex(log, "acl-index")
ifIdx := ifaceidx.NewIfaceIndex(log, "if-index")
abfHandler := NewABFVppHandler(ctx.MockChannel, aclIdx, ifIdx)
abfHandler := NewABFVppHandler(ctx.MockChannel, aclIdx, ifIdx, log)
return ctx, abfHandler, ifIdx
}
Loading