~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/net/cmsg_so_mark.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0
  3 
  4 source lib.sh
  5 
  6 IP4=172.16.0.1/24
  7 TGT4=172.16.0.2
  8 IP6=2001:db8:1::1/64
  9 TGT6=2001:db8:1::2
 10 MARK=1000
 11 
 12 cleanup()
 13 {
 14     cleanup_ns $NS
 15 }
 16 
 17 trap cleanup EXIT
 18 
 19 # Namespaces
 20 setup_ns NS
 21 
 22 ip netns exec $NS sysctl -w net.ipv4.ping_group_range='0 2147483647' > /dev/null
 23 
 24 # Connectivity
 25 ip -netns $NS link add type dummy
 26 ip -netns $NS link set dev dummy0 up
 27 ip -netns $NS addr add $IP4 dev dummy0
 28 ip -netns $NS addr add $IP6 dev dummy0
 29 
 30 ip -netns $NS rule add fwmark $MARK lookup 300
 31 ip -6 -netns $NS rule add fwmark $MARK lookup 300
 32 ip -netns $NS route add prohibit any table 300
 33 ip -6 -netns $NS route add prohibit any table 300
 34 
 35 # Test
 36 BAD=0
 37 TOTAL=0
 38 
 39 check_result() {
 40     ((TOTAL++))
 41     if [ $1 -ne $2 ]; then
 42         echo "  Case $3 returned $1, expected $2"
 43         ((BAD++))
 44     fi
 45 }
 46 
 47 for ovr in setsock cmsg both; do
 48     for i in 4 6; do
 49         [ $i == 4 ] && TGT=$TGT4 || TGT=$TGT6
 50 
 51         for p in u i r; do
 52             [ $p == "u" ] && prot=UDP
 53             [ $p == "i" ] && prot=ICMP
 54             [ $p == "r" ] && prot=RAW
 55 
 56             [ $ovr == "setsock" ] && m="-M"
 57             [ $ovr == "cmsg" ]    && m="-m"
 58             [ $ovr == "both" ]    && m="-M $MARK -m"
 59 
 60             ip netns exec $NS ./cmsg_sender -$i -p $p $m $((MARK + 1)) $TGT 1234
 61             check_result $? 0 "$prot $ovr - pass"
 62 
 63             [ $ovr == "diff" ] && m="-M $((MARK + 1)) -m"
 64 
 65             ip netns exec $NS ./cmsg_sender -$i -p $p $m $MARK -s $TGT 1234
 66             check_result $? 1 "$prot $ovr - rejection"
 67         done
 68     done
 69 done
 70 
 71 # Summary
 72 if [ $BAD -ne 0 ]; then
 73     echo "FAIL - $BAD/$TOTAL cases failed"
 74     exit 1
 75 else
 76     echo "OK"
 77     exit 0
 78 fi

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php