3
0
mirror of https://github.com/Qortal/Brooklyn.git synced 2025-02-07 06:44:18 +00:00
Brooklyn/tools/testing/selftests/net/cmsg_so_mark.sh
crowetic a94b3d14aa Brooklyn+ (PLUS) changes
Changes included (and more):

1. Dynamic RAM merge

2. Real-time page scan and allocation

3. Cache compression

4. Real-time IRQ checks

5. Dynamic I/O allocation for Java heap

6. Java page migration

7. Contiguous memory allocation

8. Idle pages tracking

9. Per CPU RAM usage tracking

10. ARM NEON scalar multiplication library

11. NEON/ARMv8 crypto extensions

12. NEON SHA, Blake, RIPEMD crypto extensions

13. Parallel NEON crypto engine for multi-algo based CPU stress reduction
2022-05-12 10:47:00 -07:00

78 lines
1.5 KiB
Bash

#!/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
ip netns exec $NS sysctl -w net.ipv4.ping_group_range='0 2147483647' > /dev/null
# 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
}
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
[ $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 + 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
# Summary
if [ $BAD -ne 0 ]; then
echo "FAIL - $BAD/$TOTAL cases failed"
exit 1
else
echo "OK"
exit 0
fi