diff options
author | Jakub Kicinski <kuba@kernel.org> | 2021-11-01 20:05:14 -0700 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2021-11-01 20:05:14 -0700 |
commit | 8a33dcc2f6d5cf60cc77b72c277d1eba8e4ac8fb (patch) | |
tree | 83f899fd5d970d220e04da03b045fd46261437f1 /tools/testing/selftests/net/cmsg_so_mark.sh | |
parent | b7b98f868987cd3e86c9bd9a6db048614933d7a0 (diff) | |
parent | 6b278c0cb378079f3c0c61ae4a369c09ff1a4188 (diff) | |
download | linux-stable-8a33dcc2f6d5cf60cc77b72c277d1eba8e4ac8fb.tar.gz linux-stable-8a33dcc2f6d5cf60cc77b72c277d1eba8e4ac8fb.tar.bz2 linux-stable-8a33dcc2f6d5cf60cc77b72c277d1eba8e4ac8fb.zip |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Merge in the fixes we had queued in case there was another -rc.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools/testing/selftests/net/cmsg_so_mark.sh')
-rwxr-xr-x | tools/testing/selftests/net/cmsg_so_mark.sh | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/tools/testing/selftests/net/cmsg_so_mark.sh b/tools/testing/selftests/net/cmsg_so_mark.sh new file mode 100755 index 000000000000..19c6aab8d0e9 --- /dev/null +++ b/tools/testing/selftests/net/cmsg_so_mark.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +NS=ns +IP4=172.16.0.1/24 +TGT4=172.16.0.2 +IP6=2001:db8:1::1/64 +TGT6=2001:db8:1::2 +MARK=1000 + +cleanup() +{ + ip netns del $NS +} + +trap cleanup EXIT + +# Namespaces +ip netns add $NS + +# Connectivity +ip -netns $NS link add type dummy +ip -netns $NS link set dev dummy0 up +ip -netns $NS addr add $IP4 dev dummy0 +ip -netns $NS addr add $IP6 dev dummy0 + +ip -netns $NS rule add fwmark $MARK lookup 300 +ip -6 -netns $NS rule add fwmark $MARK lookup 300 +ip -netns $NS route add prohibit any table 300 +ip -6 -netns $NS route add prohibit any table 300 + +# Test +BAD=0 +TOTAL=0 + +check_result() { + ((TOTAL++)) + if [ $1 -ne $2 ]; then + echo " Case $3 returned $1, expected $2" + ((BAD++)) + fi +} + +ip netns exec $NS ./cmsg_so_mark $TGT4 1234 $((MARK + 1)) +check_result $? 0 "IPv4 pass" +ip netns exec $NS ./cmsg_so_mark $TGT6 1234 $((MARK + 1)) +check_result $? 0 "IPv6 pass" + +ip netns exec $NS ./cmsg_so_mark $TGT4 1234 $MARK +check_result $? 1 "IPv4 rejection" +ip netns exec $NS ./cmsg_so_mark $TGT6 1234 $MARK +check_result $? 1 "IPv6 rejection" + +# Summary +if [ $BAD -ne 0 ]; then + echo "FAIL - $BAD/$TOTAL cases failed" + exit 1 +else + echo "OK" + exit 0 +fi |