Skip to content

Commit

Permalink
Convert mac address to lower case always
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
SchSeba committed Jul 10, 2023
1 parent c44726a commit f1d045a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/sriov/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"runtime"
"strings"

"github.com/containernetworking/cni/pkg/skel"
"github.com/containernetworking/cni/pkg/types"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f1d045a

Please sign in to comment.