From f0f828c9b83ac59e57b3520b8963ffaf9f53739b Mon Sep 17 00:00:00 2001 From: Yury Kulazhenkov Date: Fri, 1 Mar 2024 13:23:11 +0200 Subject: [PATCH] Fix CMDCheck for hw offload use-case In CMDCheck there is a check that validates if host/cont interfaces are veth interfaces. For HW offload this is not true. Ignore this check if ovsHWOffload is enabled Signed-off-by: Yury Kulazhenkov --- pkg/plugin/plugin.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/plugin/plugin.go b/pkg/plugin/plugin.go index 5d173a71..7b29aced 100644 --- a/pkg/plugin/plugin.go +++ b/pkg/plugin/plugin.go @@ -604,6 +604,7 @@ func CmdCheck(args *skel.CmdArgs) error { if err != nil { return err } + ovsHWOffloadEnable := sriov.IsOvsHardwareOffloadEnabled(netconf.DeviceID) // run the IPAM plugin if netconf.NetConf.IPAM.Type != "" { @@ -644,7 +645,7 @@ func CmdCheck(args *skel.CmdArgs) error { } } else { // Check prevResults for ips against values found in the host - if err := validateInterface(*intf, true); err != nil { + if err := validateInterface(*intf, true, ovsHWOffloadEnable); err != nil { return err } hostIntf = *intf @@ -667,7 +668,7 @@ func CmdCheck(args *skel.CmdArgs) error { if err := netns.Do(func(_ ns.NetNS) error { // Check interface against values found in the container - err := validateInterface(contIntf, false) + err := validateInterface(contIntf, false, ovsHWOffloadEnable) if err != nil { return err } @@ -718,7 +719,7 @@ func validateCache(cache *types.CachedNetConf, netconf *types.NetConf) error { return nil } -func validateInterface(intf current.Interface, isHost bool) error { +func validateInterface(intf current.Interface, isHost bool, hwOffload bool) error { var link netlink.Link var err error var iftype string @@ -738,10 +739,11 @@ func validateInterface(intf current.Interface, isHost bool) error { if !isHost && intf.Sandbox == "" { return fmt.Errorf("Error: %s interface %s should not be in host namespace", iftype, link.Attrs().Name) } - - _, isVeth := link.(*netlink.Veth) - if !isVeth { - return fmt.Errorf("Error: %s interface %s not of type veth/p2p", iftype, link.Attrs().Name) + if !hwOffload { + _, isVeth := link.(*netlink.Veth) + if !isVeth { + return fmt.Errorf("Error: %s interface %s not of type veth/p2p", iftype, link.Attrs().Name) + } } if intf.Mac != "" && intf.Mac != link.Attrs().HardwareAddr.String() {