blob: 96f6d5a9fed693cfe45228fe58de4788163bbf3b (
plain)
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
|
#!/bin/sh
#
# Copyright (c) 2015, Ilya Maximets <i.maximets@samsung.com>
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
# any parameter passed as arguments to this script is passed unchanged to
# the test itself (pktio_main)
# directories where pktio_main binary can be found:
# -in the validation dir when running make check (intree or out of tree)
# -in the script directory, when running after 'make install', or
# -in the validation when running standalone intree.
# -in the current directory.
# running stand alone out of tree requires setting PATH
PATH=${TEST_DIR}/api/pktio:$PATH
PATH=$(dirname $0):$PATH
PATH=$(dirname $0)/../../../../test/validation/api/pktio:$PATH
PATH=.:$PATH
pktio_main_path=$(which pktio_main${EXEEXT})
if [ -x "$pktio_main_path" ] ; then
echo "running with $pktio_main_path"
else
echo "cannot find pktio_main${EXEEXT}: please set you PATH for it."
fi
# exit code expected by automake for skipped tests
TEST_SKIPPED=77
TAP_BASE_NAME=iotap_vald
IF0=${TAP_BASE_NAME}0
IF1=${TAP_BASE_NAME}1
BR=${TAP_BASE_NAME}_br
export ODP_PKTIO_IF0="tap:$IF0"
export ODP_PKTIO_IF1="tap:$IF1"
tap_cleanup()
{
ret=$?
for iface in $IF0 $IF1; do
ip link set dev $iface nomaster
done
ip link delete $BR type bridge
for iface in $IF0 $IF1; do
ip tuntap del mode tap $iface
done
trap - EXIT
exit $ret
}
tap_setup()
{
if [ "$(id -u)" != "0" ]; then
echo "pktio: need to be root to setup TAP interfaces."
return $TEST_SKIPPED
fi
for iface in $IF0 $IF1 $BR; do
ip link show $iface 2> /dev/null
if [ $? -eq 0 ]; then
echo "pktio: interface $iface already exist $?"
return 2
fi
done
trap tap_cleanup EXIT
for iface in $IF0 $IF1; do
ip tuntap add mode tap $iface
if [ $? -ne 0 ]; then
echo "pktio: error: unable to create TAP device $iface"
return 3
fi
done
ip link add name $BR type bridge
if [ $? -ne 0 ]; then
echo "pktio: error: unable to create bridge $BR"
return 3
fi
for iface in $IF0 $IF1; do
ip link set dev $iface master $BR
if [ $? -ne 0 ]; then
echo "pktio: error: unable to add $iface to bridge $BR"
return 4
fi
done
for iface in $IF0 $IF1 $BR; do
ifconfig $iface -arp
sysctl -w net.ipv6.conf.${iface}.disable_ipv6=1
ip link set dev $iface mtu 9216 up
done
return 0
}
tap_setup
ret=$?
if [ $ret -ne 0 ]; then
echo "pktio: tap_setup() FAILED!"
exit $TEST_SKIPPED
fi
# Using ODP_WAIT_FOR_NETWORK to prevent fail if tap still not enabled in bridge
ODP_WAIT_FOR_NETWORK=yes pktio_main${EXEEXT} $*
ret=$?
exit $ret
|