Skip to content

Commit

Permalink
API for SPAN (#1430)
Browse files Browse the repository at this point in the history
* Add SPAN VPP calls

* Add model and descriptor for SPAN

* Update client to support SPAN feature

* Add example for SPAN

* Add test to check bad configuration. Change to table tests structure

* Add vppcalls for 1901 and 1908

* Fix dump to return SPANs with L2 set too

* Add debug logs

* Name vpp-span is better for descriptor. Fix: interfaces must be dumped before SPANs

* Rename SPAN State to Direction. Minor improvements

* fix tests after rename
  • Loading branch information
rewenset authored and ondrej-fabry committed Aug 19, 2019
1 parent 2fd89dd commit e8fa2f9
Show file tree
Hide file tree
Showing 26 changed files with 1,760 additions and 0 deletions.
15 changes: 15 additions & 0 deletions api/models/vpp/interfaces/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ var (
Version: "v2",
Type: "interfaces",
})

ModelSpan = models.Register(&Span{}, models.Spec{
Module: ModuleName,
Version: "v2",
Type: "span",
}, models.WithNameTemplate("{{.InterfaceFrom}}/to/{{.InterfaceTo}}"))
)

// InterfaceKey returns the key used in NB DB to store the configuration of the
Expand All @@ -43,6 +49,15 @@ func InterfaceKey(name string) string {
})
}

// SpanKey returns the key used in NB DB to store the configuration of the
// given vpp span.
func SpanKey(ifaceFrom, ifaceTo string) string {
return models.Key(&Span{
InterfaceFrom: ifaceFrom,
InterfaceTo: ifaceTo,
})
}

/* Interface State */
const (
// StatePrefix is a key prefix used in NB DB to store interface states.
Expand Down
147 changes: 147 additions & 0 deletions api/models/vpp/interfaces/span.pb.go

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

21 changes: 21 additions & 0 deletions api/models/vpp/interfaces/span.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
syntax = "proto3";

package vpp.interfaces;

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

import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.messagename_all) = true;

message Span {
enum Direction {
UNKNOWN = 0;
RX = 1;
TX = 2;
BOTH = 3;
};
string interface_from = 1;
string interface_to = 2;
Direction direction = 3;
bool is_l2 = 4;
}
4 changes: 4 additions & 0 deletions clientv2/linux/data_change_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ type PutDSL interface {

// VppInterface adds a request to create or update VPP network interface.
VppInterface(val *vpp_interfaces.Interface) PutDSL
// Span adds VPP span to the Put request.
Span(span *vpp_interfaces.Span) PutDSL
// ACL adds a request to create or update VPP Access Control List.
ACL(acl *vpp_acl.ACL) PutDSL
// ABF adds a request to create or update VPP ACL-based forwarding.
Expand Down Expand Up @@ -136,6 +138,8 @@ type DeleteDSL interface {

// VppInterface adds a request to delete an existing VPP network interface.
VppInterface(ifaceName string) DeleteDSL
// Span adds VPP span to the Delete request.
Span(span *vpp_interfaces.Span) DeleteDSL
// ACL adds a request to delete an existing VPP Access Control List.
ACL(aclName string) DeleteDSL
// ABF adds a request to delete an existing VPP ACL-based forwarding.
Expand Down
2 changes: 2 additions & 0 deletions clientv2/linux/data_resync_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ type DataResyncDSL interface {

// VppInterface adds VPP interface to the RESYNC request.
VppInterface(intf *vpp_interfaces.Interface) DataResyncDSL
// Span adds VPP span to the RESYNC request.
Span(span *vpp_interfaces.Span) DataResyncDSL
// ACL adds VPP Access Control List to the RESYNC request.
ACL(acl *vpp_acl.ACL) DataResyncDSL
// ABF adds ACL-based forwarding to the RESYNC request.
Expand Down
12 changes: 12 additions & 0 deletions clientv2/linux/dbadapter/data_change_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ func (dsl *PutDSL) VppInterface(val *interfaces.Interface) linuxclient.PutDSL {
return dsl
}

// Span adds a request to create or update VPP SPAN.
func (dsl *PutDSL) Span(val *interfaces.Span) linuxclient.PutDSL {
dsl.vppPut.Span(val)
return dsl
}

// ACL adds a request to create or update VPP Access Control List.
func (dsl *PutDSL) ACL(acl *acl.ACL) linuxclient.PutDSL {
dsl.vppPut.ACL(acl)
Expand Down Expand Up @@ -279,6 +285,12 @@ func (dsl *DeleteDSL) VppInterface(ifaceName string) linuxclient.DeleteDSL {
return dsl
}

// Span adds a request to delete VPP SPAN.
func (dsl *DeleteDSL) Span(val *interfaces.Span) linuxclient.DeleteDSL {
dsl.vppDelete.Span(val)
return dsl
}

// ACL adds a request to delete an existing VPP Access Control List.
func (dsl *DeleteDSL) ACL(aclName string) linuxclient.DeleteDSL {
dsl.vppDelete.ACL(aclName)
Expand Down
6 changes: 6 additions & 0 deletions clientv2/linux/dbadapter/data_resync_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ func (dsl *DataResyncDSL) VppInterface(intf *interfaces.Interface) linuxclient.D
return dsl
}

// Span adds VPP span to the RESYNC request.
func (dsl *DataResyncDSL) Span(span *interfaces.Span) linuxclient.DataResyncDSL {
dsl.vppDataResync.Span(span)
return dsl
}

// ACL adds VPP Access Control List to the RESYNC request.
func (dsl *DataResyncDSL) ACL(acl *acl.ACL) linuxclient.DataResyncDSL {
dsl.vppDataResync.ACL(acl)
Expand Down
4 changes: 4 additions & 0 deletions clientv2/vpp/data_change_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ type DataChangeDSL interface {
type PutDSL interface {
// Interface adds a request to create or update VPP network interface.
Interface(val *interfaces.Interface) PutDSL
// Span adds VPP span to the Put request.
Span(span *interfaces.Span) PutDSL
// ACL adds a request to create or update VPP Access Control List.
ACL(acl *acl.ACL) PutDSL
// ABF adds a request to create or update VPP ACL-based forwarding.
Expand Down Expand Up @@ -105,6 +107,8 @@ type PutDSL interface {
type DeleteDSL interface {
// Interface adds a request to delete an existing VPP network interface.
Interface(ifaceName string) DeleteDSL
// Span adds VPP span to the Delete request.
Span(span *interfaces.Span) DeleteDSL
// ACL adds a request to delete an existing VPP Access Control List.
ACL(aclName string) DeleteDSL
// ABF adds a request to delete and existing VPP Access Control List.
Expand Down
2 changes: 2 additions & 0 deletions clientv2/vpp/data_resync_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import (
type DataResyncDSL interface {
// Interface adds interface to the RESYNC request.
Interface(intf *interfaces.Interface) DataResyncDSL
// Span adds span to the RESYNC request.
Span(intf *interfaces.Span) DataResyncDSL
// ACL adds Access Control List to the RESYNC request.
ACL(acl *acl.ACL) DataResyncDSL
// ABF adds ACL-based forwarding to the RESYNC request.
Expand Down
14 changes: 14 additions & 0 deletions clientv2/vpp/dbadapter/data_change_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ func (dsl *PutDSL) Interface(val *intf.Interface) vppclient.PutDSL {
return dsl
}

// Span adds VPP span to the change request.
func (dsl *PutDSL) Span(val *intf.Span) vppclient.PutDSL {
key := intf.SpanKey(val.InterfaceFrom, val.InterfaceTo)
dsl.parent.txn.Put(key, val)
return dsl
}

// ACL adds a request to create or update VPP Access Control List.
func (dsl *PutDSL) ACL(val *acl.ACL) vppclient.PutDSL {
dsl.parent.txn.Put(acl.Key(val.Name), val)
Expand Down Expand Up @@ -203,6 +210,13 @@ func (dsl *DeleteDSL) Interface(interfaceName string) vppclient.DeleteDSL {
return dsl
}

// Span adds VPP span to the RESYNC request.
func (dsl *DeleteDSL) Span(val *intf.Span) vppclient.DeleteDSL {
key := intf.SpanKey(val.InterfaceFrom, val.InterfaceTo)
dsl.parent.txn.Delete(key)
return dsl
}

// ACL adds a request to delete an existing VPP Access Control List.
func (dsl *DeleteDSL) ACL(aclName string) vppclient.DeleteDSL {
dsl.parent.txn.Delete(acl.Key(aclName))
Expand Down
9 changes: 9 additions & 0 deletions clientv2/vpp/dbadapter/data_resync_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ func (dsl *DataResyncDSL) Interface(val *intf.Interface) vppclient.DataResyncDSL
return dsl
}

// Span adds VPP span to the RESYNC request.
func (dsl *DataResyncDSL) Span(val *intf.Span) vppclient.DataResyncDSL {
key := intf.SpanKey(val.InterfaceFrom, val.InterfaceTo)
dsl.txn.Put(key, val)
dsl.txnKeys = append(dsl.txnKeys, key)

return dsl
}

// ACL adds Access Control List to the RESYNC request.
func (dsl *DataResyncDSL) ACL(val *acl.ACL) vppclient.DataResyncDSL {
key := acl.Key(val.Name)
Expand Down
Loading

0 comments on commit e8fa2f9

Please sign in to comment.