1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0 3 4SRC_TREE=../../../../ 5 6test_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 21test_save() 22{ 23 JE=`sysctl -n net.core.bpf_jit_enable` 24 JH=`sysctl -n net.core.bpf_jit_harden` 25} 26 27test_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 33rc=0 34test_save 35test_run 0 0 36test_run 1 0 37test_run 1 1 38test_run 1 2 39test_restore 40exit $rc 41