# This test is designed for testing the new VRF strict_mode functionality.
source lib.sh
ret=0
# identifies the "init" network namespace which is often called root network # namespace.
INIT_NETNS_NAME="init"
PAUSE_ON_FAIL=${PAUSE_ON_FAIL:=no}
TESTS="init testns mix"
log_test()
{
local rc=$1
local expected=$2
local msg="$3"
if [ ${rc} -eq ${expected} ]; then
nsuccess=$((nsuccess+1))
printf "\n TEST: %-60s [ OK ]\n""${msg}" else
ret=1
nfail=$((nfail+1))
printf "\n TEST: %-60s [FAIL]\n""${msg}" if [ "${PAUSE_ON_FAIL}" = "yes" ]; then echo echo"hit enter to continue, 'q' to quit"
read a
[ "$a" = "q" ] && exit 1 fi fi
}
print_log_test_results()
{ if [ "$TESTS" != "none" ]; then
printf "\nTests passed: %3d\n" ${nsuccess}
printf "Tests failed: %3d\n" ${nfail} fi
}
-t <test> Test(s) to run (default: all)
(options: $TESTS)
EOF
}
################################################################################ # main
while getopts ":t:h" opt; do
case $opt in
t) TESTS=$OPTARG;;
h) usage; exit 0;;
*) usage; exit 1;;
esac done
vrf_strict_mode_check_support()
{
local nsname=$1
local output
local rc
output="$(lsmod | grep '^vrf' | awk '{print $1}')" if [ -z "${output}" ]; then
modinfo vrf || return $? fi
# we do not care about the value of the strict_mode; we only check if # the strict_mode parameter is available or not.
read_strict_mode ${nsname} &>/dev/null; rc=$?
log_test ${rc} 0 "${nsname}: net.vrf.strict_mode is available"
return ${rc}
}
if [ "$(id -u)" -ne 0 ];then echo"SKIP: Need root privileges"
exit $ksft_skip fi
if [ ! -x "$(command -v ip)" ]; then echo"SKIP: Could not run test without ip tool"
exit $ksft_skip fi
modprobe vrf &>/dev/null if [ ! -e /proc/sys/net/vrf/strict_mode ]; then echo"SKIP: vrf sysctl does not exist"
exit $ksft_skip fi
cleanup &> /dev/null
setup for t in $TESTS do
case $t in
vrf_strict_mode_tests_init|init) vrf_strict_mode_tests_init;;
vrf_strict_mode_tests_testns|testns) vrf_strict_mode_tests_testns;;
vrf_strict_mode_tests_mix|mix) vrf_strict_mode_tests_mix;;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.