From f1d045aa557489ff70b14c1e2c0468ef8464444f Mon Sep 17 00:00:00 2001 From: Sebastian Sch Date: Mon, 10 Jul 2023 16:39:01 +0300 Subject: [PATCH] Convert mac address to lower case always Without this commit there is a possible bug if the user request a mac address with upper case. The issue is that netlink lib will always return the hardware struct for mac address and it will always be lower case. So to be able and do a right equal check we convert the user provided mac address to lower case always Signed-off-by: Sebastian Sch --- cmd/sriov/main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/sriov/main.go b/cmd/sriov/main.go index 93784e051..616fb185c 100644 --- a/cmd/sriov/main.go +++ b/cmd/sriov/main.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "runtime" + "strings" "github.com/containernetworking/cni/pkg/skel" "github.com/containernetworking/cni/pkg/types" @@ -66,6 +67,9 @@ func cmdAdd(args *skel.CmdArgs) error { netConf.MAC = netConf.RuntimeConfig.Mac } + // Always use lower case for mac address + netConf.MAC = strings.ToLower(netConf.MAC) + netns, err := ns.GetNS(args.Netns) if err != nil { return fmt.Errorf("failed to open netns %q: %v", netns, err)