Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/tests/sys/netinet6/output6.sh
39482 views
1
#!/usr/bin/env atf-sh
2
#-
3
# SPDX-License-Identifier: BSD-2-Clause
4
#
5
# Copyright (c) 2020 Alexander V. Chernikov
6
#
7
# Redistribution and use in source and binary forms, with or without
8
# modification, are permitted provided that the following conditions
9
# are met:
10
# 1. Redistributions of source code must retain the above copyright
11
# notice, this list of conditions and the following disclaimer.
12
# 2. Redistributions in binary form must reproduce the above copyright
13
# notice, this list of conditions and the following disclaimer in the
14
# documentation and/or other materials provided with the distribution.
15
#
16
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26
# SUCH DAMAGE.
27
#
28
#
29
30
. $(atf_get_srcdir)/../common/vnet.subr
31
32
atf_test_case "output6_tcp_setup_success" "cleanup"
33
output6_tcp_setup_success_head()
34
{
35
36
atf_set descr 'Test valid IPv6 TCP output'
37
atf_set require.user root
38
}
39
40
output6_tcp_setup_success_body()
41
{
42
43
vnet_init
44
45
net_src="2001:db8:0:0:1::"
46
net_dst="2001:db8:0:0:1::"
47
ip_src="${net_src}1"
48
ip_dst=${net_dst}4242
49
plen=64
50
text="testtesttst"
51
port=4242
52
53
script_name=`dirname $0`/../common/net_receiver.py
54
script_name=`realpath ${script_name}`
55
jname="v6t-output6_tcp_setup_success"
56
57
epair=$(vnet_mkepair)
58
59
vnet_mkjail ${jname}a ${epair}a
60
jexec ${jname}a ifconfig ${epair}a up
61
jexec ${jname}a ifconfig ${epair}a inet6 ${ip_src}/${plen}
62
63
vnet_mkjail ${jname}b ${epair}b
64
jexec ${jname}b ifconfig ${epair}b up
65
66
jexec ${jname}b ifconfig ${epair}b inet6 ${ip_dst}/${plen}
67
68
# wait for DAD to complete
69
while [ `jexec ${jname}b ifconfig ${epair}b inet6 | grep -c tentative` != "0" ]; do
70
sleep 0.1
71
done
72
while [ `jexec ${jname}a ifconfig ${epair}a inet6 | grep -c tentative` != "0" ]; do
73
sleep 0.1
74
done
75
76
# run listener
77
args="--family inet6 --ports ${port} --match_str ${text}"
78
echo jexec ${jname}b ${script_name} ${args}
79
jexec ${jname}b ${script_name} --test_name "test_listen_tcp" ${args} &
80
cmd_pid=$!
81
82
# wait for the script init
83
counter=0
84
while [ `jexec ${jname}b sockstat -6qlp ${port} | wc -l` != "1" ]; do
85
sleep 0.01
86
counter=$((counter+1))
87
if [ ${counter} -ge 50 ]; then break; fi
88
done
89
if [ `jexec ${jname}b sockstat -6qlp ${port} | wc -l` != "1" ]; then
90
echo "App setup failed"
91
exit 1
92
fi
93
94
# run sender
95
echo -n "${text}" | jexec ${jname}a nc -N ${ip_dst} ${port}
96
exit_code=$?
97
if [ $exit_code -ne 0 ]; then atf_fail "sender exit code $exit_code" ; fi
98
99
wait ${cmd_pid}
100
exit_code=$?
101
if [ $exit_code -ne 0 ]; then atf_fail "receiver exit code $exit_code" ; fi
102
}
103
104
output6_tcp_setup_success_cleanup()
105
{
106
vnet_cleanup
107
}
108
109
110
atf_test_case "output6_udp_setup_success" "cleanup"
111
output6_udp_setup_success_head()
112
{
113
114
atf_set descr 'Test valid IPv6 UDP output'
115
atf_set require.user root
116
}
117
118
output6_udp_setup_success_body()
119
{
120
121
vnet_init
122
123
net_src="2001:db8:0:0:1::"
124
net_dst="2001:db8:0:0:1::"
125
ip_src="${net_src}1"
126
ip_dst=${net_dst}4242
127
plen=64
128
text="testtesttst"
129
port=4242
130
131
script_name=`dirname $0`/../common/net_receiver.py
132
script_name=`realpath ${script_name}`
133
jname="v6t-output6_udp_setup_success"
134
135
epair=$(vnet_mkepair)
136
137
vnet_mkjail ${jname}a ${epair}a
138
jexec ${jname}a ifconfig ${epair}a up
139
jexec ${jname}a ifconfig ${epair}a inet6 ${ip_src}/${plen}
140
141
vnet_mkjail ${jname}b ${epair}b
142
jexec ${jname}b ifconfig ${epair}b up
143
jexec ${jname}b ifconfig ${epair}b inet6 ${ip_dst}/${plen}
144
145
# wait for DAD to complete
146
while [ `jexec ${jname}b ifconfig ${epair}b inet6 | grep -c tentative` != "0" ]; do
147
sleep 0.1
148
done
149
while [ `jexec ${jname}a ifconfig ${epair}a inet6 | grep -c tentative` != "0" ]; do
150
sleep 0.1
151
done
152
153
# run listener
154
args="--family inet6 --ports ${port} --match_str ${text}"
155
echo jexec ${jname}b ${script_name} ${args}
156
jexec ${jname}b ${script_name} --test_name "test_listen_udp" ${args} &
157
cmd_pid=$!
158
159
# wait for the script init
160
counter=0
161
while [ `jexec ${jname}b sockstat -6qlp ${port} | wc -l` != "1" ]; do
162
sleep 0.1
163
counterc=$((counter+1))
164
if [ ${counter} -ge 50 ]; then break; fi
165
done
166
if [ `jexec ${jname}b sockstat -6qlp ${port} | wc -l` != "1" ]; then
167
echo "App setup failed"
168
exit 1
169
fi
170
171
# run sender
172
# TODO: switch from nc to some alternative to avoid 1-second delay
173
echo -n "${text}" | jexec ${jname}a nc -uNw1 ${ip_dst} ${port}
174
exit_code=$?
175
if [ $exit_code -ne 0 ]; then atf_fail "sender exit code $exit_code" ; fi
176
177
wait ${cmd_pid}
178
exit_code=$?
179
if [ $exit_code -ne 0 ]; then atf_fail "receiver exit code $exit_code" ; fi
180
}
181
182
output6_udp_setup_success_cleanup()
183
{
184
vnet_cleanup
185
}
186
187
atf_test_case "output6_raw_success" "cleanup"
188
output6_raw_success_head()
189
{
190
191
atf_set descr 'Test valid IPv6 raw output'
192
atf_set require.user root
193
}
194
195
output6_raw_success_body()
196
{
197
198
vnet_init
199
200
net_src="2001:db8:0:0:1::"
201
net_dst="2001:db8:0:0:1::"
202
ip_src="${net_src}1"
203
ip_dst=${net_dst}4242
204
plen=64
205
206
script_name=`dirname $0`/../common/net_receiver.py
207
script_name=`realpath ${script_name}`
208
jname="v6t-output6_raw_success"
209
210
epair=$(vnet_mkepair)
211
212
vnet_mkjail ${jname}a ${epair}a
213
jexec ${jname}a ifconfig ${epair}a up
214
jexec ${jname}a ifconfig ${epair}a inet6 ${ip_src}/${plen}
215
216
vnet_mkjail ${jname}b ${epair}b
217
jexec ${jname}b ifconfig ${epair}b up
218
219
jexec ${jname}b ifconfig ${epair}b inet6 ${ip_dst}/${plen}
220
221
# wait for DAD to complete
222
while [ `jexec ${jname}b ifconfig ${epair}b inet6 | grep -c tentative` != "0" ]; do
223
sleep 0.1
224
done
225
while [ `jexec ${jname}a ifconfig ${epair}a inet6 | grep -c tentative` != "0" ]; do
226
sleep 0.1
227
done
228
229
atf_check -o match:'1 packets transmitted, 1 packets received' jexec ${jname}a ping -6 -nc1 ${ip_dst}
230
}
231
232
output6_raw_success_cleanup()
233
{
234
vnet_cleanup
235
}
236
237
# Multipath tests are done the following way:
238
# epair0/LL
239
# jailA lo/GU < > lo/GU jailB
240
# epair1/LL
241
# jailA has 2 routes towards /64 prefix on jailB loopback, via 2 epairs
242
# jailB has 1 route towards /64 prefix on jailA loopback, via epair0
243
#
244
# jailA initiates connections/sends packets towards IPs on jailB loopback.
245
# Script then compares amount of packets sent via epair0 and epair1
246
247
mpath_check()
248
{
249
if [ `sysctl -iW net.route.multipath | wc -l` != "1" ]; then
250
atf_skip "This test requires ROUTE_MPATH enabled"
251
fi
252
}
253
254
mpath_enable()
255
{
256
jexec $1 sysctl net.route.multipath=1
257
if [ $? != 0 ]; then
258
atf_fail "Setting multipath in jail $1 failed".
259
fi
260
}
261
262
263
atf_test_case "output6_tcp_flowid_mpath_success" "cleanup"
264
output6_tcp_flowid_mpath_success_head()
265
{
266
267
atf_set descr 'Test valid IPv6 TCP output flowid generation'
268
atf_set require.user root
269
}
270
271
output6_tcp_flowid_mpath_success_body()
272
{
273
vnet_init
274
mpath_check
275
276
net_src="2001:db8:0:1"
277
net_dst="2001:db8:0:2"
278
ip_src="${net_src}::1"
279
ip_dst="${net_dst}::1"
280
plen=64
281
text="testtesttst"
282
283
script_name=`dirname $0`/../common/net_receiver.py
284
script_name=`realpath ${script_name}`
285
jname="v6t-output6_tcp_flowid_mpath_success"
286
287
epair0=$(vnet_mkepair)
288
epair1=$(vnet_mkepair)
289
lo_src=$(vnet_mkloopback)
290
lo_dst=$(vnet_mkloopback)
291
292
vnet_mkjail ${jname}a ${epair0}a ${epair1}a ${lo_src}
293
mpath_enable ${jname}a
294
jls -N
295
# enable link-local IPv6
296
jexec ${jname}a ndp -i ${epair0}a -- -disabled
297
jexec ${jname}a ifconfig ${epair0}a up
298
jexec ${jname}a ndp -i ${epair1}a -- -disabled
299
jexec ${jname}a ifconfig ${epair1}a up
300
jexec ${jname}a ifconfig ${lo_src} up
301
302
vnet_mkjail ${jname}b ${epair0}b ${epair1}b ${lo_dst}
303
jls -N
304
jexec ${jname}b ndp -i ${epair0}b -- -disabled
305
jexec ${jname}b ifconfig ${epair0}b up
306
jexec ${jname}b ndp -i ${epair1}b -- -disabled
307
jexec ${jname}b ifconfig ${epair1}b up
308
jexec ${jname}b ifconfig ${lo_dst} up
309
310
# DST ips/ports to test
311
ips="d3:c4:eb:40 2b:ff:dd:52 b1:d4:44:0e 41:2c:4d:43 66:4a:b4:be 8b:da:ac:f7 ca:d1:c4:f0 b1:31:da:d7 0c:ac:45:7a 44:9c:ce:71"
312
ports="53540 49743 43067 9131 16734 5150 14379 40292 20634 51302 3387 24387 9282 14275 42103 26881 42461 29520 45714 11096"
313
314
jexec ${jname}a ifconfig ${lo_src} inet6 ${ip_src}/128
315
316
jexec ${jname}b ifconfig ${lo_dst} inet6 ${ip_dst}/128
317
for i in ${ips}; do
318
jexec ${jname}b ifconfig ${lo_dst} inet6 ${net_dst}:${i}/128
319
done
320
321
# wait for DAD to complete
322
while [ `jexec ${jname}b ifconfig | grep inet6 | grep -c tentative` != "0" ]; do
323
sleep 0.1
324
done
325
while [ `jexec ${jname}a ifconfig | grep inet6 | grep -c tentative` != "0" ]; do
326
sleep 0.1
327
done
328
329
# Add routes
330
# A -> towards B via epair0a LL
331
ll=`jexec ${jname}b ifconfig ${epair0}b inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'`
332
jexec ${jname}a route add -6 -net ${net_dst}::/${plen} ${ll}%${epair0}a
333
# A -> towards B via epair1a LL
334
ll=`jexec ${jname}b ifconfig ${epair1}b inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'`
335
jexec ${jname}a route add -6 -net ${net_dst}::/${plen} ${ll}%${epair1}a
336
337
# B towards A via epair0b LL
338
ll=`jexec ${jname}a ifconfig ${epair1}a inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'`
339
jexec ${jname}b route add -6 -net ${net_src}::/${plen} ${ll}%${epair1}b
340
341
# Base setup verification
342
atf_check -o match:'1 packets transmitted, 1 packets received' jexec ${jname}a ping -6 -c1 ${ip_dst}
343
344
# run listener
345
num_ports=`echo ${ports} | wc -w`
346
num_ips=`echo ${ips} | wc -w`
347
count_examples=$((num_ports*num_ips))
348
listener_ports=`echo ${ports} | tr ' ' '\n' | sort -n | tr '\n' ',' | sed -e 's?,$??'`
349
args="--family inet6 --ports ${listener_ports} --count ${count_examples} --match_str ${text}"
350
echo jexec ${jname}b ${script_name} ${args}
351
jexec ${jname}b ${script_name} --test_name "test_listen_tcp" ${args} &
352
cmd_pid=$!
353
354
# wait for the app init
355
counter=0
356
init=0
357
while [ ${counter} -le 50 ]; do
358
_ports=`jexec ${jname}b sockstat -6ql | awk "\\\$3 == ${cmd_pid} {print \\\$6}"|awk -F: "{print \\\$2}" | sort -n | tr '\n' ','`
359
if [ "${_ports}" = "${listener_ports}," ]; then
360
init=1
361
break;
362
fi
363
done
364
if [ ${init} -eq 0 ]; then
365
jexec ${jname}b sockstat -6ql | awk "\$3 == ${cmd_pid}"
366
echo "App setup failed"
367
exit 1
368
fi
369
echo "App setup done"
370
371
# run sender
372
for _ip in ${ips}; do
373
ip="${net_dst}:${_ip}"
374
for port in ${ports}; do
375
echo -n "${text}" | jexec ${jname}a nc -nN ${ip} ${port}
376
exit_code=$?
377
if [ $exit_code -ne 0 ]; then atf_fail "sender exit code $exit_code" ; fi
378
done
379
done
380
381
wait ${cmd_pid}
382
exit_code=$?
383
if [ $exit_code -ne 0 ]; then atf_fail "receiver exit code $exit_code" ; fi
384
385
pkt_0=`jexec ${jname}a netstat -Wf link -I ${epair0}a | head | awk '$1!~/^Name/{print$8}'`
386
pkt_1=`jexec ${jname}a netstat -Wf link -I ${epair1}a | head | awk '$1!~/^Name/{print$8}'`
387
if [ ${pkt_0} -le 10 ]; then
388
atf_fail "Balancing failure: 1: ${pkt_0} 2: ${pkt_1}"
389
fi
390
if [ ${pkt_1} -le 10 ]; then
391
atf_fail "Balancing failure: 1: ${pkt_0} 2: ${pkt_1}"
392
fi
393
echo "TCP Balancing: 1: ${pkt_0} 2: ${pkt_1}"
394
}
395
396
output6_tcp_flowid_mpath_success_cleanup()
397
{
398
vnet_cleanup
399
}
400
401
atf_test_case "output6_udp_flowid_mpath_success" "cleanup"
402
output6_udp_flowid_mpath_success_head()
403
{
404
405
atf_set descr 'Test valid IPv6 UDP output flowid generation'
406
atf_set require.user root
407
}
408
409
output6_udp_flowid_mpath_success_body()
410
{
411
412
vnet_init
413
mpath_check
414
415
# Note this test will spawn around ~100 nc processes
416
417
net_src="2001:db8:0:1"
418
net_dst="2001:db8:0:2"
419
ip_src="${net_src}::1"
420
ip_dst="${net_dst}::1"
421
plen=64
422
text="testtesttst"
423
424
script_name=`dirname $0`/../common/net_receiver.py
425
script_name=`realpath ${script_name}`
426
jname="v6t-output6_udp_flowid_mpath_success"
427
428
epair0=$(vnet_mkepair)
429
epair1=$(vnet_mkepair)
430
lo_src=$(vnet_mkloopback)
431
lo_dst=$(vnet_mkloopback)
432
433
vnet_mkjail ${jname}a ${epair0}a ${epair1}a ${lo_src}
434
mpath_enable ${jname}a
435
jls -N
436
# enable link-local IPv6
437
jexec ${jname}a ndp -i ${epair0}a -- -disabled
438
jexec ${jname}a ifconfig ${epair0}a up
439
jexec ${jname}a ndp -i ${epair1}a -- -disabled
440
jexec ${jname}a ifconfig ${epair1}a up
441
jexec ${jname}a ifconfig ${lo_src} up
442
443
vnet_mkjail ${jname}b ${epair0}b ${epair1}b ${lo_dst}
444
jls -N
445
jexec ${jname}b ndp -i ${epair0}b -- -disabled
446
jexec ${jname}b ifconfig ${epair0}b up
447
jexec ${jname}b ndp -i ${epair1}b -- -disabled
448
jexec ${jname}b ifconfig ${epair1}b up
449
jexec ${jname}b ifconfig ${lo_dst} up
450
451
# DST ips/ports to test
452
ips="d3:c4:eb:40 2b:ff:dd:52 b1:d4:44:0e 41:2c:4d:43 66:4a:b4:be 8b:da:ac:f7 ca:d1:c4:f0 b1:31:da:d7 0c:ac:45:7a 44:9c:ce:71"
453
ports="53540 49743 43067 9131 16734 5150 14379 40292 20634 51302 3387 24387 9282 14275 42103 26881 42461 29520 45714 11096"
454
455
jexec ${jname}a ifconfig ${lo_src} inet6 ${ip_src}/128
456
457
jexec ${jname}b ifconfig ${lo_dst} inet6 ${ip_dst}/128
458
for i in ${ips}; do
459
jexec ${jname}b ifconfig ${lo_dst} inet6 ${net_dst}:${i}/128
460
done
461
462
463
# wait for DAD to complete
464
while [ `jexec ${jname}b ifconfig | grep inet6 | grep -c tentative` != "0" ]; do
465
sleep 0.1
466
done
467
while [ `jexec ${jname}a ifconfig | grep inet6 | grep -c tentative` != "0" ]; do
468
sleep 0.1
469
done
470
471
# Add routes
472
# A -> towards B via epair0a LL
473
ll=`jexec ${jname}b ifconfig ${epair0}b inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'`
474
jexec ${jname}a route add -6 -net ${net_dst}::/${plen} ${ll}%${epair0}a
475
# A -> towards B via epair1a LL
476
ll=`jexec ${jname}b ifconfig ${epair1}b inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'`
477
jexec ${jname}a route add -6 -net ${net_dst}::/${plen} ${ll}%${epair1}a
478
479
# B towards A via epair0b LL
480
ll=`jexec ${jname}a ifconfig ${epair1}a inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'`
481
jexec ${jname}b route add -6 -net ${net_src}::/${plen} ${ll}%${epair1}b
482
483
# Base setup verification
484
atf_check -o match:'1 packets transmitted, 1 packets received' jexec ${jname}a ping -6 -c1 ${ip_dst}
485
486
# run listener
487
num_ports=`echo ${ports} | wc -w`
488
num_ips=`echo ${ips} | wc -w`
489
count_examples=$((num_ports*num_ips))
490
listener_ports=`echo ${ports} | tr ' ' '\n' | sort -n | tr '\n' ',' | sed -e 's?,$??'`
491
args="--family inet6 --ports ${listener_ports} --count ${count_examples} --match_str ${text}"
492
echo jexec ${jname}b ${script_name} ${args}
493
jexec ${jname}b ${script_name} --test_name "test_listen_udp" ${args} &
494
cmd_pid=$!
495
496
# wait for the app init
497
counter=0
498
init=0
499
while [ ${counter} -le 50 ]; do
500
_ports=`jexec ${jname}b sockstat -6ql | awk "\\\$3 == ${cmd_pid} {print \\\$6}"|awk -F: "{print \\\$2}" | sort -n | tr '\n' ','`
501
if [ "${_ports}" = "${listener_ports}," ]; then
502
init=1
503
break;
504
fi
505
done
506
if [ ${init} -eq 0 ]; then
507
jexec ${jname}b sockstat -6ql | awk "\$3 == ${cmd_pid}"
508
echo "App setup failed"
509
exit 1
510
fi
511
echo "App setup done"
512
513
# run sender
514
for _ip in ${ips}; do
515
ip="${net_dst}:${_ip}"
516
for port in ${ports}; do
517
# XXX: switch to something that allows immediate exit
518
echo -n "${text}" | jexec ${jname}a nc -nuNw1 ${ip} ${port} &
519
sleep 0.01
520
done
521
done
522
523
wait ${cmd_pid}
524
exit_code=$?
525
if [ $exit_code -ne 0 ]; then atf_fail "receiver exit code $exit_code" ; fi
526
527
pkt_0=`jexec ${jname}a netstat -Wf link -I ${epair0}a | head | awk '$1!~/^Name/{print$8}'`
528
pkt_1=`jexec ${jname}a netstat -Wf link -I ${epair1}a | head | awk '$1!~/^Name/{print$8}'`
529
if [ ${pkt_0} -le 10 ]; then
530
atf_fail "Balancing failure: 1: ${pkt_0} 2: ${pkt_1}"
531
fi
532
if [ ${pkt_1} -le 10 ]; then
533
atf_fail "Balancing failure: 1: ${pkt_0} 2: ${pkt_1}"
534
fi
535
echo "UDP BALANCING: 1: ${pkt_0} 2: ${pkt_1}"
536
}
537
538
output6_udp_flowid_mpath_success_cleanup()
539
{
540
vnet_cleanup
541
}
542
543
atf_test_case "output6_raw_flowid_mpath_success" "cleanup"
544
output6_raw_flowid_mpath_success_head()
545
{
546
547
atf_set descr 'Test valid IPv6 raw output flowid generation'
548
atf_set require.user root
549
}
550
551
output6_raw_flowid_mpath_success_body()
552
{
553
554
vnet_init
555
mpath_check
556
557
net_src="2001:db8:0:1"
558
net_dst="2001:db8:0:2"
559
ip_src="${net_src}::1"
560
ip_dst="${net_dst}::1"
561
plen=64
562
text="testtesttst"
563
564
jname="v6t-output6_raw_flowid_mpath_success"
565
566
epair0=$(vnet_mkepair)
567
epair1=$(vnet_mkepair)
568
lo_src=$(vnet_mkloopback)
569
lo_dst=$(vnet_mkloopback)
570
571
vnet_mkjail ${jname}a ${epair0}a ${epair1}a ${lo_src}
572
mpath_enable ${jname}a
573
jls -N
574
# enable link-local IPv6
575
jexec ${jname}a ndp -i ${epair0}a -- -disabled
576
jexec ${jname}a ifconfig ${epair0}a up
577
jexec ${jname}a ndp -i ${epair1}a -- -disabled
578
jexec ${jname}a ifconfig ${epair1}a up
579
jexec ${jname}a ifconfig ${lo_src} up
580
581
vnet_mkjail ${jname}b ${epair0}b ${epair1}b ${lo_dst}
582
jls -N
583
jexec ${jname}b ndp -i ${epair0}b -- -disabled
584
jexec ${jname}b ifconfig ${epair0}b up
585
jexec ${jname}b ndp -i ${epair1}b -- -disabled
586
jexec ${jname}b ifconfig ${epair1}b up
587
jexec ${jname}b ifconfig ${lo_dst} up
588
589
# DST ips to test
590
ips="9d:33:f2:7f 48:06:9a:0b cf:96:d5:78 76:da:8e:28 d4:66:38:1e ec:43:da:7c bb:f8:93:2f d3:c4:eb:40"
591
ips="${ips} c7:31:0e:ae 8d:ed:35:2e c0:e0:22:31 82:1c:4e:28 c1:00:60:3e 6a:4f:3b:6c 8e:a7:e9:57 2b:ff:dd:52"
592
ips="${ips} 88:44:79:5d 80:62:83:11 c8:e4:17:a6 e7:2a:45:d7 5a:92:0e:04 70:fc:6a:ee ce:24:4c:68 41:2c:4d:43"
593
ips="${ips} 57:2b:5e:a7 f9:e0:69:c6 cb:b9:e6:ed 28:88:5d:fa d6:19:ac:1d dc:de:37:d8 fe:39:55:c7 b1:31:da:d7"
594
595
jexec ${jname}a ifconfig ${lo_src} inet6 ${ip_src}/128
596
597
jexec ${jname}b ifconfig ${lo_dst} inet6 ${ip_dst}/128
598
for i in ${ips}; do
599
jexec ${jname}b ifconfig ${lo_dst} inet6 ${net_dst}:${i}/128
600
done
601
602
# wait for DAD to complete
603
while [ `jexec ${jname}b ifconfig | grep inet6 | grep -c tentative` != "0" ]; do
604
sleep 0.1
605
done
606
while [ `jexec ${jname}a ifconfig | grep inet6 | grep -c tentative` != "0" ]; do
607
sleep 0.1
608
done
609
610
# Add routes
611
# A -> towards B via epair0a LL
612
ll=`jexec ${jname}b ifconfig ${epair0}b inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'`
613
jexec ${jname}a route add -6 -net ${net_dst}::/${plen} ${ll}%${epair0}a
614
# A -> towards B via epair1a LL
615
ll=`jexec ${jname}b ifconfig ${epair1}b inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'`
616
jexec ${jname}a route add -6 -net ${net_dst}::/${plen} ${ll}%${epair1}a
617
618
# B towards A via epair0b LL
619
ll=`jexec ${jname}a ifconfig ${epair1}a inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'`
620
jexec ${jname}b route add -6 -net ${net_src}::/${plen} ${ll}%${epair1}b
621
622
# Base setup verification
623
atf_check -o match:'1 packets transmitted, 1 packets received' jexec ${jname}a ping -6 -nc1 ${ip_dst}
624
625
# run sender
626
valid_message='1 packets transmitted, 1 packets received'
627
for _ip in ${ips}; do
628
ip="${net_dst}:${_ip}"
629
atf_check -o match:"${valid_message}" jexec ${jname}a ping -6 -nc1 ${ip}
630
done
631
632
pkt_0=`jexec ${jname}a netstat -Wf link -I ${epair0}a | head | awk '$1!~/^Name/{print$8}'`
633
pkt_1=`jexec ${jname}a netstat -Wf link -I ${epair1}a | head | awk '$1!~/^Name/{print$8}'`
634
635
jexec ${jname}a netstat -bWf link -I ${epair0}a
636
jexec ${jname}a netstat -bWf link -I ${epair1}a
637
if [ ${pkt_0} -le 10 ]; then
638
atf_fail "Balancing failure: 1: ${pkt_0} 2: ${pkt_1}"
639
fi
640
if [ ${pkt_1} -le 10 ]; then
641
atf_fail "Balancing failure: 1: ${pkt_0} 2: ${pkt_1}"
642
fi
643
echo "RAW BALANCING: 1: ${pkt_0} 2: ${pkt_1}"
644
}
645
646
output6_raw_flowid_mpath_success_cleanup()
647
{
648
vnet_cleanup
649
}
650
651
atf_init_test_cases()
652
{
653
atf_add_test_case "output6_tcp_setup_success"
654
atf_add_test_case "output6_udp_setup_success"
655
atf_add_test_case "output6_raw_success"
656
atf_add_test_case "output6_tcp_flowid_mpath_success"
657
atf_add_test_case "output6_udp_flowid_mpath_success"
658
atf_add_test_case "output6_raw_flowid_mpath_success"
659
}
660
661
# end
662
663
664
665