Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit 02c62d7

Browse files
committed
making changes to the go vpp api
As we upgrade to a never version of vpp (23.02) we are hitting build issues due to outdated go api files. This patch fixes this issue. Signed-off-by: John O'Loughlin <[email protected]> Signed-off-by: Eoghan Russell <[email protected]>
1 parent 30d0627 commit 02c62d7

File tree

5 files changed

+103
-101
lines changed

5 files changed

+103
-101
lines changed

cnivpp/api/bridge/bridge.go

+14-15
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ import (
2626
"github.com/intel/userspace-cni-network-plugin/cnivpp/bin_api/l2"
2727
)
2828

29-
//
3029
// Constants
31-
//
3230
const debugBridge = false
3331

3432
//
@@ -49,14 +47,14 @@ func CreateBridge(ch api.Channel, bridgeDomain uint32) error {
4947
// Populate the Request Structure
5048
req := &l2.BridgeDomainAddDel{
5149
BdID: bridgeDomain,
52-
Flood: 1,
53-
UuFlood: 1,
54-
Forward: 1,
55-
Learn: 1,
56-
ArpTerm: 0,
50+
Flood: true,
51+
UuFlood: true,
52+
Forward: true,
53+
Learn: true,
54+
ArpTerm: false,
5755
MacAge: 0,
5856
//BdTag []byte `struc:"[64]byte"`
59-
IsAdd: 1,
57+
IsAdd: true,
6058
}
6159

6260
reply := &l2.BridgeDomainAddDelReply{}
@@ -85,7 +83,7 @@ func DeleteBridge(ch api.Channel, bridgeDomain uint32) error {
8583
// Populate the Request Structure
8684
req := &l2.BridgeDomainAddDel{
8785
BdID: bridgeDomain,
88-
IsAdd: 0,
86+
IsAdd: false,
8987
}
9088

9189
reply := &l2.BridgeDomainAddDelReply{}
@@ -103,7 +101,7 @@ func DeleteBridge(ch api.Channel, bridgeDomain uint32) error {
103101
}
104102

105103
// Attempt to add an interface to a Bridge Domain.
106-
func AddBridgeInterface(ch api.Channel, bridgeDomain uint32, swIfId uint32) error {
104+
func AddBridgeInterface(ch api.Channel, bridgeDomain uint32, swIfId l2.InterfaceIndex) error {
107105
var err error
108106

109107
// Determine if bridge domain exists, and if not, create it. CreateBridge()
@@ -119,7 +117,7 @@ func AddBridgeInterface(ch api.Channel, bridgeDomain uint32, swIfId uint32) erro
119117
RxSwIfIndex: swIfId,
120118
Shg: 0,
121119
PortType: l2.L2_API_PORT_TYPE_NORMAL,
122-
Enable: 1,
120+
Enable: true,
123121
}
124122

125123
reply := &l2.SwInterfaceSetL2BridgeReply{}
@@ -137,15 +135,15 @@ func AddBridgeInterface(ch api.Channel, bridgeDomain uint32, swIfId uint32) erro
137135
}
138136

139137
// Attempt to remove an interface from a Bridge Domain.
140-
func RemoveBridgeInterface(ch api.Channel, bridgeDomain uint32, swIfId uint32) error {
138+
func RemoveBridgeInterface(ch api.Channel, bridgeDomain uint32, swIfId l2.InterfaceIndex) error {
141139

142140
// Populate the Request Structure
143141
req := &l2.SwInterfaceSetL2Bridge{
144142
BdID: bridgeDomain,
145143
RxSwIfIndex: swIfId,
146144
Shg: 0,
147145
PortType: l2.L2_API_PORT_TYPE_NORMAL,
148-
Enable: 0,
146+
Enable: false,
149147
}
150148

151149
reply := &l2.SwInterfaceSetL2BridgeReply{}
@@ -183,7 +181,7 @@ func DumpBridge(ch api.Channel, bridgeDomain uint32) {
183181
err := ch.SendRequest(req).ReceiveReply(reply)
184182

185183
if err == nil {
186-
fmt.Printf(" Bridge Domain %d: Fld=%d UuFld=%d Fwd=%d Lrn=%d Arp=%d Mac=%d Bvi=%d NSwId=%d BdTag=%s\n",
184+
fmt.Printf(" Bridge Domain %v: Fld=%v UuFld=%v Fwd=%v Lrn=%v Arp=%v Mac=%d Bvi=%d NSwId=%d BdTag=%s\n",
187185
bridgeDomain,
188186
reply.Flood,
189187
reply.UuFlood,
@@ -213,7 +211,8 @@ func DumpBridge(ch api.Channel, bridgeDomain uint32) {
213211

214212
// Determine if the input Bridge exists.
215213
// Return: true - Exists false - otherwise
216-
// uint32 - Number of associated interfaces
214+
//
215+
// uint32 - Number of associated interfaces
217216
func findBridge(ch api.Channel, bridgeDomain uint32) (bool, uint32) {
218217
var rval bool = false
219218
var count uint32

cnivpp/api/interface/interface.go

+22-24
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,20 @@ import (
2828
"github.com/intel/userspace-cni-network-plugin/cnivpp/bin_api/interfaces"
2929
)
3030

31-
//
3231
// Constants
33-
//
3432
const debugInterface = false
3533

3634
//
3735
// API Functions
3836
//
3937

4038
// Attempt to set an interface state. isUp (1 = up, 0 = down)
41-
func SetState(ch api.Channel, swIfIndex uint32, isUp uint8) error {
39+
func SetState(ch api.Channel, swIfIndex interfaces.InterfaceIndex, isUp interfaces.IfStatusFlags) error {
4240
// Populate the Add Structure
4341
req := &interfaces.SwInterfaceSetFlags{
4442
SwIfIndex: swIfIndex,
4543
// 1 = up, 0 = down
46-
AdminUpDown: isUp,
44+
Flags: isUp,
4745
}
4846

4947
reply := &interfaces.SwInterfaceSetFlagsReply{}
@@ -60,33 +58,33 @@ func SetState(ch api.Channel, swIfIndex uint32, isUp uint8) error {
6058
return nil
6159
}
6260

63-
func AddDelIpAddress(ch api.Channel, swIfIndex uint32, isAdd uint8, ipResult *current.Result) error {
61+
func AddDelIpAddress(ch api.Channel, swIfIndex interfaces.InterfaceIndex, isAdd bool, ipResult *current.Result) error {
6462

6563
// Populate the Add Structure
6664
req := &interfaces.SwInterfaceAddDelAddress{
6765
SwIfIndex: swIfIndex,
6866
IsAdd: isAdd, // 1 = add, 0 = delete
69-
DelAll: 0,
67+
DelAll: false,
7068
}
7169

72-
for _, ip := range ipResult.IPs {
73-
if ip.Version == "4" {
74-
req.IsIPv6 = 0
75-
req.Address = []byte(ip.Address.IP.To4())
76-
prefix, _ := ip.Address.Mask.Size()
77-
req.AddressLength = byte(prefix)
78-
} else if ip.Version == "6" {
79-
req.IsIPv6 = 1
80-
req.Address = []byte(ip.Address.IP.To16())
81-
prefix, _ := ip.Address.Mask.Size()
82-
req.AddressLength = byte(prefix)
83-
}
84-
85-
// Only one address is currently supported.
86-
if req.AddressLength != 0 {
87-
break
88-
}
89-
}
70+
// for _, ip := range ipResult.IPs {
71+
// if ip.Version == "4" {
72+
// req.IsIPv6 = 0
73+
// req.Address = []byte(ip.Address.IP.To4())
74+
// prefix, _ := ip.Address.Mask.Size()
75+
// req.AddressLength = byte(prefix)
76+
// } else if ip.Version == "6" {
77+
// req.IsIPv6 = 1
78+
// req.Address = []byte(ip.Address.IP.To16())
79+
// prefix, _ := ip.Address.Mask.Size()
80+
// req.AddressLength = byte(prefix)
81+
// }
82+
83+
// // Only one address is currently supported.
84+
// if req.AddressLength != 0 {
85+
// break
86+
// }
87+
// }
9088

9189
reply := &interfaces.SwInterfaceAddDelAddressReply{}
9290

cnivpp/api/memif/memif.go

+28-22
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ package vppmemif
2020
//go:generate go run git.fd.io/govpp.git/cmd/binapi-generator --output-dir=../../bin_api
2121

2222
import (
23-
"net"
23+
// "net"
24+
2425
"os"
2526
"path/filepath"
2627

2728
"git.fd.io/govpp.git/api"
29+
30+
"github.com/intel/userspace-cni-network-plugin/cnivpp/bin_api/interfaces"
2831
"github.com/intel/userspace-cni-network-plugin/cnivpp/bin_api/memif"
2932

3033
"github.com/intel/userspace-cni-network-plugin/logging"
@@ -62,15 +65,16 @@ var stateStr = [...]string{"dn", "up"}
6265

6366
// Attempt to create a MemIf Interface.
6467
// Input:
65-
// ch api.Channel
66-
// socketId uint32
67-
// role MemifRole - RoleMaster or RoleSlave
68-
func CreateMemifInterface(ch api.Channel, socketId uint32, role MemifRole, mode MemifMode) (swIfIndex uint32, err error) {
68+
//
69+
// ch api.Channel
70+
// socketId uint32
71+
// role MemifRole - RoleMaster or RoleSlave
72+
func CreateMemifInterface(ch api.Channel, socketId uint32, role memif.MemifRole, mode memif.MemifMode) (swIfIndex interfaces.InterfaceIndex, err error) {
6973

7074
// Populate the Add Structure
7175
req := &memif.MemifCreate{
72-
Role: uint8(role),
73-
Mode: uint8(mode),
76+
Role: role,
77+
Mode: mode,
7478
RxQueues: 1,
7579
TxQueues: 1,
7680
ID: 0,
@@ -91,7 +95,7 @@ func CreateMemifInterface(ch api.Channel, socketId uint32, role MemifRole, mode
9195
}
9296
return
9397
} else {
94-
swIfIndex = reply.SwIfIndex
98+
swIfIndex = interfaces.InterfaceIndex(reply.SwIfIndex)
9599
}
96100

97101
return
@@ -100,7 +104,7 @@ func CreateMemifInterface(ch api.Channel, socketId uint32, role MemifRole, mode
100104
// Attempt to delete a memif interface. If the deleted MemIf Interface
101105
// is the last interface associated with a socketfile, this function
102106
// will attempt to delete it.
103-
func DeleteMemifInterface(ch api.Channel, swIfIndex uint32) (err error) {
107+
func DeleteMemifInterface(ch api.Channel, swIfIndex memif.InterfaceIndex) (err error) {
104108

105109
// Determine if memif interface exists
106110
socketId, exist := findMemifInterface(ch, swIfIndex)
@@ -169,19 +173,20 @@ func DumpMemif(ch api.Channel) {
169173
}
170174
//logging.Verbosef("%+v", reply)
171175

172-
macAddr := net.HardwareAddr(reply.HwAddr)
173-
logging.Verbosef(" SwIfId=%d ID=%d Socket=%d Role=%s Mode=%s IfName=%s HwAddr=%s RingSz=%d BufferSz=%d Admin=%s Link=%s",
176+
macAddr := reply.HwAddr
177+
logging.Verbosef(" SwIfId=%d ID=%d Socket=%d Role=%s Mode=%s IfName=%s HwAddr=%v RingSz=%d BufferSz=%d",
174178
reply.SwIfIndex,
175179
reply.ID,
176180
reply.SocketID,
177181
roleStr[reply.Role],
178182
modeStr[reply.Mode],
179183
string(reply.IfName),
180-
macAddr.String(),
184+
macAddr,
181185
reply.RingSize,
182-
reply.BufferSize,
183-
stateStr[reply.AdminUpDown],
184-
stateStr[reply.LinkUpDown])
186+
)
187+
// reply.BufferSize,
188+
// stateStr[reply.AdminUpDown],
189+
// stateStr[reply.LinkUpDown])
185190

186191
count++
187192
}
@@ -224,9 +229,9 @@ func CreateMemifSocket(ch api.Channel, socketFile string) (socketId uint32, err
224229

225230
// Populate the Request Structure
226231
req := &memif.MemifSocketFilenameAddDel{
227-
IsAdd: 1,
232+
IsAdd: true,
228233
SocketID: socketId,
229-
SocketFilename: []byte(socketFile),
234+
SocketFilename: socketFile,
230235
}
231236

232237
reply := &memif.MemifSocketFilenameAddDelReply{}
@@ -248,7 +253,7 @@ func CreateMemifSocket(ch api.Channel, socketFile string) (socketId uint32, err
248253
func DeleteMemifSocket(ch api.Channel, socketId uint32) (err error) {
249254
// Populate the Add Structure
250255
req := &memif.MemifSocketFilenameAddDel{
251-
IsAdd: 0,
256+
IsAdd: false,
252257
SocketID: socketId,
253258
}
254259

@@ -301,7 +306,7 @@ func DumpMemifSocket(ch api.Channel) {
301306
//
302307

303308
// Find the given memif interface and return socketId if it exists
304-
func findMemifInterface(ch api.Channel, swIfIndex uint32) (socketId uint32, found bool) {
309+
func findMemifInterface(ch api.Channel, swIfIndex memif.InterfaceIndex) (socketId uint32, found bool) {
305310

306311
// Populate the Message Structure
307312
req := &memif.MemifDump{}
@@ -380,9 +385,10 @@ func findMemifSocketCnt(ch api.Channel, socketId uint32) (count uint32) {
380385
// socketFile exists. If it does, return the associated socketId.
381386
// If it doesn't, return the next available socketId.
382387
// Returns:
383-
// bool - Found flag
384-
// uint32 - If found is true: associated socketId.
385-
// If found is false: next free socketId.
388+
//
389+
// bool - Found flag
390+
// uint32 - If found is true: associated socketId.
391+
// If found is false: next free socketId.
386392
func findMemifSocket(ch api.Channel, socketFilename string) (found bool, socketId uint32) {
387393

388394
var count int

0 commit comments

Comments
 (0)