diff --git a/plugins/main/host-device/README.md b/plugins/main/host-device/README.md index 323088006..3ea9e77ce 100644 --- a/plugins/main/host-device/README.md +++ b/plugins/main/host-device/README.md @@ -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 diff --git a/plugins/main/host-device/host-device.go b/plugins/main/host-device/host-device.go index 1939d1d90..546c25794 100644 --- a/plugins/main/host-device/host-device.go +++ b/plugins/main/host-device/host-device.go @@ -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 @@ -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 = ¤t.Result{ CNIVersion: current.ImplementedSpecVersion, Interfaces: []*current.Interface{ { @@ -106,7 +111,7 @@ func cmdAdd(args *skel.CmdArgs) error { }, }, } - return types.PrintResult(&result, cfg.CNIVersion) + return types.PrintResult(result, cfg.CNIVersion) } } @@ -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 }