diff --git a/test/others/ns_ext/run.sh b/test/others/ns_ext/run.sh index 4ebe3e280..5d1e139d7 100755 --- a/test/others/ns_ext/run.sh +++ b/test/others/ns_ext/run.sh @@ -2,6 +2,11 @@ set -x +if ! ../../zdtm/static/macvlan.checkskip; then + echo "No macvlan support. Skipping" + exit 0 +fi + if [[ "$1" == "pid" ]]; then NS=pid else diff --git a/test/zdtm/static/macvlan.checkskip b/test/zdtm/static/macvlan.checkskip new file mode 100755 index 000000000..f4e060953 --- /dev/null +++ b/test/zdtm/static/macvlan.checkskip @@ -0,0 +1,38 @@ +#!/bin/bash + +FAIL=0 + +create_macvlan_device() { + if ! ip link add test_mvlan1 type veth >/dev/null 2>&1; then + FAIL=1 + fi + if ! ip link add mymacvlan1 link test_mvlan1 type macvlan >/dev/null 2>&1; then + FAIL=1 + fi + + return "${FAIL}" +} + +cleanup() { + ip link del test_mvlan1 >/dev/null 2>&1 + ip link del mymacvlan1 >/dev/null 2>&1 +} + +trap "cleanup" QUIT TERM INT HUP EXIT + +# Test once without loading the module +if create_macvlan_device; then + exit 0 +fi + +# Test once more with explicitly loading the module +if ! modprobe macvlan >/dev/null 2>&1; then + exit 1 +fi +create_macvlan_device + +if [ "${FAIL}" == "1" ]; then + exit 1 +fi + +exit 0