Skip to content

Commit

Permalink
add ABF to config data model (#1356)
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Lavor <[email protected]>
  • Loading branch information
VladoLavor authored and ondrej-fabry committed May 27, 2019
1 parent aac8a20 commit 888c3d3
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 42 deletions.
94 changes: 52 additions & 42 deletions api/models/vpp/vpp.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions api/models/vpp/vpp.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package vpp;

option go_package = "github.com/ligato/vpp-agent/api/models/vpp;vpp";

import "models/vpp/abf/abf.proto";
import "models/vpp/acl/acl.proto";
import "models/vpp/interfaces/interface.proto";
import "models/vpp/interfaces/state.proto";
Expand All @@ -21,6 +22,7 @@ message ConfigData {
repeated interfaces.Interface interfaces = 10;

repeated acl.ACL acls = 20;
repeated abf.ABF abfs = 21;

repeated l2.BridgeDomain bridge_domains = 30;
repeated l2.FIBEntry fibs = 31;
Expand Down
2 changes: 2 additions & 0 deletions api/models/vpp/vpp_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package vpp

import (
"github.com/ligato/vpp-agent/api/models/vpp/abf"
"github.com/ligato/vpp-agent/api/models/vpp/acl"
"github.com/ligato/vpp-agent/api/models/vpp/interfaces"
"github.com/ligato/vpp-agent/api/models/vpp/ipsec"
Expand All @@ -28,6 +29,7 @@ import (
type (
// ACL
ACL = vpp_acl.ACL
ABF = vpp_abf.ABF

// Interfaces
Interface = vpp_interfaces.Interface
Expand Down
13 changes: 13 additions & 0 deletions cmd/agentctl/utils/db_read_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/gogo/protobuf/proto"

"github.com/ligato/cn-infra/db/keyval"
abf "github.com/ligato/vpp-agent/api/models/vpp/abf"
acl "github.com/ligato/vpp-agent/api/models/vpp/acl"
interfaces "github.com/ligato/vpp-agent/api/models/vpp/interfaces"
ipsec "github.com/ligato/vpp-agent/api/models/vpp/ipsec"
Expand Down Expand Up @@ -102,6 +103,8 @@ func (ed EtcdDump) ReadDataFromDb(db keyval.ProtoBroker, key string,
switch {
case strings.HasPrefix(key, acl.ModelACL.KeyPrefix()):
ed[agent], err = readACLConfigFromDb(db, vd, key)
case strings.HasPrefix(key, abf.ModelABF.KeyPrefix()):
ed[agent], err = readABFConfigFromDb(db, vd, key)
case strings.HasPrefix(key, interfaces.ModelInterface.KeyPrefix()):
ed[agent], err = readInterfaceConfigFromDb(db, vd, key)
case strings.HasPrefix(key, l2.ModelBridgeDomain.KeyPrefix()):
Expand Down Expand Up @@ -165,6 +168,16 @@ func readACLConfigFromDb(db keyval.ProtoBroker, vd *VppData, key string) (*VppDa
return vd, err
}

func readABFConfigFromDb(db keyval.ProtoBroker, vd *VppData, key string) (*VppData, error) {
abf := &abf.ABF{}

found, _, err := readDataFromDb(db, key, abf)
if found && err == nil {
vd.Config.VppConfig.Abfs = append(vd.Config.VppConfig.Abfs, abf)
}
return vd, err
}

func readInterfaceConfigFromDb(db keyval.ProtoBroker, vd *VppData, key string) (*VppData, error) {
int := &interfaces.Interface{}

Expand Down
26 changes: 26 additions & 0 deletions plugins/configurator/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"golang.org/x/net/context"

rpc "github.com/ligato/vpp-agent/api/configurator"
vpp_abf "github.com/ligato/vpp-agent/api/models/vpp/abf"
vpp_acl "github.com/ligato/vpp-agent/api/models/vpp/acl"
vpp_interfaces "github.com/ligato/vpp-agent/api/models/vpp/interfaces"
vpp_ipsec "github.com/ligato/vpp-agent/api/models/vpp/ipsec"
Expand All @@ -14,6 +15,7 @@ import (
vpp_punt "github.com/ligato/vpp-agent/api/models/vpp/punt"
iflinuxcalls "github.com/ligato/vpp-agent/plugins/linux/ifplugin/linuxcalls"
l3linuxcalls "github.com/ligato/vpp-agent/plugins/linux/l3plugin/linuxcalls"
abfvppcalls "github.com/ligato/vpp-agent/plugins/vpp/abfplugin/vppcalls"
aclvppcalls "github.com/ligato/vpp-agent/plugins/vpp/aclplugin/vppcalls"
ifvppcalls "github.com/ligato/vpp-agent/plugins/vpp/ifplugin/vppcalls"
ipsecvppcalls "github.com/ligato/vpp-agent/plugins/vpp/ipsecplugin/vppcalls"
Expand All @@ -28,6 +30,7 @@ type dumpService struct {

// VPP Handlers
aclHandler aclvppcalls.ACLVppRead
abfHandler abfvppcalls.ABFVppRead
ifHandler ifvppcalls.InterfaceVppRead
natHandler natvppcalls.NatVppRead
l2Handler l2vppcalls.L2VppAPI
Expand Down Expand Up @@ -58,6 +61,11 @@ func (svc *dumpService) Dump(context.Context, *rpc.DumpRequest) (*rpc.DumpRespon
svc.log.Errorf("DumpAcls failed: %v", err)
return nil, err
}
dump.VppConfig.Abfs, err = svc.DumpAbfs()
if err != nil {
svc.log.Errorf("DumpAbfs failed: %v", err)
return nil, err
}
dump.VppConfig.IpsecSpds, err = svc.DumpIPSecSPDs()
if err != nil {
svc.log.Errorf("DumpIPSecSPDs failed: %v", err)
Expand Down Expand Up @@ -130,6 +138,24 @@ func (svc *dumpService) DumpAcls() ([]*vpp_acl.ACL, error) {
return acls, nil
}

// DumpAbfs reads the ACL-based forwarding and returns data read as an *AbfResponse. If the reading ends up with
// an error, only the error is send back in the response
func (svc *dumpService) DumpAbfs() ([]*vpp_abf.ABF, error) {
var abfs []*vpp_abf.ABF
if svc.abfHandler == nil {
return nil, errors.New("abfHandler is not available")
}
abfPolicy, err := svc.abfHandler.DumpABFPolicy()
if err != nil {
return nil, err
}
for _, abfDetails := range abfPolicy {
abfs = append(abfs, abfDetails.ABF)
}

return abfs, nil
}

// DumpInterfaces reads interfaces and returns them as an *InterfaceResponse. If reading ends up with error,
// only error is send back in response
func (svc *dumpService) DumpInterfaces() ([]*vpp_interfaces.Interface, error) {
Expand Down

0 comments on commit 888c3d3

Please sign in to comment.