On 12/25/25 7:55 PM, Dmitry Skorodumov wrote:
> diff --git a/tools/testing/selftests/net/ipvtap_test.sh 
> b/tools/testing/selftests/net/ipvtap_test.sh
> new file mode 100755
> index 000000000000..751793f26fed
> --- /dev/null
> +++ b/tools/testing/selftests/net/ipvtap_test.sh
> @@ -0,0 +1,168 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# Simple tests for ipvtap
> +
> +
> +#
> +# The testing environment looks this way:
> +#
> +# |------HOST------|     |------PHY-------|
> +# |      veth<----------------->veth      |
> +# |------|--|------|     |----------------|
> +#        |  |
> +#        |  |            |-----TST0-------|
> +#        |  |------------|----ipvlan      |
> +#        |               |----------------|
> +#        |
> +#        |               |-----TST1-------|
> +#        |---------------|----ipvlan      |
> +#                        |----------------|
> +#
> +
> +ALL_TESTS="
> +     test_ip_set
> +"
> +
> +source lib.sh
> +
> +DEBUG=0
> +
> +VETH_HOST=vethtst.h
> +VETH_PHY=vethtst.p
> +
> +NS_COUNT=32
> +IP_ITERATIONS=1024
> +
> +ns_run() {
> +     ns=$1
> +     shift
> +     if [[ "$ns" == "global" ]]; then
> +             "$@" >/dev/null
> +     else
> +             ip netns exec "$ns" "$@" >/dev/null
> +     fi
> +}
> +
> +test_ip_setup_env() {
> +     modprobe -q tap
> +     modprobe -q ipvlan
> +     modprobe -q ipvtap
> +
> +     setup_ns NS_PHY
> +
> +     # setup simulated other-host (phy) and host itself
> +     ip link add $VETH_HOST type veth peer name $VETH_PHY \
> +             netns "$NS_PHY" >/dev/null

It would be better to avoid creating devices in the main netns.

> +     ip link set $VETH_HOST up
> +     ns_run "$NS_PHY" ip link set $VETH_PHY up
> +
> +     for ((i=0; i<NS_COUNT; i++)); do
> +             setup_ns ipvlan_ns_$i
> +             ns="ipvlan_ns_$i"
> +             if [ "$DEBUG" = "1" ]; then
> +                     echo "created NS ${!ns}"
> +             fi
> +             if ! ip link add netns ${!ns} ipvlan0 link $VETH_HOST \
> +                 type ipvtap mode l2 bridge; then
> +                     exit_error "FAIL: Failed to configure ipvlan link."
> +             fi
> +     done
> +}
> +
> +test_ip_cleanup_env() {
> +     ip link del $VETH_HOST
> +     cleanup_all_ns
> +}
> +
> +exit_error() {
> +     echo "$1"
> +     exit $ksft_fail
> +}
> +
> +rnd() {
> +     echo $(( RANDOM % 32 + 16 ))
> +}
> +
> +test_ip_set_thread() {
> +     ip link set ipvlan0 up
> +     for ((i=0; i<IP_ITERATIONS; i++)); do
> +             v=$(rnd)
> +             ip a a "172.25.0.$v/24" dev ipvlan0 2>/dev/null
> +             ip a a "fc00::$v/64" dev ipvlan0 2>/dev/null
> +             v=$(rnd)
> +             ip a d "172.25.0.$v/24" dev ipvlan0 2>/dev/null
> +             ip a d "fc00::$v/64" dev ipvlan0 2>/dev/null

It's unclear to me why the above tries to remove random addresses
different from the ones just added (possibly not existing)

> +     done
> +}
> +
> +test_ip_set() {
> +     RET=0
> +
> +     modprobe -q tap
> +     modprobe -q ipvlan
> +     modprobe -q ipvtap
> +
> +     trap test_ip_cleanup_env EXIT
> +
> +     test_ip_setup_env
> +
> +     declare -A ns_pids
> +     for ((i=0; i<NS_COUNT; i++)); do
> +             ns="ipvlan_ns_$i"
> +             ns_run ${!ns} bash -c "$0 test_ip_set_thread"&
> +             ns_pids[$i]=$!
> +     done
> +
> +     for ((i=0; i<NS_COUNT; i++)); do
> +             wait "${ns_pids[$i]}"
> +     done

This tests fails quite often in debug build due to timeout, see:

https://netdev.bots.linux.dev/flakes.html?tn-needle=ipvtap

and i.e.

https://netdev-ctrl.bots.linux.dev/logs/vmksft/net-dbg/results/447821/5-ipvtap-test-sh/

You should likely decrease the thread and/or iterations count, at least
for debug builds

/P


Reply via email to