Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix ethtoolSsetInfo data type according to kernel's uapi ethtool_sset… #69

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions ethtool.go
Original file line number Diff line number Diff line change
@@ -92,6 +92,11 @@ const (
PERMADDR_LEN = 32
)

// ethtool sset_info related constants
const (
MAX_SSET_INFO = 64
)

var supportedCapabilities = []struct {
name string
mask uint64
@@ -131,8 +136,8 @@ type ifreq struct {
type ethtoolSsetInfo struct {
cmd uint32
reserved uint32
sset_mask uint32
data uintptr
sset_mask uint64
data [MAX_SSET_INFO]uint32
}

type ethtoolGetFeaturesBlock struct {
@@ -693,13 +698,15 @@ func (e *Ethtool) getNames(intf string, mask int) (map[string]uint, error) {
ssetInfo := ethtoolSsetInfo{
cmd: ETHTOOL_GSSET_INFO,
sset_mask: 1 << mask,
data: [MAX_SSET_INFO]uint32{},
}

if err := e.ioctl(intf, uintptr(unsafe.Pointer(&ssetInfo))); err != nil {
return nil, err
}

length := uint32(ssetInfo.data)
/* we only read data on first index because single bit was set in sset_mask(0x10) */
length := ssetInfo.data[0]
if length == 0 {
return map[string]uint{}, nil
} else if length > MAX_GSTRINGS {