1#!/bin/sh 2 3SRC_TREE=../../../../ 4 5test_run() 6{ 7 sysctl -w net.core.bpf_jit_enable=$1 2>&1 > /dev/null 8 sysctl -w net.core.bpf_jit_harden=$2 2>&1 > /dev/null 9 10 echo "[ JIT enabled:$1 hardened:$2 ]" 11 dmesg -C 12 insmod $SRC_TREE/lib/test_bpf.ko 2> /dev/null 13 if [ $? -ne 0 ]; then 14 rc=1 15 fi 16 rmmod test_bpf 2> /dev/null 17 dmesg | grep FAIL 18} 19 20test_save() 21{ 22 JE=`sysctl -n net.core.bpf_jit_enable` 23 JH=`sysctl -n net.core.bpf_jit_harden` 24} 25 26test_restore() 27{ 28 sysctl -w net.core.bpf_jit_enable=$JE 2>&1 > /dev/null 29 sysctl -w net.core.bpf_jit_harden=$JH 2>&1 > /dev/null 30} 31 32rc=0 33test_save 34test_run 0 0 35test_run 1 0 36test_run 1 1 37test_run 1 2 38test_restore 39exit $rc 40