Skip to content

Commit e8fa2f9

Browse files
rewensetondrej-fabry
authored andcommitted
API for SPAN (ligato#1430)
* 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
1 parent 2fd89dd commit e8fa2f9

File tree

26 files changed

+1760
-0
lines changed

26 files changed

+1760
-0
lines changed

api/models/vpp/interfaces/keys.go

+15
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ var (
3333
Version: "v2",
3434
Type: "interfaces",
3535
})
36+
37+
ModelSpan = models.Register(&Span{}, models.Spec{
38+
Module: ModuleName,
39+
Version: "v2",
40+
Type: "span",
41+
}, models.WithNameTemplate("{{.InterfaceFrom}}/to/{{.InterfaceTo}}"))
3642
)
3743

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

52+
// SpanKey returns the key used in NB DB to store the configuration of the
53+
// given vpp span.
54+
func SpanKey(ifaceFrom, ifaceTo string) string {
55+
return models.Key(&Span{
56+
InterfaceFrom: ifaceFrom,
57+
InterfaceTo: ifaceTo,
58+
})
59+
}
60+
4661
/* Interface State */
4762
const (
4863
// StatePrefix is a key prefix used in NB DB to store interface states.

api/models/vpp/interfaces/span.pb.go

+147
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/models/vpp/interfaces/span.proto

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
syntax = "proto3";
2+
3+
package vpp.interfaces;
4+
5+
option go_package = "github.com/ligato/vpp-agent/api/models/vpp/interfaces;vpp_interfaces";
6+
7+
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
8+
option (gogoproto.messagename_all) = true;
9+
10+
message Span {
11+
enum Direction {
12+
UNKNOWN = 0;
13+
RX = 1;
14+
TX = 2;
15+
BOTH = 3;
16+
};
17+
string interface_from = 1;
18+
string interface_to = 2;
19+
Direction direction = 3;
20+
bool is_l2 = 4;
21+
}

clientv2/linux/data_change_api.go

+4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ type PutDSL interface {
6565

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

137139
// VppInterface adds a request to delete an existing VPP network interface.
138140
VppInterface(ifaceName string) DeleteDSL
141+
// Span adds VPP span to the Delete request.
142+
Span(span *vpp_interfaces.Span) DeleteDSL
139143
// ACL adds a request to delete an existing VPP Access Control List.
140144
ACL(aclName string) DeleteDSL
141145
// ABF adds a request to delete an existing VPP ACL-based forwarding.

clientv2/linux/data_resync_api.go

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ type DataResyncDSL interface {
4545

4646
// VppInterface adds VPP interface to the RESYNC request.
4747
VppInterface(intf *vpp_interfaces.Interface) DataResyncDSL
48+
// Span adds VPP span to the RESYNC request.
49+
Span(span *vpp_interfaces.Span) DataResyncDSL
4850
// ACL adds VPP Access Control List to the RESYNC request.
4951
ACL(acl *vpp_acl.ACL) DataResyncDSL
5052
// ABF adds ACL-based forwarding to the RESYNC request.

clientv2/linux/dbadapter/data_change_db.go

+12
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ func (dsl *PutDSL) VppInterface(val *interfaces.Interface) linuxclient.PutDSL {
103103
return dsl
104104
}
105105

106+
// Span adds a request to create or update VPP SPAN.
107+
func (dsl *PutDSL) Span(val *interfaces.Span) linuxclient.PutDSL {
108+
dsl.vppPut.Span(val)
109+
return dsl
110+
}
111+
106112
// ACL adds a request to create or update VPP Access Control List.
107113
func (dsl *PutDSL) ACL(acl *acl.ACL) linuxclient.PutDSL {
108114
dsl.vppPut.ACL(acl)
@@ -279,6 +285,12 @@ func (dsl *DeleteDSL) VppInterface(ifaceName string) linuxclient.DeleteDSL {
279285
return dsl
280286
}
281287

288+
// Span adds a request to delete VPP SPAN.
289+
func (dsl *DeleteDSL) Span(val *interfaces.Span) linuxclient.DeleteDSL {
290+
dsl.vppDelete.Span(val)
291+
return dsl
292+
}
293+
282294
// ACL adds a request to delete an existing VPP Access Control List.
283295
func (dsl *DeleteDSL) ACL(aclName string) linuxclient.DeleteDSL {
284296
dsl.vppDelete.ACL(aclName)

clientv2/linux/dbadapter/data_resync_db.go

+6
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ func (dsl *DataResyncDSL) VppInterface(intf *interfaces.Interface) linuxclient.D
8787
return dsl
8888
}
8989

90+
// Span adds VPP span to the RESYNC request.
91+
func (dsl *DataResyncDSL) Span(span *interfaces.Span) linuxclient.DataResyncDSL {
92+
dsl.vppDataResync.Span(span)
93+
return dsl
94+
}
95+
9096
// ACL adds VPP Access Control List to the RESYNC request.
9197
func (dsl *DataResyncDSL) ACL(acl *acl.ACL) linuxclient.DataResyncDSL {
9298
dsl.vppDataResync.ACL(acl)

clientv2/vpp/data_change_api.go

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ type DataChangeDSL interface {
5555
type PutDSL interface {
5656
// Interface adds a request to create or update VPP network interface.
5757
Interface(val *interfaces.Interface) PutDSL
58+
// Span adds VPP span to the Put request.
59+
Span(span *interfaces.Span) PutDSL
5860
// ACL adds a request to create or update VPP Access Control List.
5961
ACL(acl *acl.ACL) PutDSL
6062
// ABF adds a request to create or update VPP ACL-based forwarding.
@@ -105,6 +107,8 @@ type PutDSL interface {
105107
type DeleteDSL interface {
106108
// Interface adds a request to delete an existing VPP network interface.
107109
Interface(ifaceName string) DeleteDSL
110+
// Span adds VPP span to the Delete request.
111+
Span(span *interfaces.Span) DeleteDSL
108112
// ACL adds a request to delete an existing VPP Access Control List.
109113
ACL(aclName string) DeleteDSL
110114
// ABF adds a request to delete and existing VPP Access Control List.

clientv2/vpp/data_resync_api.go

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ import (
3535
type DataResyncDSL interface {
3636
// Interface adds interface to the RESYNC request.
3737
Interface(intf *interfaces.Interface) DataResyncDSL
38+
// Span adds span to the RESYNC request.
39+
Span(intf *interfaces.Span) DataResyncDSL
3840
// ACL adds Access Control List to the RESYNC request.
3941
ACL(acl *acl.ACL) DataResyncDSL
4042
// ABF adds ACL-based forwarding to the RESYNC request.

clientv2/vpp/dbadapter/data_change_db.go

+14
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ func (dsl *PutDSL) Interface(val *intf.Interface) vppclient.PutDSL {
7979
return dsl
8080
}
8181

82+
// Span adds VPP span to the change request.
83+
func (dsl *PutDSL) Span(val *intf.Span) vppclient.PutDSL {
84+
key := intf.SpanKey(val.InterfaceFrom, val.InterfaceTo)
85+
dsl.parent.txn.Put(key, val)
86+
return dsl
87+
}
88+
8289
// ACL adds a request to create or update VPP Access Control List.
8390
func (dsl *PutDSL) ACL(val *acl.ACL) vppclient.PutDSL {
8491
dsl.parent.txn.Put(acl.Key(val.Name), val)
@@ -203,6 +210,13 @@ func (dsl *DeleteDSL) Interface(interfaceName string) vppclient.DeleteDSL {
203210
return dsl
204211
}
205212

213+
// Span adds VPP span to the RESYNC request.
214+
func (dsl *DeleteDSL) Span(val *intf.Span) vppclient.DeleteDSL {
215+
key := intf.SpanKey(val.InterfaceFrom, val.InterfaceTo)
216+
dsl.parent.txn.Delete(key)
217+
return dsl
218+
}
219+
206220
// ACL adds a request to delete an existing VPP Access Control List.
207221
func (dsl *DeleteDSL) ACL(aclName string) vppclient.DeleteDSL {
208222
dsl.parent.txn.Delete(acl.Key(aclName))

clientv2/vpp/dbadapter/data_resync_db.go

+9
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ func (dsl *DataResyncDSL) Interface(val *intf.Interface) vppclient.DataResyncDSL
5757
return dsl
5858
}
5959

60+
// Span adds VPP span to the RESYNC request.
61+
func (dsl *DataResyncDSL) Span(val *intf.Span) vppclient.DataResyncDSL {
62+
key := intf.SpanKey(val.InterfaceFrom, val.InterfaceTo)
63+
dsl.txn.Put(key, val)
64+
dsl.txnKeys = append(dsl.txnKeys, key)
65+
66+
return dsl
67+
}
68+
6069
// ACL adds Access Control List to the RESYNC request.
6170
func (dsl *DataResyncDSL) ACL(val *acl.ACL) vppclient.DataResyncDSL {
6271
key := acl.Key(val.Name)

0 commit comments

Comments
 (0)