Skip to content

Commit

Permalink
Merge pull request #69 from madeelibm/type-fix
Browse files Browse the repository at this point in the history
Fix ethtoolSsetInfo data type according to kernel's uapi ethtool_sset…
  • Loading branch information
safchain authored Oct 27, 2023
2 parents 9e2880a + 4664c42 commit 073e7b2
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ethtool.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ const (
PERMADDR_LEN = 32
)

// ethtool sset_info related constants
const (
MAX_SSET_INFO = 64

Check failure on line 97 in ethtool.go

View workflow job for this annotation

GitHub Actions / unittests

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/safchain/ethtool) (gci)
)

var supportedCapabilities = []struct {
name string
mask uint64
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 073e7b2

Please sign in to comment.