2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright(c) 2020 Intel Corporation.
23 if [ $UID != 0 ]; then
24 echo $msg must be run as root >&2
25 test_exit $ksft_fail 2
31 validate_veth_support()
34 if [ $(ip link add $1 type veth 2>/dev/null; echo $?;) != 0 ]; then
35 echo $msg veth kernel support not available >&2
36 test_exit $ksft_skip 1
43 validate_veth_spec_file()
45 if [ ! -f ${SPECFILE} ]; then
46 test_exit $ksft_skip 1
53 if [ -n "${colorconsole+set}" ]; then
54 if [ $statusval -eq 2 ]; then
55 echo -e "${YELLOW}$2${NC}: [ ${RED}FAIL${NC} ]"
56 elif [ $statusval -eq 1 ]; then
57 echo -e "${YELLOW}$2${NC}: [ ${RED}SKIPPED${NC} ]"
58 elif [ $statusval -eq 0 ]; then
59 echo -e "${YELLOW}$2${NC}: [ ${GREEN}PASS${NC} ]"
62 if [ $statusval -eq 2 ]; then
63 echo -e "$2: [ FAIL ]"
64 elif [ $statusval -eq 1 ]; then
65 echo -e "$2: [ SKIPPED ]"
66 elif [ $statusval -eq 0 ]; then
67 echo -e "$2: [ PASS ]"
76 test_status $2 $(basename $0)
83 if [ $(ip netns show | grep $3 &>/dev/null; echo $?;) == 0 ]; then
84 [ $(ip netns exec $3 ip link show $2 &>/dev/null; echo $?;) == 0 ] &&
85 { ip netns exec $3 ip link del $2; }
88 #Once we delete a veth pair node, the entire veth pair is removed,
89 #this is just to be cautious just incase the NS does not exist then
90 #veth node inside NS won't get removed so we explicitly remove it
91 [ $(ip link show $1 &>/dev/null; echo $?;) == 0 ] &&
93 if [ -f ${SPECFILE} ]; then
100 clear_configs $1 $2 $3
103 validate_ip_utility()
105 [ ! $(type -P ip) ] && { echo "'ip' not found. Skipping tests."; test_exit $ksft_skip 1; }
110 ./${XSKOBJ} -i ${VETH0} -i ${VETH1},${NS1} -C ${NUMPKTS} ${VERBOSE_ARG} ${DUMP_PKTS_ARG}