-
Notifications
You must be signed in to change notification settings - Fork 10
/
test-tc-shuffle-cls_api.sh
executable file
·87 lines (71 loc) · 1.83 KB
/
test-tc-shuffle-cls_api.sh
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
#
# reload module act_gact before adding rules to get into the request_module flow in gact
# which will return EAGAIN and expose bug in cls_api module.
#
# Bug SW #1294281: [ASAP MLNX OFED] kernel crash adding drop rules when act_gact is not loaded
#
NIC=${1:-ens5f0}
my_dir="$(dirname "$0")"
. $my_dir/common.sh
TMPFILE=/tmp/rules-$$
RUNFILE=/tmp/test-$$
RULE_COUNT=${RULE_COUNT:-100}
GROUP_COUNT=${GROUP_COUNT:-50}
ROUND_COUNT=${ROUND_COUNT:-50}
rm -f $TMPFILE
rm -f $RUNFILE
title "Test"
title "- generate rules"
# c is count of rules added
c=1
for p1 in {1..30}; do
p2=25
echo "tc filter add dev $NIC parent ffff: protocol ip pref $c handle $c flower skip_hw action drop 2>/dev/null"
let c++
if [ $((c/2)) -gt $GROUP_COUNT ]; then
break
fi
done >> $TMPFILE
let c--
for j in `seq $c`; do
echo "tc filter del dev $NIC parent ffff: pref $j 2>/dev/null"
done >> $TMPFILE
title "- generate script"
for r in `seq $ROUND_COUNT`; do
echo "function round_$r() {"
for p in `seq $RULE_COUNT`; do
echo -n " "; shuf -n 1 $TMPFILE
echo " logf \$1 $p \$?"
done
echo "}"
done >> $RUNFILE
cat >>$RUNFILE <<EOF
function logf() {
#if [ "\$3" != 0 ]; then
# echo "tc cmd failed at \$2 (round \$1)"
#fi
now=\`date +"%s"\`
sec=\`echo \$now - \$_start_ts + 1 | bc\`
journalctl --since="\$sec seconds ago" | grep WARN && echo "failed at \$2 (round \$1)" && exit 1
}
sleep 1
_start_ts=\`date +"%s"\`
tc qdisc del dev $NIC ingress 2>/dev/null
set -e
tc qdisc add dev $NIC ingress
modprobe -rv cls_flower act_gact
set +e
for i in \`seq $ROUND_COUNT\`; do
eval "round_\$i \$i" &
#echo "round \$i/$ROUND_COUNT complete"
done
wait
tc qdisc del dev $NIC ingress
echo "done"
EOF
title "- execute"
bash $RUNFILE || fail "script $RUNFILE failed."
rm -f $TMPFILE
rm -f $RUNFILE
test_done