Merge pull request #804 from mmorel-35/main

build(deps): bump github.com/safchain/ethtool to v0.2.0
This commit is contained in:
Casey Callendrello 2023-01-11 11:22:53 +01:00 committed by GitHub
commit 0af8153e9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 14 deletions

2
go.mod
View File

@ -17,7 +17,7 @@ require (
github.com/networkplumbing/go-nft v0.2.0
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.24.2
github.com/safchain/ethtool v0.0.0-20210803160452-9aa261dae9b1
github.com/safchain/ethtool v0.2.0
github.com/vishvananda/netlink v1.2.1-beta.2
golang.org/x/sys v0.4.0
)

5
go.sum
View File

@ -596,8 +596,8 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8/go.mod h1:Z0q5wiBQGYcxhMZ6gUqHn6pYNLypFAvaL3UvgZLR0U4=
github.com/safchain/ethtool v0.0.0-20210803160452-9aa261dae9b1 h1:ZFfeKAhIQiiOrQaI3/znw0gOmYpO28Tcu1YaqMa/jtQ=
github.com/safchain/ethtool v0.0.0-20210803160452-9aa261dae9b1/go.mod h1:Z0q5wiBQGYcxhMZ6gUqHn6pYNLypFAvaL3UvgZLR0U4=
github.com/safchain/ethtool v0.2.0 h1:dILxMBqDnQfX192cCAPjZr9v2IgVXeElHPy435Z/IdE=
github.com/safchain/ethtool v0.2.0/go.mod h1:WkKB1DnNtvsMlDmQ50sgwowDJV/hGbJSOvJoEXs1AJQ=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/sclevine/spec v1.2.0/go.mod h1:W4J29eT/Kzv7/b9IWLB055Z+qvVC9vt0Arko24q7p+U=
github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo=
@ -880,6 +880,7 @@ golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

View File

@ -234,13 +234,22 @@ type Ethtool struct {
fd int
}
// Convert zero-terminated array of chars (string in C) to a Go string.
func goString(s []byte) string {
strEnd := bytes.IndexByte(s, 0)
if strEnd == -1 {
return string(s[:])
}
return string(s[:strEnd])
}
// DriverName returns the driver name of the given interface name.
func (e *Ethtool) DriverName(intf string) (string, error) {
info, err := e.getDriverInfo(intf)
if err != nil {
return "", err
}
return string(bytes.Trim(info.driver[:], "\x00")), nil
return goString(info.driver[:]), nil
}
// BusInfo returns the bus information of the given interface name.
@ -249,7 +258,7 @@ func (e *Ethtool) BusInfo(intf string) (string, error) {
if err != nil {
return "", err
}
return string(bytes.Trim(info.bus_info[:], "\x00")), nil
return goString(info.bus_info[:]), nil
}
// ModuleEeprom returns Eeprom information of the given interface name.
@ -281,12 +290,12 @@ func (e *Ethtool) DriverInfo(intf string) (DrvInfo, error) {
drvInfo := DrvInfo{
Cmd: i.cmd,
Driver: string(bytes.Trim(i.driver[:], "\x00")),
Version: string(bytes.Trim(i.version[:], "\x00")),
FwVersion: string(bytes.Trim(i.fw_version[:], "\x00")),
BusInfo: string(bytes.Trim(i.bus_info[:], "\x00")),
EromVersion: string(bytes.Trim(i.erom_version[:], "\x00")),
Reserved2: string(bytes.Trim(i.reserved2[:], "\x00")),
Driver: goString(i.driver[:]),
Version: goString(i.version[:]),
FwVersion: goString(i.fw_version[:]),
BusInfo: goString(i.bus_info[:]),
EromVersion: goString(i.erom_version[:]),
Reserved2: goString(i.reserved2[:]),
NPrivFlags: i.n_priv_flags,
NStats: i.n_stats,
TestInfoLen: i.testinfo_len,
@ -500,7 +509,7 @@ func (e *Ethtool) FeatureNames(intf string) (map[string]uint, error) {
var result = make(map[string]uint)
for i := 0; i != int(length); i++ {
b := gstrings.data[i*ETH_GSTRING_LEN : i*ETH_GSTRING_LEN+ETH_GSTRING_LEN]
key := string(bytes.Trim(b, "\x00"))
key := goString(b)
if key != "" {
result[key] = uint(i)
}

4
vendor/modules.txt vendored
View File

@ -148,8 +148,8 @@ github.com/onsi/gomega/types
# github.com/pkg/errors v0.9.1
## explicit
github.com/pkg/errors
# github.com/safchain/ethtool v0.0.0-20210803160452-9aa261dae9b1
## explicit
# github.com/safchain/ethtool v0.2.0
## explicit; go 1.16
github.com/safchain/ethtool
# github.com/sirupsen/logrus v1.8.1
## explicit; go 1.13