1 # SPDX-License-Identifier: GPL-2.0
8 local group_id
=$1; shift
9 local stats_get
=$1; shift
17 for ((dp
=0; dp
< 60000; dp
+= 10000)); do
19 local t0_rp12
=$
(link_stats_tx_packets_get
$rp12)
20 local t0_rp13
=$
(link_stats_tx_packets_get
$rp13)
21 local t0_nh1
=$
($stats_get $group_id $nh1_id)
22 local t0_nh2
=$
($stats_get $group_id $nh2_id)
25 $mz -q -p 64 -d 0 -t udp \
26 "sp=1024,dp=$((dp))-$((dp + 10000))"
29 local t1_rp12
=$
(link_stats_tx_packets_get
$rp12)
30 local t1_rp13
=$
(link_stats_tx_packets_get
$rp13)
31 local t1_nh1
=$
($stats_get $group_id $nh1_id)
32 local t1_nh2
=$
($stats_get $group_id $nh2_id)
34 local d_rp12
=$
((t1_rp12
- t0_rp12
))
35 local d_rp13
=$
((t1_rp13
- t0_rp13
))
36 local d_nh1
=$
((t1_nh1
- t0_nh1
))
37 local d_nh2
=$
((t1_nh2
- t0_nh2
))
39 dd=$
(absval $
((d_rp12
- d_nh1
)))
41 check_err $?
"Discrepancy between link and $stats_get: d_rp12=$d_rp12 d_nh1=$d_nh1"
43 dd=$
(absval $
((d_rp13
- d_nh2
)))
45 check_err $?
"Discrepancy between link and $stats_get: d_rp13=$d_rp13 d_nh2=$d_nh2"
48 log_test
"NH stats test $what"
51 nh_stats_test_dispatch_swhw
()
54 local nh1_id
=$1; shift
55 local nh2_id
=$1; shift
56 local group_id
=$1; shift
59 nh_stats_do_test
"$what" "$nh1_id" "$nh2_id" "$group_id" \
60 nh_stats_get
"${mz[@]}"
63 nh_stats_do_test
"HW $what" "$nh1_id" "$nh2_id" "$group_id" \
64 nh_stats_get_hw
"${mz[@]}"
67 nh_stats_test_dispatch
()
69 local nhgtype
=$1; shift
71 local nh1_id
=$1; shift
72 local nh2_id
=$1; shift
73 local group_id
=$1; shift
78 if ! ip nexthop
help 2>&1 |
grep -q hw_stats
; then
79 log_test_skip
"NH stats test: ip doesn't support HW stats"
83 ip nexthop replace id
$group_id group
$nh1_id/$nh2_id \
84 hw_stats on
type $nhgtype
85 enabled
=$
(ip
-s -j -d nexthop show id
$group_id |
86 jq
'.[].hw_stats.enabled')
87 if [[ $enabled == true
]]; then
88 nh_stats_test_dispatch_swhw
"$what" "$nh1_id" "$nh2_id" \
89 "$group_id" "${mz[@]}"
90 elif [[ $enabled == false
]]; then
91 check_err
1 "HW stats still disabled after enabling"
92 log_test
"NH stats test"
94 log_test_skip
"NH stats test: ip doesn't report hw_stats info"
97 ip nexthop replace id
$group_id group
$nh1_id/$nh2_id \
98 hw_stats off
type $nhgtype
103 local nhgtype
=$1; shift
105 sysctl_set net.ipv4.fib_multipath_hash_policy
1
106 nh_stats_test_dispatch
$nhgtype "IPv4" 101 102 103 \
107 $MZ $h1 -A 192.0.2.2 -B 198.51.100.2
108 sysctl_restore net.ipv4.fib_multipath_hash_policy
113 local nhgtype
=$1; shift
115 sysctl_set net.ipv6.fib_multipath_hash_policy
1
116 nh_stats_test_dispatch
$nhgtype "IPv6" 104 105 106 \
117 $MZ -6 $h1 -A 2001:db8
:1::2 -B 2001:db8
:2::2
118 sysctl_restore net.ipv6.fib_multipath_hash_policy
125 ip nexthop replace id
9999 group
"$nhid,65535" &>/dev
/null
127 log_test_skip
"16-bit multipath tests" \
128 "iproute2 or the kernel do not support 16-bit next hop weights"
131 ip nexthop del id
9999 ||
: