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 Jun 12, 2020
1 parent 71ce83c commit 61c82cb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions plugins/main/host-device/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Move an already-existing device into a container.

This simple plugin will move the requested device from the host's network namespace
to the container's. IPAM configuration can be used for this plugin.
This plugin can also be used for a device bound to dpdk driver via `pciBusID` or
runtimeConfig `deviceID` parameter then IPAM configuration will be ignored.

## Network configuration reference

Expand Down
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 61c82cb

Please sign in to comment.