]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - tools/testing/selftests/bpf/test_kmod.sh
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[mirror_ubuntu-bionic-kernel.git] / tools / testing / selftests / bpf / test_kmod.sh
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0
3
4 SRC_TREE=../../../../
5
6 test_run()
7 {
8 sysctl -w net.core.bpf_jit_enable=$1 2>&1 > /dev/null
9 sysctl -w net.core.bpf_jit_harden=$2 2>&1 > /dev/null
10
11 echo "[ JIT enabled:$1 hardened:$2 ]"
12 dmesg -C
13 insmod $SRC_TREE/lib/test_bpf.ko 2> /dev/null
14 if [ $? -ne 0 ]; then
15 rc=1
16 fi
17 rmmod test_bpf 2> /dev/null
18 dmesg | grep FAIL
19 }
20
21 test_save()
22 {
23 JE=`sysctl -n net.core.bpf_jit_enable`
24 JH=`sysctl -n net.core.bpf_jit_harden`
25 }
26
27 test_restore()
28 {
29 sysctl -w net.core.bpf_jit_enable=$JE 2>&1 > /dev/null
30 sysctl -w net.core.bpf_jit_harden=$JH 2>&1 > /dev/null
31 }
32
33 rc=0
34 test_save
35 test_run 0 0
36 test_run 1 0
37 test_run 1 1
38 test_run 1 2
39 test_restore
40 exit $rc