Skip to content

Commit

Permalink
Merge pull request #670 from SchSeba/check_lock_down_on_mlx_plugin
Browse files Browse the repository at this point in the history
Check for kernel lockdown only in mlx plugin
  • Loading branch information
zeeke authored Apr 2, 2024
2 parents b6aace2 + 3174334 commit 8f34c8b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 14 deletions.
6 changes: 0 additions & 6 deletions pkg/host/internal/sriov/sriov.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/types"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vars"
mlx "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vendors/mellanox"
)

type interfaceToConfigure struct {
Expand Down Expand Up @@ -583,11 +582,6 @@ func (s *sriov) configSriovDevice(iface *sriovnetworkv1.Interface, skipVFConfigu

func (s *sriov) ConfigSriovInterfaces(storeManager store.ManagerInterface,
interfaces []sriovnetworkv1.Interface, ifaceStatuses []sriovnetworkv1.InterfaceExt, skipVFConfiguration bool) error {
if s.kernelHelper.IsKernelLockdownMode() && mlx.HasMellanoxInterfacesInSpec(ifaceStatuses, interfaces) {
log.Log.Error(nil, "cannot use mellanox devices when in kernel lockdown mode")
return fmt.Errorf("cannot use mellanox devices when in kernel lockdown mode")
}

toBeConfigured, toBeResetted, err := s.getConfigureAndReset(storeManager, interfaces, ifaceStatuses)
if err != nil {
log.Log.Error(err, "cannot get a list of interfaces to configure")
Expand Down
8 changes: 0 additions & 8 deletions pkg/host/internal/sriov/sriov_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ var _ = Describe("SRIOV", func() {
Files: map[string][]byte{"/sys/bus/pci/devices/0000:d8:00.0/sriov_numvfs": {}},
})

hostMock.EXPECT().IsKernelLockdownMode().Return(false)
dputilsLibMock.EXPECT().GetSriovVFcapacity("0000:d8:00.0").Return(2)
dputilsLibMock.EXPECT().GetVFconfigured("0000:d8:00.0").Return(0)
netlinkLibMock.EXPECT().DevLinkGetDeviceByName("pci", "0000:d8:00.0").Return(&netlink.DevlinkDevice{
Expand Down Expand Up @@ -177,7 +176,6 @@ var _ = Describe("SRIOV", func() {
Files: map[string][]byte{"/sys/bus/pci/devices/0000:d8:00.0/sriov_numvfs": {}},
})

hostMock.EXPECT().IsKernelLockdownMode().Return(false)
dputilsLibMock.EXPECT().GetSriovVFcapacity("0000:d8:00.0").Return(1)
dputilsLibMock.EXPECT().GetVFconfigured("0000:d8:00.0").Return(0)
netlinkLibMock.EXPECT().DevLinkGetDeviceByName("pci", "0000:d8:00.0").Return(&netlink.DevlinkDevice{
Expand Down Expand Up @@ -230,7 +228,6 @@ var _ = Describe("SRIOV", func() {
Files: map[string][]byte{"/sys/bus/pci/devices/0000:d8:00.0/sriov_numvfs": {}},
})

hostMock.EXPECT().IsKernelLockdownMode().Return(false)
dputilsLibMock.EXPECT().GetSriovVFcapacity("0000:d8:00.0").Return(1)
dputilsLibMock.EXPECT().GetVFconfigured("0000:d8:00.0").Return(0)
hostMock.EXPECT().RemoveDisableNMUdevRule("0000:d8:00.0").Return(nil)
Expand Down Expand Up @@ -294,7 +291,6 @@ var _ = Describe("SRIOV", func() {
})

It("externally managed - wrong VF count", func() {
hostMock.EXPECT().IsKernelLockdownMode().Return(false)
dputilsLibMock.EXPECT().GetVFconfigured("0000:d8:00.0").Return(0)
Expect(s.ConfigSriovInterfaces(storeManagerMode,
[]sriovnetworkv1.Interface{{
Expand All @@ -316,7 +312,6 @@ var _ = Describe("SRIOV", func() {
})

It("externally managed - wrong MTU", func() {
hostMock.EXPECT().IsKernelLockdownMode().Return(false)
dputilsLibMock.EXPECT().GetVFconfigured("0000:d8:00.0").Return(1)
netlinkLibMock.EXPECT().DevLinkGetDeviceByName("pci", "0000:d8:00.0").Return(
&netlink.DevlinkDevice{Attrs: netlink.DevlinkDevAttrs{Eswitch: netlink.DevlinkDevEswitchAttr{Mode: "legacy"}}},
Expand Down Expand Up @@ -347,7 +342,6 @@ var _ = Describe("SRIOV", func() {
Files: map[string][]byte{"/sys/bus/pci/devices/0000:d8:00.0/sriov_numvfs": {}},
})

hostMock.EXPECT().IsKernelLockdownMode().Return(false)
storeManagerMode.EXPECT().LoadPfsStatus("0000:d8:00.0").Return(&sriovnetworkv1.Interface{
Name: "enp216s0f0np0",
PciAddress: "0000:d8:00.0",
Expand All @@ -374,7 +368,6 @@ var _ = Describe("SRIOV", func() {
helpers.GinkgoAssertFileContentsEquals("/sys/bus/pci/devices/0000:d8:00.0/sriov_numvfs", "0")
})
It("reset device - skip external", func() {
hostMock.EXPECT().IsKernelLockdownMode().Return(false)
storeManagerMode.EXPECT().LoadPfsStatus("0000:d8:00.0").Return(&sriovnetworkv1.Interface{
Name: "enp216s0f0np0",
PciAddress: "0000:d8:00.0",
Expand All @@ -397,7 +390,6 @@ var _ = Describe("SRIOV", func() {
Files: map[string][]byte{"/sys/bus/pci/devices/0000:d8:00.0/sriov_numvfs": {}},
})

hostMock.EXPECT().IsKernelLockdownMode().Return(false)
dputilsLibMock.EXPECT().GetSriovVFcapacity("0000:d8:00.0").Return(2)
dputilsLibMock.EXPECT().GetVFconfigured("0000:d8:00.0").Return(0)
netlinkLibMock.EXPECT().DevLinkGetDeviceByName("pci", "0000:d8:00.0").Return(
Expand Down

0 comments on commit 8f34c8b

Please sign in to comment.