@@ -41,61 +41,6 @@ cleanup()
41
41
done
42
42
}
43
43
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
-
99
44
# $1: IP address
100
45
is_v6 ()
101
46
{
@@ -164,93 +109,168 @@ stop_if_error()
164
109
fi
165
110
}
166
111
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."
187
133
188
134
# Wait until supervisor all supervision frames have been processed and the node
189
135
# entries have been merged. Otherwise duplicate frames will be observed which is
190
136
# 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
202
148
203
149
# 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
205
157
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
158
+ stop_if_error " Longer ping test failed."
211
159
212
- stop_if_error " Longer ping test failed."
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."
213
165
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."
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."
219
171
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."
172
+ echo " INFO: Cutting one link."
173
+ do_ping_long " $ns1 " 100.64.0.3 &
225
174
226
- echo " INFO: Cutting one link."
227
- do_ping_long " $ns1 " 100.64.0.3 &
175
+ sleep 3
176
+ ip -net " $ns3 " link set ns3eth1 down
177
+ wait
228
178
229
- sleep 3
230
- ip -net " $ns3 " link set ns3eth1 down
231
- wait
179
+ ip -net " $ns3 " link set ns3eth1 up
232
180
233
- ip -net " $ns3 " link set ns3eth1 up
181
+ stop_if_error " Failed with one link down. "
234
182
235
- stop_if_error " Failed with one link down."
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%
236
186
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%
187
+ do_ping_long " $ns1 " 100.64.0.2
188
+ do_ping_long " $ns1 " 100.64.0.3
240
189
241
- do_ping_long " $ns1 " 100.64.0.2
242
- do_ping_long " $ns1 " 100.64.0.3
190
+ stop_if_error " Failed with delay and packetloss."
243
191
244
- stop_if_error " Failed with delay and packetloss."
192
+ do_ping_long " $ns2 " 100.64.0.1
193
+ do_ping_long " $ns2 " 100.64.0.3
245
194
246
- do_ping_long " $ns2 " 100.64.0.1
247
- do_ping_long " $ns2 " 100.64.0.3
195
+ stop_if_error " Failed with delay and packetloss."
248
196
249
- stop_if_error " Failed with delay and packetloss."
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."
200
+
201
+ echo " INFO: All good."
202
+ }
203
+
204
+ setup_hsr_interfaces ()
205
+ {
206
+ local HSRv=" $1 "
207
+
208
+ echo " INFO: preparing interfaces for HSRv${HSRv} ."
209
+ # Three HSR nodes. Each node has one link to each of its neighbour, two links in total.
210
+ #
211
+ # ns1eth1 ----- ns2eth1
212
+ # hsr1 hsr2
213
+ # ns1eth2 ns2eth2
214
+ # | |
215
+ # ns3eth1 ns3eth2
216
+ # \ /
217
+ # hsr3
218
+ #
219
+ # Interfaces
220
+ ip link add ns1eth1 netns " $ns1 " type veth peer name ns2eth1 netns " $ns2 "
221
+ ip link add ns1eth2 netns " $ns1 " type veth peer name ns3eth1 netns " $ns3 "
222
+ ip link add ns3eth2 netns " $ns3 " type veth peer name ns2eth2 netns " $ns2 "
223
+
224
+ # HSRv0/1
225
+ ip -net " $ns1 " link add name hsr1 type hsr slave1 ns1eth1 slave2 ns1eth2 supervision 45 version $HSRv proto 0
226
+ ip -net " $ns2 " link add name hsr2 type hsr slave1 ns2eth1 slave2 ns2eth2 supervision 45 version $HSRv proto 0
227
+ ip -net " $ns3 " link add name hsr3 type hsr slave1 ns3eth1 slave2 ns3eth2 supervision 45 version $HSRv proto 0
228
+
229
+ # IP for HSR
230
+ ip -net " $ns1 " addr add 100.64.0.1/24 dev hsr1
231
+ ip -net " $ns1 " addr add dead:beef:1::1/64 dev hsr1 nodad
232
+ ip -net " $ns2 " addr add 100.64.0.2/24 dev hsr2
233
+ ip -net " $ns2 " addr add dead:beef:1::2/64 dev hsr2 nodad
234
+ ip -net " $ns3 " addr add 100.64.0.3/24 dev hsr3
235
+ ip -net " $ns3 " addr add dead:beef:1::3/64 dev hsr3 nodad
236
+
237
+ # All Links up
238
+ ip -net " $ns1 " link set ns1eth1 up
239
+ ip -net " $ns1 " link set ns1eth2 up
240
+ ip -net " $ns1 " link set hsr1 up
241
+
242
+ ip -net " $ns2 " link set ns2eth1 up
243
+ ip -net " $ns2 " link set ns2eth2 up
244
+ ip -net " $ns2 " link set hsr2 up
245
+
246
+ ip -net " $ns3 " link set ns3eth1 up
247
+ ip -net " $ns3 " link set ns3eth2 up
248
+ ip -net " $ns3 " link set hsr3 up
249
+ }
250
+
251
+ ip -Version > /dev/null 2>&1
252
+ if [ $? -ne 0 ]; then
253
+ echo " SKIP: Could not run test without ip tool"
254
+ exit $ksft_skip
255
+ fi
256
+
257
+ trap cleanup EXIT
258
+
259
+ for i in " $ns1 " " $ns2 " " $ns3 " ; do
260
+ ip netns add $i || exit $ksft_skip
261
+ ip -net $i link set lo up
262
+ done
263
+
264
+ setup_hsr_interfaces 0
265
+ do_complete_ping_test
266
+ cleanup
267
+
268
+ for i in " $ns1 " " $ns2 " " $ns3 " ; do
269
+ ip netns add $i || exit $ksft_skip
270
+ ip -net $i link set lo up
271
+ done
250
272
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."
273
+ setup_hsr_interfaces 1
274
+ do_complete_ping_test
254
275
255
- echo " INFO: All good."
256
276
exit $ret
0 commit comments