Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) #!/bin/bash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) function config_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) 	ip netns add at_ns0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) 	ip link add veth0 type veth peer name veth0b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) 	ip link set veth0b up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 	ip link set veth0 netns at_ns0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 	ip netns exec at_ns0 ip addr add 172.16.1.100/24 dev veth0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 	ip netns exec at_ns0 ip addr add 2401:db00::1/64 dev veth0 nodad
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 	ip netns exec at_ns0 ip link set dev veth0 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 	ip addr add 172.16.1.101/24 dev veth0b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 	ip addr add 2401:db00::2/64 dev veth0b nodad
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) function config_cgroup {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 	rm -rf /tmp/cgroupv2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 	mkdir -p /tmp/cgroupv2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	mount -t cgroup2 none /tmp/cgroupv2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	mkdir -p /tmp/cgroupv2/foo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	echo $$ >> /tmp/cgroupv2/foo/cgroup.procs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) function attach_bpf {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	test_cgrp2_sock2 /tmp/cgroupv2/foo sock_flags_kern.o $1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	[ $? -ne 0 ] && exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) function cleanup {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	if [ -d /tmp/cgroupv2/foo ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 		test_cgrp2_sock -d /tmp/cgroupv2/foo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	ip link del veth0b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	ip netns delete at_ns0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	umount /tmp/cgroupv2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	rm -rf /tmp/cgroupv2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) cleanup 2>/dev/null
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) set -e
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) config_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) config_cgroup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) set +e
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) # Test 1 - fail ping6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) attach_bpf 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) ping -c1 -w1 172.16.1.100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) if [ $? -ne 0 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	echo "ping failed when it should succeed"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	cleanup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) ping6 -c1 -w1 2401:db00::1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) if [ $? -eq 0 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	echo "ping6 succeeded when it should not"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 	cleanup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) # Test 2 - fail ping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) attach_bpf 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) ping6 -c1 -w1 2401:db00::1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) if [ $? -ne 0 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	echo "ping6 failed when it should succeed"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 	cleanup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) ping -c1 -w1 172.16.1.100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) if [ $? -eq 0 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 	echo "ping succeeded when it should not"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) 	cleanup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 	exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) cleanup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) echo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) echo "*** PASS ***"