Update netlink vendoring (#1471)
* github.com/ema/qdisc * github.com/mdlayher/genetlink * github.com/mdlayher/wifi Signed-off-by: Ben Kochie <superq@gmail.com>
This commit is contained in:
parent
8c3de12c22
commit
0e77317955
245 changed files with 6515 additions and 1699 deletions
90
vendor/github.com/prometheus/procfs/sysfs/class_cooling_device.go
generated
vendored
Normal file
90
vendor/github.com/prometheus/procfs/sysfs/class_cooling_device.go
generated
vendored
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
// Copyright 2019 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build !windows
|
||||
|
||||
package sysfs
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/prometheus/procfs/internal/util"
|
||||
)
|
||||
|
||||
// ClassCoolingDeviceStats contains info from files in /sys/class/thermal/cooling_device[0-9]*
|
||||
// for a single device.
|
||||
// https://www.kernel.org/doc/Documentation/thermal/sysfs-api.txt
|
||||
type ClassCoolingDeviceStats struct {
|
||||
Name string // The name of the cooling device.
|
||||
Type string // Type of the cooling device(processor/fan/...)
|
||||
MaxState int64 // Maximum cooling state of the cooling device
|
||||
CurState int64 // Current cooling state of the cooling device
|
||||
}
|
||||
|
||||
func (fs FS) ClassCoolingDeviceStats() ([]ClassCoolingDeviceStats, error) {
|
||||
cds, err := filepath.Glob(fs.sys.Path("class/thermal/cooling_device[0-9]*"))
|
||||
if err != nil {
|
||||
return []ClassCoolingDeviceStats{}, err
|
||||
}
|
||||
|
||||
var coolingDeviceStats = ClassCoolingDeviceStats{}
|
||||
stats := make([]ClassCoolingDeviceStats, len(cds))
|
||||
for i, cd := range cds {
|
||||
cdName := strings.TrimPrefix(filepath.Base(cd), "cooling_device")
|
||||
|
||||
coolingDeviceStats, err = parseCoolingDeviceStats(cd)
|
||||
if err != nil {
|
||||
return []ClassCoolingDeviceStats{}, err
|
||||
}
|
||||
|
||||
coolingDeviceStats.Name = cdName
|
||||
stats[i] = coolingDeviceStats
|
||||
}
|
||||
return stats, nil
|
||||
}
|
||||
|
||||
func parseCoolingDeviceStats(cd string) (ClassCoolingDeviceStats, error) {
|
||||
cdType, err := util.SysReadFile(filepath.Join(cd, "type"))
|
||||
if err != nil {
|
||||
return ClassCoolingDeviceStats{}, err
|
||||
}
|
||||
|
||||
cdMaxStateString, err := util.SysReadFile(filepath.Join(cd, "max_state"))
|
||||
if err != nil {
|
||||
return ClassCoolingDeviceStats{}, err
|
||||
}
|
||||
cdMaxStateInt, err := strconv.ParseInt(cdMaxStateString, 10, 64)
|
||||
if err != nil {
|
||||
return ClassCoolingDeviceStats{}, err
|
||||
}
|
||||
|
||||
// cur_state can be -1, eg intel powerclamp
|
||||
// https://www.kernel.org/doc/Documentation/thermal/intel_powerclamp.txt
|
||||
cdCurStateString, err := util.SysReadFile(filepath.Join(cd, "cur_state"))
|
||||
if err != nil {
|
||||
return ClassCoolingDeviceStats{}, err
|
||||
}
|
||||
|
||||
cdCurStateInt, err := strconv.ParseInt(cdCurStateString, 10, 64)
|
||||
if err != nil {
|
||||
return ClassCoolingDeviceStats{}, err
|
||||
}
|
||||
|
||||
return ClassCoolingDeviceStats{
|
||||
Type: cdType,
|
||||
MaxState: cdMaxStateInt,
|
||||
CurState: cdCurStateInt,
|
||||
}, nil
|
||||
}
|
||||
84
vendor/github.com/prometheus/procfs/sysfs/vulnerability.go
generated
vendored
Normal file
84
vendor/github.com/prometheus/procfs/sysfs/vulnerability.go
generated
vendored
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
// Copyright 2019 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package sysfs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
notAffected = "Not Affected"
|
||||
vulnerable = "Vulnerable"
|
||||
mitigation = "Mitigation"
|
||||
)
|
||||
|
||||
// CPUVulnerabilities retrieves a map of vulnerability names to their mitigations.
|
||||
func (fs FS) CPUVulnerabilities() ([]Vulnerability, error) {
|
||||
matches, err := filepath.Glob(fs.sys.Path("devices/system/cpu/vulnerabilities/*"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
vulnerabilities := make([]Vulnerability, 0, len(matches))
|
||||
for _, match := range matches {
|
||||
name := filepath.Base(match)
|
||||
|
||||
value, err := ioutil.ReadFile(match)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
v, err := parseVulnerability(name, string(value))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
vulnerabilities = append(vulnerabilities, v)
|
||||
}
|
||||
|
||||
return vulnerabilities, nil
|
||||
}
|
||||
|
||||
// Vulnerability represents a single vulnerability extracted from /sys/devices/system/cpu/vulnerabilities/
|
||||
type Vulnerability struct {
|
||||
CodeName string
|
||||
State string
|
||||
Mitigation string
|
||||
}
|
||||
|
||||
func parseVulnerability(name, value string) (Vulnerability, error) {
|
||||
v := Vulnerability{CodeName: name}
|
||||
value = strings.TrimSpace(value)
|
||||
if value == notAffected {
|
||||
v.State = notAffected
|
||||
return v, nil
|
||||
}
|
||||
|
||||
if strings.HasPrefix(value, vulnerable) {
|
||||
v.State = vulnerable
|
||||
v.Mitigation = strings.TrimPrefix(strings.TrimPrefix(value, vulnerable), ": ")
|
||||
return v, nil
|
||||
}
|
||||
|
||||
if strings.HasPrefix(value, mitigation) {
|
||||
v.State = mitigation
|
||||
v.Mitigation = strings.TrimPrefix(strings.TrimPrefix(value, mitigation), ": ")
|
||||
return v, nil
|
||||
}
|
||||
|
||||
return v, fmt.Errorf("unknown vulnerability state for %s: %s", name, value)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue