-
Notifications
You must be signed in to change notification settings - Fork 13
/
test-ovs-vxlan-remove-tunnel-during-traffic.sh
executable file
·129 lines (105 loc) · 3.14 KB
/
test-ovs-vxlan-remove-tunnel-during-traffic.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash
#
# Test ovs with vxlan
# Remove vxlan tunnel interface during traffic on the receive side.
# Related upstream commit:
# 8e1da73acded gro_cell: add napi_disable in gro_cells_destroy
#
# Bug SW #1609215: kernel crash removing vxlan tunnel interface during traffic
#
my_dir="$(dirname "$0")"
. $my_dir/common.sh
VM1_IP="7.7.7.1"
VM2_IP="7.7.7.2"
local_tun="2.2.2.2"
remote_tun="2.2.2.3"
vxlan_port=4789
function cleanup() {
stop_traffic &>/dev/null
ovs_clear_bridges
ip l del dev vxlan_sys_4789 &>/dev/null
ip netns del ns0 &> /dev/null
for i in `seq 0 3`; do
ip link del veth$i &> /dev/null
done
}
function config_vxlan() {
ip netns exec ns0 ip link add name vxlan42 type vxlan id 42 dev veth3 remote $local_tun dstport $vxlan_port
ip netns exec ns0 ifconfig vxlan42 $VM2_IP/24 up
}
function config_ns() {
echo "setup veth and ns"
ip link add veth0 type veth peer name veth1 || fail "Failed to configure veth"
ip link add veth2 type veth peer name veth3
ifconfig veth0 $VM1_IP/24 up
ifconfig veth1 up
ifconfig veth2 $local_tun/24 up
ip netns add ns0
ip link set veth3 netns ns0
ip netns exec ns0 ifconfig veth3 $remote_tun/24 up
}
function config_ovs() {
echo "setup ovs dst_port:$vxlan_port"
start_clean_openvswitch
ovs-vsctl add-br brv-1
ovs-vsctl add-port brv-1 veth1
ovs-vsctl add-port brv-1 vxlan0 -- set interface vxlan0 type=vxlan options:local_ip=$local_tun options:remote_ip=$remote_tun options:key=42 options:dst_port=$vxlan_port
}
function get_vxlan_rx_pkt_count() {
ip netns exec ns0 ip -s link show dev vxlan42 | grep RX: -A1 | tail -1 | awk {'print $2'}
}
function stop_traffic() {
echo "stop traffic"
killall -q -9 iperf &>/dev/null
# killall -9 noodle &>/dev/null
wait &>/dev/null
}
function start_traffic() {
# expecting issue to reproduce when we have at least ~90kpps
iperf -u -c $VM2_IP -b 1G -P 8 -t $runtime &>/dev/null &
sleep 4
# noodle commands that also help reproduce the issue
# $my_dir/noodle -c $VM2_IP -b 150 -p 9999 -C 10000 -n 5000 &
# $my_dir/noodle -c $VM2_IP -b 50 -p 9999 -C 5000 -n 5000 &
}
function start_test() {
title "Test destroy vxlan interface during traffic"
config_ns
config_vxlan
config_ovs
runtime=60
echo "start traffic $VM1_IP -> $VM2_IP"
local i
for i in `seq 3`; do
start_traffic
# we dont use iperf server and sometimes iperf exists. just run it again.
if pidof iperf &>/dev/null ; then
break
fi
echo "retry"
done
let runtime=runtime-4
start1=`get_time`
while true ; do
stats=`get_vxlan_rx_pkt_count`
echo "stats $stats"
if [ "$stats" == "0" ]; then
err "Zero stats on vxlan interface"
break
fi
ip netns exec ns0 ip link del dev vxlan42 || err "Failed to remove tunnel interface"
config_vxlan
sleep 1
loop=`get_time`
let loop=loop-start1
if [ $loop -ge $runtime ]; then
break
fi
done
stop_traffic
cleanup
}
trap cleanup EXIT
cleanup
start_test
test_done