2 # SPDX-License-Identifier: GPL-2.0
4 # Regression tests for the SO_TXTIME interface
10 readonly BIN
="./so_txtime"
12 readonly RAND
="$(mktemp -u XXXXXX)"
13 readonly NSPREFIX
="ns-${RAND}"
14 readonly NS1
="${NSPREFIX}1"
15 readonly NS2
="${NSPREFIX}2"
17 readonly SADDR4
='192.168.1.1'
18 readonly DADDR4
='192.168.1.2'
19 readonly SADDR6
='fd::1'
20 readonly DADDR6
='fd::2'
29 # Create virtual ethernet pair between network namespaces
33 ip link add
"${DEV}" netns
"${NS1}" type veth \
34 peer name
"${DEV}" netns
"${NS2}"
36 # Bring the devices up
37 ip
-netns "${NS1}" link
set "${DEV}" up
38 ip
-netns "${NS2}" link
set "${DEV}" up
40 # Set fixed MAC addresses on the devices
41 ip
-netns "${NS1}" link
set dev
"${DEV}" address
02:02:02:02:02:02
42 ip
-netns "${NS2}" link
set dev
"${DEV}" address
06:06:06:06:06:06
44 # Add fixed IP addresses to the devices
45 ip
-netns "${NS1}" addr add
192.168.1.1/24 dev
"${DEV}"
46 ip
-netns "${NS2}" addr add
192.168.1.2/24 dev
"${DEV}"
47 ip
-netns "${NS1}" addr add fd
::1/64 dev
"${DEV}" nodad
48 ip
-netns "${NS2}" addr add fd
::2/64 dev
"${DEV}" nodad
51 local readonly IP
="$1"
52 local readonly CLOCK
="$2"
53 local readonly TXARGS
="$3"
54 local readonly RXARGS
="$4"
56 if [[ "${IP}" == "4" ]]; then
57 local readonly SADDR
="${SADDR4}"
58 local readonly DADDR
="${DADDR4}"
59 elif [[ "${IP}" == "6" ]]; then
60 local readonly SADDR
="${SADDR6}"
61 local readonly DADDR
="${DADDR6}"
63 echo "Invalid IP version ${IP}"
67 local readonly START
="$(date +%s%N --date="+ 0.1 seconds
")"
69 ip netns
exec "${NS2}" "${BIN}" -"${IP}" -c "${CLOCK}" -t "${START}" -S "${SADDR}" -D "${DADDR}" "${RXARGS}" -r &
70 ip netns
exec "${NS1}" "${BIN}" -"${IP}" -c "${CLOCK}" -t "${START}" -S "${SADDR}" -D "${DADDR}" "${TXARGS}"
84 ip netns
exec "${NS1}" tc qdisc add dev
"${DEV}" root fq
87 do_test
4 mono a
,-1 a
,-1
88 do_test
6 mono a
,0 a
,0
89 do_test
6 mono a
,10 a
,10
90 do_test
4 mono a
,10,b
,20 a
,10,b
,20
91 do_test
6 mono a
,20,b
,10 b
,20,a
,20
93 if ip netns
exec "${NS1}" tc qdisc replace dev
"${DEV}" root etf clockid CLOCK_TAI delta
400000; then
94 do_fail_test
4 tai a
,-1 a
,-1
95 do_fail_test
6 tai a
,0 a
,0
96 do_test
6 tai a
,10 a
,10
97 do_test
4 tai a
,10,b
,20 a
,10,b
,20
98 do_test
6 tai a
,20,b
,10 b
,10,a
,20
100 echo "tc ($(tc -V)) does not support qdisc etf. skipping"
101 [ $ret -eq 0 ] && ret
=$ksft_skip
104 if [ $ret -eq 0 ]; then
105 echo OK. All tests passed
106 elif [[ $ret -ne $ksft_skip && -n "$KSFT_MACHINE_SLOW" ]]; then
107 echo "Ignoring errors due to slow environment" 1>&2