Subject: selftests: openvswitch: Questions about possible enhancements

From: Simon Horman <[email-masked]>
Date: Wed, 24 Apr 2024 17:44:05 +0100

Hi Aaron, Jakub, all,

I have recently been exercising the Open vSwitch kernel selftests,
using vng, something like this:

	TESTDIR="tools/testing/selftests/net/openvswitch"

        vng -v --run . --user root --cpus 2 \
                --overlay-rwdir "$PWD" -- \
                "modprobe openvswitch && \
		 echo \"timeout=90\" >> \"${TESTDIR}/settings\" && \
                 make -C \"$TESTDIR\" run_tests"

And I have some observations that I'd like to ask about.

1. Building the kernel using the following command does not
   build the openvswitch kernel module.

	vng -v --build \
		--config tools/testing/selftests/net/config

   All that seems to be missing is CONFIG_OPENVSWITCH=m
   and I am wondering what the best way of resolving this is.

   Perhaps I am doing something wrong.
   Or perhaps tools/testing/selftests/net/openvswitch/config
   should be created? If so, should it include (most of?) what is in
   tools/testing/selftests/net/config, or just CONFIG_OPENVSWITCH=m?

2. As per my example above, it seems that a modprobe openvswitch is
   required (if openvswitch is a module).

   Again, perhaps I am doing something wrong. But if not, should this be
   incorporated into tools/testing/selftests/net/openvswitch/openvswitch.sh
   or otherwise automated?

3. I have observed that the last test fails (yesterday, but not today!),
   because the namespace it tries to create already exists. I believe this
   is because it is pending deletion.

   My work-around is as follows:

 ovs_add_netns_and_veths () {
 	info "Adding netns attached: sbx:$1 dp:$2 {$3, $4, $5}"
+	for i in $(seq 10); do
+		ovs_sbx "$1" test -e "/var/run/netns/$3" || break
+		info "Namespace $3 still exists (attempt $i)"
+		ovs_sbx "$1" ip netns del "$3"
+		sleep "$i"
+	done
 	ovs_sbx "$1" ip netns add "$3" || return 1
 	on_exit "ovs_sbx $1 ip netns del $3"
 	ovs_sbx "$1" ip link add "$4" type veth peer name "$5" || return 1

   N.B.: the "netns del" part is probably not needed,
   but I'm not able to exercise it effectively right now.

   I am wondering if a loop like this is appropriate to add, perhaps also
   to namespace deletion. Or if it would be appropriate to port
   openvswitch.sh to use ./tools/testing/selftests/net/lib.sh, which I
   believe handles this.

4. I am observing timeouts whith the default value of 45s.
   Bumping this to 90s seems to help.
   Are there any objections to a patch to bump the timeout?