Skip to content

Commit

Permalink
Only add linkType selector for infiniband devices
Browse files Browse the repository at this point in the history
LinkType is not detectable for eth vfio-pci device using
netlink library which results in failure when exposing
vfio-pci resources.

Signed-off-by: Zenghui Shi <[email protected]>
  • Loading branch information
zshi-redhat committed Feb 9, 2021
1 parent bf06f89 commit bfde7c6
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions controllers/sriovnetworknodepolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,14 +559,16 @@ func (r *SriovNetworkNodePolicyReconciler) renderDevicePluginConfigData(pl *srio
if len(p.Spec.NicSelector.PfNames) > 0 {
netDeviceSelectors.PfNames = sriovnetworkv1.UniqueAppend(netDeviceSelectors.PfNames, p.Spec.NicSelector.PfNames...)
}
if p.Spec.LinkType != "" {
linkType := linkTypeEthernet
if strings.ToLower(p.Spec.LinkType) == "ib" {
linkType = linkTypeInfiniband
}

if !sriovnetworkv1.StringInArray(linkType, netDeviceSelectors.LinkTypes) {
netDeviceSelectors.LinkTypes = sriovnetworkv1.UniqueAppend(netDeviceSelectors.LinkTypes, linkType)
// vfio-pci device link type is not detectable
if p.Spec.DeviceType != "vfio-pci" {
if p.Spec.LinkType != "" {
linkType := linkTypeEthernet
if strings.ToLower(p.Spec.LinkType) == "ib" {
linkType = linkTypeInfiniband
}
if !sriovnetworkv1.StringInArray(linkType, netDeviceSelectors.LinkTypes) {
netDeviceSelectors.LinkTypes = sriovnetworkv1.UniqueAppend(netDeviceSelectors.LinkTypes, linkType)
}
}
}
if len(p.Spec.NicSelector.RootDevices) > 0 {
Expand Down Expand Up @@ -622,12 +624,15 @@ func (r *SriovNetworkNodePolicyReconciler) renderDevicePluginConfigData(pl *srio
if len(p.Spec.NicSelector.PfNames) > 0 {
netDeviceSelectors.PfNames = append(netDeviceSelectors.PfNames, p.Spec.NicSelector.PfNames...)
}
if p.Spec.LinkType != "" {
linkType := linkTypeEthernet
if strings.ToLower(p.Spec.LinkType) == "ib" {
linkType = linkTypeInfiniband
// vfio-pci device link type is not detectable
if p.Spec.DeviceType != "vfio-pci" {
if p.Spec.LinkType != "" {
linkType := linkTypeEthernet
if strings.ToLower(p.Spec.LinkType) == "ib" {
linkType = linkTypeInfiniband
}
netDeviceSelectors.LinkTypes = sriovnetworkv1.UniqueAppend(netDeviceSelectors.LinkTypes, linkType)
}
netDeviceSelectors.LinkTypes = sriovnetworkv1.UniqueAppend(netDeviceSelectors.LinkTypes, linkType)
}
if len(p.Spec.NicSelector.RootDevices) > 0 {
netDeviceSelectors.RootDevices = append(netDeviceSelectors.RootDevices, p.Spec.NicSelector.RootDevices...)
Expand Down

0 comments on commit bfde7c6

Please sign in to comment.