Skip to content

Commit

Permalink
Fix the review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Periyasamy Palanisamy <[email protected]>
  • Loading branch information
pperiyasamy committed Nov 19, 2020
1 parent 39eee3d commit a4dbb7a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions plugins/main/host-device/host-device.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const (
sysBusPCI = "/sys/bus/pci/devices"
)

// Array of different linux drivers bound to network device needed for DPDK
var userspaceDrivers = []string{"vfio-pci", "uio_pci_generic", "igb_uio"}

//NetConf for host-device config, look the README to learn how to use those parameters
Expand Down Expand Up @@ -94,10 +95,14 @@ func cmdAdd(args *skel.CmdArgs) error {
defer containerNs.Close()

var result *current.Result

if len(cfg.PCIAddr) > 0 {
isDpdkMode, _ := hasDpdkDriver(cfg.PCIAddr)
isDpdkMode, err := hasDpdkDriver(cfg.PCIAddr)
if err != nil {
return fmt.Errorf("error with host device: %v", err)
}
if isDpdkMode {
result := current.Result{
result = &current.Result{
CNIVersion: current.ImplementedSpecVersion,
Interfaces: []*current.Interface{
{
Expand All @@ -106,7 +111,7 @@ func cmdAdd(args *skel.CmdArgs) error {
},
},
}
return types.PrintResult(&result, cfg.CNIVersion)
return types.PrintResult(result, cfg.CNIVersion)
}
}

Expand Down Expand Up @@ -187,7 +192,10 @@ func cmdDel(args *skel.CmdArgs) error {
defer containerNs.Close()

if len(cfg.PCIAddr) > 0 {
isDpdkMode, _ := hasDpdkDriver(cfg.PCIAddr)
isDpdkMode, err := hasDpdkDriver(cfg.PCIAddr)
if err != nil {
return fmt.Errorf("error with host device: %v", err)
}
if isDpdkMode {
return nil
}
Expand Down

0 comments on commit a4dbb7a

Please sign in to comment.