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 { echo "removing link $1:$2"; ip netns
exec $3 ip link del
$2; }
89 #Once we delete a veth pair node, the entire veth pair is removed,
90 #this is just to be cautious just incase the NS does not exist then
91 #veth node inside NS won't get removed so we explicitly remove it
92 [ $
(ip link show
$1 &>/dev
/null
; echo $?
;) == 0 ] &&
93 { echo "removing link $1"; ip link del
$1; }
94 if [ -f ${SPECFILE} ]; then
95 echo "removing spec file:" ${SPECFILE}
102 echo "cleaning up..."
103 clear_configs
$1 $2 $3
106 validate_ip_utility
()
108 [ ! $
(type -P ip
) ] && { echo "'ip' not found. Skipping tests."; test_exit
$ksft_skip 1; }
113 ip link
set dev
$1 xdpdrv off
114 ip netns
exec $3 ip link
set dev
$2 xdpdrv off
119 ip link
set dev
$1 xdpgeneric off
120 ip netns
exec $3 ip link
set dev
$2 xdpgeneric off
125 local -a 'paramkeys=("${!'"$1"'[@]}")' copy
126 paramkeysstr
=${paramkeys[*]}
128 for index
in $paramkeysstr;
131 copy
[$index]=${!current}
134 .
/${XSKOBJ} -i ${VETH0} -i ${VETH1},${NS1} ${copy[*]} -C ${NUMPKTS}