Skip to content

Commit

Permalink
Merge pull request #302 from ykulazhenkov/pr-check-fix
Browse files Browse the repository at this point in the history
Fix CMDCheck for hw offload use-case
  • Loading branch information
phoracek authored Apr 9, 2024
2 parents 70e52f7 + f0f828c commit 34a10fe
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions pkg/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand Down Expand Up @@ -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
Expand All @@ -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() {
Expand Down

0 comments on commit 34a10fe

Please sign in to comment.