aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/net/cmsg_so_mark.sh
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2022-02-09 16:36:46 -0800
committerDavid S. Miller <davem@davemloft.net>2022-02-10 15:04:51 +0000
commit9bbfbc92c64a9f4d5ac4205071c5fc02a8201039 (patch)
tree6be406651132f42ebd4e5599d1a8c0ec5aac031d /tools/testing/selftests/net/cmsg_so_mark.sh
parentselftests: net: cmsg_so_mark: test ICMP and RAW sockets (diff)
downloadlinux-dev-9bbfbc92c64a9f4d5ac4205071c5fc02a8201039.tar.xz
linux-dev-9bbfbc92c64a9f4d5ac4205071c5fc02a8201039.zip
selftests: net: cmsg_so_mark: test with SO_MARK set by setsockopt
Test if setting SO_MARK with setsockopt works and if cmsg takes precedence over it. Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/testing/selftests/net/cmsg_so_mark.sh')
-rwxr-xr-xtools/testing/selftests/net/cmsg_so_mark.sh28
1 files changed, 18 insertions, 10 deletions
diff --git a/tools/testing/selftests/net/cmsg_so_mark.sh b/tools/testing/selftests/net/cmsg_so_mark.sh
index 925f6b9deee2..1650b8622f2f 100755
--- a/tools/testing/selftests/net/cmsg_so_mark.sh
+++ b/tools/testing/selftests/net/cmsg_so_mark.sh
@@ -43,19 +43,27 @@ check_result() {
fi
}
-for i in 4 6; do
- [ $i == 4 ] && TGT=$TGT4 || TGT=$TGT6
+for ovr in setsock cmsg both; do
+ for i in 4 6; do
+ [ $i == 4 ] && TGT=$TGT4 || TGT=$TGT6
- for p in u i r; do
- [ $p == "u" ] && prot=UDP
- [ $p == "i" ] && prot=ICMP
- [ $p == "r" ] && prot=RAW
+ for p in u i r; do
+ [ $p == "u" ] && prot=UDP
+ [ $p == "i" ] && prot=ICMP
+ [ $p == "r" ] && prot=RAW
- ip netns exec $NS ./cmsg_sender -$i -p $p -m $((MARK + 1)) $TGT 1234
- check_result $? 0 "$prot pass"
+ [ $ovr == "setsock" ] && m="-M"
+ [ $ovr == "cmsg" ] && m="-m"
+ [ $ovr == "both" ] && m="-M $MARK -m"
- ip netns exec $NS ./cmsg_sender -$i -p $p -m $MARK -s $TGT 1234
- check_result $? 1 "$prot rejection"
+ ip netns exec $NS ./cmsg_sender -$i -p $p $m $((MARK + 1)) $TGT 1234
+ check_result $? 0 "$prot $ovr - pass"
+
+ [ $ovr == "diff" ] && m="-M $((MARK + 1)) -m"
+
+ ip netns exec $NS ./cmsg_sender -$i -p $p $m $MARK -s $TGT 1234
+ check_result $? 1 "$prot $ovr - rejection"
+ done
done
done