Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
1
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
646cf7e
Breadcrumbs
linux
/
tools
/
testing
/
selftests
/
net
/
forwarding
/
ethtool_lib.sh
Blame
Blame
Latest commit
History
History
executable file
·
69 lines (58 loc) · 1.5 KB
Breadcrumbs
linux
/
tools
/
testing
/
selftests
/
net
/
forwarding
/
ethtool_lib.sh
Top
File metadata and controls
Code
Blame
executable file
·
69 lines (58 loc) · 1.5 KB
Raw
#!/bin/bash # SPDX-License-Identifier: GPL-2.0 speeds_arr_get() { cmd='/ETHTOOL_LINK_MODE_[^[:space:]]*_BIT[[:space:]]+=[[:space:]]+/ \ {sub(/,$/, "") \ sub(/ETHTOOL_LINK_MODE_/,"") \ sub(/_BIT/,"") \ sub(/_Full/,"/Full") \ sub(/_Half/,"/Half");\ print "["$1"]="$3}' awk "${cmd}" /usr/include/linux/ethtool.h } ethtool_set() { local cmd="$@" local out=$(ethtool -s $cmd 2>&1 | wc -l) check_err $out "error in configuration. $cmd" } dev_speeds_get() { local dev=$1; shift local with_mode=$1; shift local adver=$1; shift local speeds_str if (($adver)); then mode="Advertised link modes" else mode="Supported link modes" fi speeds_str=$(ethtool "$dev" | \ # Snip everything before the link modes section. sed -n '/'"$mode"':/,$p' | \ # Quit processing the rest at the start of the next section. # When checking, skip the header of this section (hence the 2,). sed -n '2,${/^[\t][^ \t]/q};p' | \ # Drop the section header of the current section. cut -d':' -f2) local -a speeds_arr=($speeds_str) if [[ $with_mode -eq 0 ]]; then for ((i=0; i<${#speeds_arr[@]}; i++)); do speeds_arr[$i]=${speeds_arr[$i]%base*} done fi echo ${speeds_arr[@]} } common_speeds_get() { dev1=$1; shift dev2=$1; shift with_mode=$1; shift adver=$1; shift local -a dev1_speeds=($(dev_speeds_get $dev1 $with_mode $adver)) local -a dev2_speeds=($(dev_speeds_get $dev2 $with_mode $adver)) comm -12 \ <(printf '%s\n' "${dev1_speeds[@]}" | sort -u) \ <(printf '%s\n' "${dev2_speeds[@]}" | sort -u) }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
You can’t perform that action at this time.