Skip to content

Commit

Permalink
Modify VPP memif logic to create socket directory if it doesn't
Browse files Browse the repository at this point in the history
exist. In VPP 18.07, VPP crashes, and in VPP 18.10, VPP returns
an error.

Signed-off-by: Billy McFall <bmcfall@redhat.com>
  • Loading branch information
Billy99 committed Oct 8, 2018
1 parent e67ef94 commit 15a4a6e
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion cnivpp/api/memif/memif.go
Expand Up @@ -22,6 +22,8 @@ package vppmemif
import (
"fmt"
"net"
"os"
"path/filepath"

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

found, socketId := findMemifSocket(ch, socketFile)
if found {
fmt.Println("Socketfile already exists")
if debugMemif {
fmt.Println("Socketfile already exists")
}
return
}

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

// Determine if directory socket is created in exists. If it doesn't, create it.
sockDir := filepath.Dir(socketFile)
if _, err = os.Stat(sockDir); err != nil {
if os.IsNotExist(err) {
if err = os.MkdirAll(sockDir, 0700); err != nil {
if debugMemif {
fmt.Println("Unable to create Socketfile directory")
}
return
}
} else {
if debugMemif {
fmt.Println("Error getting status of Socketfile directory")
}
return
}
}


// Populate the Request Structure
req := &memif.MemifSocketFilenameAddDel{
IsAdd: 1,
Expand Down

0 comments on commit 15a4a6e

Please sign in to comment.