@@ -41,61 +41,6 @@ cleanup()
4141 done
4242}
4343
44- ip -Version > /dev/null 2>&1
45- if [ $? -ne 0 ]; then
46- echo " SKIP: Could not run test without ip tool"
47- exit $ksft_skip
48- fi
49-
50- trap cleanup EXIT
51-
52- for i in " $ns1 " " $ns2 " " $ns3 " ; do
53- ip netns add $i || exit $ksft_skip
54- ip -net $i link set lo up
55- done
56-
57- echo " INFO: preparing interfaces."
58- # Three HSR nodes. Each node has one link to each of its neighbour, two links in total.
59- #
60- # ns1eth1 ----- ns2eth1
61- # hsr1 hsr2
62- # ns1eth2 ns2eth2
63- # | |
64- # ns3eth1 ns3eth2
65- # \ /
66- # hsr3
67- #
68- # Interfaces
69- ip link add ns1eth1 netns " $ns1 " type veth peer name ns2eth1 netns " $ns2 "
70- ip link add ns1eth2 netns " $ns1 " type veth peer name ns3eth1 netns " $ns3 "
71- ip link add ns3eth2 netns " $ns3 " type veth peer name ns2eth2 netns " $ns2 "
72-
73- # HSRv0.
74- ip -net " $ns1 " link add name hsr1 type hsr slave1 ns1eth1 slave2 ns1eth2 supervision 45 version 0 proto 0
75- ip -net " $ns2 " link add name hsr2 type hsr slave1 ns2eth1 slave2 ns2eth2 supervision 45 version 0 proto 0
76- ip -net " $ns3 " link add name hsr3 type hsr slave1 ns3eth1 slave2 ns3eth2 supervision 45 version 0 proto 0
77-
78- # IP for HSR
79- ip -net " $ns1 " addr add 100.64.0.1/24 dev hsr1
80- ip -net " $ns1 " addr add dead:beef:1::1/64 dev hsr1 nodad
81- ip -net " $ns2 " addr add 100.64.0.2/24 dev hsr2
82- ip -net " $ns2 " addr add dead:beef:1::2/64 dev hsr2 nodad
83- ip -net " $ns3 " addr add 100.64.0.3/24 dev hsr3
84- ip -net " $ns3 " addr add dead:beef:1::3/64 dev hsr3 nodad
85-
86- # All Links up
87- ip -net " $ns1 " link set ns1eth1 up
88- ip -net " $ns1 " link set ns1eth2 up
89- ip -net " $ns1 " link set hsr1 up
90-
91- ip -net " $ns2 " link set ns2eth1 up
92- ip -net " $ns2 " link set ns2eth2 up
93- ip -net " $ns2 " link set hsr2 up
94-
95- ip -net " $ns3 " link set ns3eth1 up
96- ip -net " $ns3 " link set ns3eth2 up
97- ip -net " $ns3 " link set hsr3 up
98-
9944# $1: IP address
10045is_v6 ()
10146{
@@ -164,93 +109,157 @@ stop_if_error()
164109 fi
165110}
166111
167-
168- echo " INFO: Initial validation ping."
169- # Each node has to be able each one.
170- do_ping " $ns1 " 100.64.0.2
171- do_ping " $ns2 " 100.64.0.1
172- do_ping " $ns3 " 100.64.0.1
173- stop_if_error " Initial validation failed."
174-
175- do_ping " $ns1 " 100.64.0.3
176- do_ping " $ns2 " 100.64.0.3
177- do_ping " $ns3 " 100.64.0.2
178-
179- do_ping " $ns1 " dead:beef:1::2
180- do_ping " $ns1 " dead:beef:1::3
181- do_ping " $ns2 " dead:beef:1::1
182- do_ping " $ns2 " dead:beef:1::2
183- do_ping " $ns3 " dead:beef:1::1
184- do_ping " $ns3 " dead:beef:1::2
185-
186- stop_if_error " Initial validation failed."
112+ do_complete_ping_test ()
113+ {
114+ echo " INFO: Initial validation ping."
115+ # Each node has to be able each one.
116+ do_ping " $ns1 " 100.64.0.2
117+ do_ping " $ns2 " 100.64.0.1
118+ do_ping " $ns3 " 100.64.0.1
119+ stop_if_error " Initial validation failed."
120+
121+ do_ping " $ns1 " 100.64.0.3
122+ do_ping " $ns2 " 100.64.0.3
123+ do_ping " $ns3 " 100.64.0.2
124+
125+ do_ping " $ns1 " dead:beef:1::2
126+ do_ping " $ns1 " dead:beef:1::3
127+ do_ping " $ns2 " dead:beef:1::1
128+ do_ping " $ns2 " dead:beef:1::2
129+ do_ping " $ns3 " dead:beef:1::1
130+ do_ping " $ns3 " dead:beef:1::2
131+
132+ stop_if_error " Initial validation failed."
187133
188134# Wait until supervisor all supervision frames have been processed and the node
189135# entries have been merged. Otherwise duplicate frames will be observed which is
190136# valid at this stage.
191- WAIT=5
192- while [ ${WAIT} -gt 0 ]
193- do
194- grep 00:00:00:00:00:00 /sys/kernel/debug/hsr/hsr* /node_table
195- if [ $? -ne 0 ]
196- then
197- break
198- fi
199- sleep 1
200- let " WAIT = WAIT - 1"
201- done
137+ WAIT=5
138+ while [ ${WAIT} -gt 0 ]
139+ do
140+ grep 00:00:00:00:00:00 /sys/kernel/debug/hsr/hsr* /node_table
141+ if [ $? -ne 0 ]
142+ then
143+ break
144+ fi
145+ sleep 1
146+ let " WAIT = WAIT - 1"
147+ done
202148
203149# Just a safety delay in case the above check didn't handle it.
204- sleep 1
150+ sleep 1
151+
152+ echo " INFO: Longer ping test."
153+ do_ping_long " $ns1 " 100.64.0.2
154+ do_ping_long " $ns1 " dead:beef:1::2
155+ do_ping_long " $ns1 " 100.64.0.3
156+ do_ping_long " $ns1 " dead:beef:1::3
157+
158+ stop_if_error " Longer ping test failed."
159+
160+ do_ping_long " $ns2 " 100.64.0.1
161+ do_ping_long " $ns2 " dead:beef:1::1
162+ do_ping_long " $ns2 " 100.64.0.3
163+ do_ping_long " $ns2 " dead:beef:1::2
164+ stop_if_error " Longer ping test failed."
165+
166+ do_ping_long " $ns3 " 100.64.0.1
167+ do_ping_long " $ns3 " dead:beef:1::1
168+ do_ping_long " $ns3 " 100.64.0.2
169+ do_ping_long " $ns3 " dead:beef:1::2
170+ stop_if_error " Longer ping test failed."
171+
172+ echo " INFO: Cutting one link."
173+ do_ping_long " $ns1 " 100.64.0.3 &
205174
206- echo " INFO: Longer ping test."
207- do_ping_long " $ns1 " 100.64.0.2
208- do_ping_long " $ns1 " dead:beef:1::2
209- do_ping_long " $ns1 " 100.64.0.3
210- do_ping_long " $ns1 " dead:beef:1::3
175+ sleep 3
176+ ip -net " $ns3 " link set ns3eth1 down
177+ wait
211178
212- stop_if_error " Longer ping test failed. "
179+ ip -net " $ns3 " link set ns3eth1 up
213180
214- do_ping_long " $ns2 " 100.64.0.1
215- do_ping_long " $ns2 " dead:beef:1::1
216- do_ping_long " $ns2 " 100.64.0.3
217- do_ping_long " $ns2 " dead:beef:1::2
218- stop_if_error " Longer ping test failed."
181+ stop_if_error " Failed with one link down."
219182
220- do_ping_long " $ns3 " 100.64.0.1
221- do_ping_long " $ns3 " dead:beef:1::1
222- do_ping_long " $ns3 " 100.64.0.2
223- do_ping_long " $ns3 " dead:beef:1::2
224- stop_if_error " Longer ping test failed."
183+ echo " INFO: Delay the link and drop a few packages."
184+ tc -net " $ns3 " qdisc add dev ns3eth1 root netem delay 50ms
185+ tc -net " $ns2 " qdisc add dev ns2eth1 root netem delay 5ms loss 25%
225186
226- echo " INFO: Cutting one link. "
227- do_ping_long " $ns1 " 100.64.0.3 &
187+ do_ping_long " $ns1 " 100.64.0.2
188+ do_ping_long " $ns1 " 100.64.0.3
228189
229- sleep 3
230- ip -net " $ns3 " link set ns3eth1 down
231- wait
190+ stop_if_error " Failed with delay and packetloss."
232191
233- ip -net " $ns3 " link set ns3eth1 up
192+ do_ping_long " $ns2 " 100.64.0.1
193+ do_ping_long " $ns2 " 100.64.0.3
234194
235- stop_if_error " Failed with one link down ."
195+ stop_if_error " Failed with delay and packetloss ."
236196
237- echo " INFO: Delay the link and drop a few packages. "
238- tc -net " $ns3 " qdisc add dev ns3eth1 root netem delay 50ms
239- tc -net " $ns2 " qdisc add dev ns2eth1 root netem delay 5ms loss 25%
197+ do_ping_long " $ns3 " 100.64.0.1
198+ do_ping_long " $ns3 " 100.64.0.2
199+ stop_if_error " Failed with delay and packetloss. "
240200
241- do_ping_long " $ns1 " 100.64.0.2
242- do_ping_long " $ns1 " 100.64.0.3
201+ echo " INFO: All good."
202+ }
203+
204+ setup_hsr_interfaces ()
205+ {
206+ echo " INFO: preparing interfaces."
207+ # Three HSR nodes. Each node has one link to each of its neighbour, two links in total.
208+ #
209+ # ns1eth1 ----- ns2eth1
210+ # hsr1 hsr2
211+ # ns1eth2 ns2eth2
212+ # | |
213+ # ns3eth1 ns3eth2
214+ # \ /
215+ # hsr3
216+ #
217+ # Interfaces
218+ ip link add ns1eth1 netns " $ns1 " type veth peer name ns2eth1 netns " $ns2 "
219+ ip link add ns1eth2 netns " $ns1 " type veth peer name ns3eth1 netns " $ns3 "
220+ ip link add ns3eth2 netns " $ns3 " type veth peer name ns2eth2 netns " $ns2 "
221+
222+ # HSRv0.
223+ ip -net " $ns1 " link add name hsr1 type hsr slave1 ns1eth1 slave2 ns1eth2 supervision 45 version 0 proto 0
224+ ip -net " $ns2 " link add name hsr2 type hsr slave1 ns2eth1 slave2 ns2eth2 supervision 45 version 0 proto 0
225+ ip -net " $ns3 " link add name hsr3 type hsr slave1 ns3eth1 slave2 ns3eth2 supervision 45 version 0 proto 0
226+
227+ # IP for HSR
228+ ip -net " $ns1 " addr add 100.64.0.1/24 dev hsr1
229+ ip -net " $ns1 " addr add dead:beef:1::1/64 dev hsr1 nodad
230+ ip -net " $ns2 " addr add 100.64.0.2/24 dev hsr2
231+ ip -net " $ns2 " addr add dead:beef:1::2/64 dev hsr2 nodad
232+ ip -net " $ns3 " addr add 100.64.0.3/24 dev hsr3
233+ ip -net " $ns3 " addr add dead:beef:1::3/64 dev hsr3 nodad
234+
235+ # All Links up
236+ ip -net " $ns1 " link set ns1eth1 up
237+ ip -net " $ns1 " link set ns1eth2 up
238+ ip -net " $ns1 " link set hsr1 up
239+
240+ ip -net " $ns2 " link set ns2eth1 up
241+ ip -net " $ns2 " link set ns2eth2 up
242+ ip -net " $ns2 " link set hsr2 up
243+
244+ ip -net " $ns3 " link set ns3eth1 up
245+ ip -net " $ns3 " link set ns3eth2 up
246+ ip -net " $ns3 " link set hsr3 up
247+ }
243248
244- stop_if_error " Failed with delay and packetloss."
249+ ip -Version > /dev/null 2>&1
250+ if [ $? -ne 0 ]; then
251+ echo " SKIP: Could not run test without ip tool"
252+ exit $ksft_skip
253+ fi
245254
246- do_ping_long " $ns2 " 100.64.0.1
247- do_ping_long " $ns2 " 100.64.0.3
255+ trap cleanup EXIT
248256
249- stop_if_error " Failed with delay and packetloss."
257+ for i in " $ns1 " " $ns2 " " $ns3 " ; do
258+ ip netns add $i || exit $ksft_skip
259+ ip -net $i link set lo up
260+ done
250261
251- do_ping_long " $ns3 " 100.64.0.1
252- do_ping_long " $ns3 " 100.64.0.2
253- stop_if_error " Failed with delay and packetloss."
262+ setup_hsr_interfaces
263+ do_complete_ping_test
254264
255- echo " INFO: All good."
256265exit $ret
0 commit comments