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 6 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
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
}
29 changes: 18 additions & 11 deletions plugins/vpp/abfplugin/vppcalls/vpp1908/dump_abf_vppcalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,12 @@ func (h *ABFVppHandler) dumpABFPolicy() ([]*vppcalls.ABFDetails, error) {

// base fields
fwdPath := &vpp_abf.ABF_ForwardingPath{
NextHopIp: parseNextHopToString(path.NextHop, path.Afi),
NextHopIp: parseNextHopToString(path.Nh, path.Proto),
InterfaceName: ifName,
Weight: uint32(path.Weight),
Preference: uint32(path.Preference),
Dvr: uintToBool(path.IsDvr),
Dvr: isDvr(path.Type),
}

fwdPaths = append(fwdPaths, fwdPath)
}

Expand All @@ -149,19 +148,27 @@ func (h *ABFVppHandler) dumpABFPolicy() ([]*vppcalls.ABFDetails, error) {
return abfs, nil
}

// Parses IP address to string. IP version is read from 'afi' where 1==IPv4 and 2==IPv6
func parseNextHopToString(nh []byte, IPv uint8) string {
var nhIP net.IP = nh
if IPv == 1 {
return nhIP[:4].To4().String()
// returns next hop IP address
func parseNextHopToString(nh abf.FibPathNh, proto abf.FibPathNhProto) string {
if proto == abf.FIB_API_PATH_NH_PROTO_IP4 {
addr := nh.Address.GetIP4()
return net.IP(addr[:]).To4().String()
}
if IPv == 2 {
return nhIP.To16().String()
if proto == abf.FIB_API_PATH_NH_PROTO_IP6 {
addr := nh.Address.GetIP6()
return net.IP(addr[:]).To16().String()
}

return ""
}

// abf fib currently supports only DVR or normal mode
func isDvr(pathType abf.FibPathType) (isDvr bool) {
if pathType == abf.FIB_API_PATH_TYPE_DVR {
return true
}
return false
}

func uintToBool(value uint8) bool {
if value == 0 {
return false
Expand Down
11 changes: 7 additions & 4 deletions plugins/vpp/abfplugin/vppcalls/vpp1908/vppcalls_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package vpp1908

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["vpp1908"] = 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,
}
}
Loading