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

Commit 15a4a6e

Browse files
committed
Modify VPP memif logic to create socket directory if it doesn't
exist. In VPP 18.07, VPP crashes, and in VPP 18.10, VPP returns an error. Signed-off-by: Billy McFall <[email protected]>
1 parent e67ef94 commit 15a4a6e

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

Diff for: cnivpp/api/memif/memif.go

+24-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ package vppmemif
2222
import (
2323
"fmt"
2424
"net"
25+
"os"
26+
"path/filepath"
2527

2628
"git.fd.io/govpp.git/api"
2729
"git.fd.io/govpp.git/core/bin_api/memif"
@@ -191,14 +193,35 @@ func CreateMemifSocket(ch api.Channel, socketFile string) (socketId uint32, err
191193

192194
found, socketId := findMemifSocket(ch, socketFile)
193195
if found {
194-
fmt.Println("Socketfile already exists")
196+
if debugMemif {
197+
fmt.Println("Socketfile already exists")
198+
}
195199
return
196200
}
197201

198202
if debugMemif {
199203
fmt.Printf("Attempting to create SocketId=%d File=%s\n", socketId, socketFile)
200204
}
201205

206+
// Determine if directory socket is created in exists. If it doesn't, create it.
207+
sockDir := filepath.Dir(socketFile)
208+
if _, err = os.Stat(sockDir); err != nil {
209+
if os.IsNotExist(err) {
210+
if err = os.MkdirAll(sockDir, 0700); err != nil {
211+
if debugMemif {
212+
fmt.Println("Unable to create Socketfile directory")
213+
}
214+
return
215+
}
216+
} else {
217+
if debugMemif {
218+
fmt.Println("Error getting status of Socketfile directory")
219+
}
220+
return
221+
}
222+
}
223+
224+
202225
// Populate the Request Structure
203226
req := &memif.MemifSocketFilenameAddDel{
204227
IsAdd: 1,

0 commit comments

Comments
 (0)