Файловый менеджер - Редактировать - /var/www/xthruster/html/wp-content/uploads/flags/samples.tar
Назад
bpf/test_cgrp2_sock.sh 0000755 00000005621 14722051373 0010755 0 ustar 00 #!/bin/sh # SPDX-License-Identifier: GPL-2.0 # Test various socket options that can be set by attaching programs to cgroups. CGRP_MNT="/tmp/cgroupv2-test_cgrp2_sock" ################################################################################ # print_result() { local rc=$1 local status=" OK " [ $rc -ne 0 ] && status="FAIL" printf "%-50s [%4s]\n" "$2" "$status" } check_sock() { out=$(test_cgrp2_sock) echo $out | grep -q "$1" if [ $? -ne 0 ]; then print_result 1 "IPv4: $2" echo " expected: $1" echo " have: $out" rc=1 else print_result 0 "IPv4: $2" fi } check_sock6() { out=$(test_cgrp2_sock -6) echo $out | grep -q "$1" if [ $? -ne 0 ]; then print_result 1 "IPv6: $2" echo " expected: $1" echo " have: $out" rc=1 else print_result 0 "IPv6: $2" fi } ################################################################################ # cleanup() { echo $$ >> ${CGRP_MNT}/cgroup.procs rmdir ${CGRP_MNT}/sockopts } cleanup_and_exit() { local rc=$1 local msg="$2" [ -n "$msg" ] && echo "ERROR: $msg" test_cgrp2_sock -d ${CGRP_MNT}/sockopts ip li del cgrp2_sock umount ${CGRP_MNT} exit $rc } ################################################################################ # main rc=0 ip li add cgrp2_sock type dummy 2>/dev/null set -e mkdir -p ${CGRP_MNT} mount -t cgroup2 none ${CGRP_MNT} set +e # make sure we have a known start point cleanup 2>/dev/null mkdir -p ${CGRP_MNT}/sockopts [ $? -ne 0 ] && cleanup_and_exit 1 "Failed to create cgroup hierarchy" # set pid into cgroup echo $$ > ${CGRP_MNT}/sockopts/cgroup.procs # no bpf program attached, so socket should show no settings check_sock "dev , mark 0, priority 0" "No programs attached" check_sock6 "dev , mark 0, priority 0" "No programs attached" # verify device is set # test_cgrp2_sock -b cgrp2_sock ${CGRP_MNT}/sockopts if [ $? -ne 0 ]; then cleanup_and_exit 1 "Failed to install program to set device" fi check_sock "dev cgrp2_sock, mark 0, priority 0" "Device set" check_sock6 "dev cgrp2_sock, mark 0, priority 0" "Device set" # verify mark is set # test_cgrp2_sock -m 666 ${CGRP_MNT}/sockopts if [ $? -ne 0 ]; then cleanup_and_exit 1 "Failed to install program to set mark" fi check_sock "dev , mark 666, priority 0" "Mark set" check_sock6 "dev , mark 666, priority 0" "Mark set" # verify priority is set # test_cgrp2_sock -p 123 ${CGRP_MNT}/sockopts if [ $? -ne 0 ]; then cleanup_and_exit 1 "Failed to install program to set priority" fi check_sock "dev , mark 0, priority 123" "Priority set" check_sock6 "dev , mark 0, priority 123" "Priority set" # all 3 at once # test_cgrp2_sock -b cgrp2_sock -m 666 -p 123 ${CGRP_MNT}/sockopts if [ $? -ne 0 ]; then cleanup_and_exit 1 "Failed to install program to set device, mark and priority" fi check_sock "dev cgrp2_sock, mark 666, priority 123" "Priority set" check_sock6 "dev cgrp2_sock, mark 666, priority 123" "Priority set" cleanup_and_exit $rc bpf/run_cookie_uid_helper_example.sh 0000755 00000000525 14722051373 0013730 0 ustar 00 #!/bin/bash # SPDX-License-Identifier: GPL-2.0 local_dir="$(pwd)" root_dir=$local_dir/../.. mnt_dir=$(mktemp -d --tmp) on_exit() { iptables -D OUTPUT -m bpf --object-pinned ${mnt_dir}/bpf_prog -j ACCEPT umount ${mnt_dir} rm -r ${mnt_dir} } trap on_exit EXIT mount -t bpf bpf ${mnt_dir} ./per_socket_stats_example ${mnt_dir}/bpf_prog $1 bpf/tc_l2_redirect.sh 0000755 00000011640 14722051373 0010544 0 ustar 00 #!/bin/bash # SPDX-License-Identifier: GPL-2.0 [[ -z $TC ]] && TC='tc' [[ -z $IP ]] && IP='ip' REDIRECT_USER='./tc_l2_redirect' REDIRECT_BPF='./tc_l2_redirect_kern.o' RP_FILTER=$(< /proc/sys/net/ipv4/conf/all/rp_filter) IPV6_FORWARDING=$(< /proc/sys/net/ipv6/conf/all/forwarding) function config_common { local tun_type=$1 $IP netns add ns1 $IP netns add ns2 $IP link add ve1 type veth peer name vens1 $IP link add ve2 type veth peer name vens2 $IP link set dev ve1 up $IP link set dev ve2 up $IP link set dev ve1 mtu 1500 $IP link set dev ve2 mtu 1500 $IP link set dev vens1 netns ns1 $IP link set dev vens2 netns ns2 $IP -n ns1 link set dev lo up $IP -n ns1 link set dev vens1 up $IP -n ns1 addr add 10.1.1.101/24 dev vens1 $IP -n ns1 addr add 2401:db01::65/64 dev vens1 nodad $IP -n ns1 route add default via 10.1.1.1 dev vens1 $IP -n ns1 route add default via 2401:db01::1 dev vens1 $IP -n ns2 link set dev lo up $IP -n ns2 link set dev vens2 up $IP -n ns2 addr add 10.2.1.102/24 dev vens2 $IP -n ns2 addr add 2401:db02::66/64 dev vens2 nodad $IP -n ns2 addr add 10.10.1.102 dev lo $IP -n ns2 addr add 2401:face::66/64 dev lo nodad $IP -n ns2 link add ipt2 type ipip local 10.2.1.102 remote 10.2.1.1 $IP -n ns2 link add ip6t2 type ip6tnl mode any local 2401:db02::66 remote 2401:db02::1 $IP -n ns2 link set dev ipt2 up $IP -n ns2 link set dev ip6t2 up $IP netns exec ns2 $TC qdisc add dev vens2 clsact $IP netns exec ns2 $TC filter add dev vens2 ingress bpf da obj $REDIRECT_BPF sec drop_non_tun_vip if [[ $tun_type == "ipip" ]]; then $IP -n ns2 route add 10.1.1.0/24 dev ipt2 $IP netns exec ns2 sysctl -q -w net.ipv4.conf.all.rp_filter=0 $IP netns exec ns2 sysctl -q -w net.ipv4.conf.ipt2.rp_filter=0 else $IP -n ns2 route add 10.1.1.0/24 dev ip6t2 $IP -n ns2 route add 2401:db01::/64 dev ip6t2 $IP netns exec ns2 sysctl -q -w net.ipv4.conf.all.rp_filter=0 $IP netns exec ns2 sysctl -q -w net.ipv4.conf.ip6t2.rp_filter=0 fi $IP addr add 10.1.1.1/24 dev ve1 $IP addr add 2401:db01::1/64 dev ve1 nodad $IP addr add 10.2.1.1/24 dev ve2 $IP addr add 2401:db02::1/64 dev ve2 nodad $TC qdisc add dev ve2 clsact $TC filter add dev ve2 ingress bpf da obj $REDIRECT_BPF sec l2_to_iptun_ingress_forward sysctl -q -w net.ipv4.conf.all.rp_filter=0 sysctl -q -w net.ipv6.conf.all.forwarding=1 } function cleanup { set +e [[ -z $DEBUG ]] || set +x $IP netns delete ns1 >& /dev/null $IP netns delete ns2 >& /dev/null $IP link del ve1 >& /dev/null $IP link del ve2 >& /dev/null $IP link del ipt >& /dev/null $IP link del ip6t >& /dev/null sysctl -q -w net.ipv4.conf.all.rp_filter=$RP_FILTER sysctl -q -w net.ipv6.conf.all.forwarding=$IPV6_FORWARDING rm -f /sys/fs/bpf/tc/globals/tun_iface [[ -z $DEBUG ]] || set -x set -e } function l2_to_ipip { echo -n "l2_to_ipip $1: " local dir=$1 config_common ipip $IP link add ipt type ipip external $IP link set dev ipt up sysctl -q -w net.ipv4.conf.ipt.rp_filter=0 sysctl -q -w net.ipv4.conf.ipt.forwarding=1 if [[ $dir == "egress" ]]; then $IP route add 10.10.1.0/24 via 10.2.1.102 dev ve2 $TC filter add dev ve2 egress bpf da obj $REDIRECT_BPF sec l2_to_iptun_ingress_redirect sysctl -q -w net.ipv4.conf.ve1.forwarding=1 else $TC qdisc add dev ve1 clsact $TC filter add dev ve1 ingress bpf da obj $REDIRECT_BPF sec l2_to_iptun_ingress_redirect fi $REDIRECT_USER -U /sys/fs/bpf/tc/globals/tun_iface -i $(< /sys/class/net/ipt/ifindex) $IP netns exec ns1 ping -c1 10.10.1.102 >& /dev/null if [[ $dir == "egress" ]]; then # test direct egress to ve2 (i.e. not forwarding from # ve1 to ve2). ping -c1 10.10.1.102 >& /dev/null fi cleanup echo "OK" } function l2_to_ip6tnl { echo -n "l2_to_ip6tnl $1: " local dir=$1 config_common ip6tnl $IP link add ip6t type ip6tnl mode any external $IP link set dev ip6t up sysctl -q -w net.ipv4.conf.ip6t.rp_filter=0 sysctl -q -w net.ipv4.conf.ip6t.forwarding=1 if [[ $dir == "egress" ]]; then $IP route add 10.10.1.0/24 via 10.2.1.102 dev ve2 $IP route add 2401:face::/64 via 2401:db02::66 dev ve2 $TC filter add dev ve2 egress bpf da obj $REDIRECT_BPF sec l2_to_ip6tun_ingress_redirect sysctl -q -w net.ipv4.conf.ve1.forwarding=1 else $TC qdisc add dev ve1 clsact $TC filter add dev ve1 ingress bpf da obj $REDIRECT_BPF sec l2_to_ip6tun_ingress_redirect fi $REDIRECT_USER -U /sys/fs/bpf/tc/globals/tun_iface -i $(< /sys/class/net/ip6t/ifindex) $IP netns exec ns1 ping -c1 10.10.1.102 >& /dev/null $IP netns exec ns1 ping -6 -c1 2401:face::66 >& /dev/null if [[ $dir == "egress" ]]; then # test direct egress to ve2 (i.e. not forwarding from # ve1 to ve2). ping -c1 10.10.1.102 >& /dev/null ping -6 -c1 2401:face::66 >& /dev/null fi cleanup echo "OK" } cleanup test_names="l2_to_ipip l2_to_ip6tnl" test_dirs="ingress egress" if [[ $# -ge 2 ]]; then test_names=$1 test_dirs=$2 elif [[ $# -ge 1 ]]; then test_names=$1 fi for t in $test_names; do for d in $test_dirs; do $t $d done done bpf/test_override_return.sh 0000755 00000000424 14722051373 0012133 0 ustar 00 #!/bin/bash rm -r tmpmnt rm -f testfile.img dd if=/dev/zero of=testfile.img bs=1M seek=1000 count=1 DEVICE=$(losetup --show -f testfile.img) mkfs.btrfs -f $DEVICE mkdir tmpmnt ./tracex7 $DEVICE if [ $? -eq 0 ] then echo "SUCCESS!" else echo "FAILED!" fi losetup -d $DEVICE bpf/test_ipip.sh 0000755 00000013130 14722051373 0007654 0 ustar 00 #!/bin/bash # SPDX-License-Identifier: GPL-2.0 function config_device { ip netns add at_ns0 ip netns add at_ns1 ip netns add at_ns2 ip link add veth0 type veth peer name veth0b ip link add veth1 type veth peer name veth1b ip link add veth2 type veth peer name veth2b ip link set veth0b up ip link set veth1b up ip link set veth2b up ip link set dev veth0b mtu 1500 ip link set dev veth1b mtu 1500 ip link set dev veth2b mtu 1500 ip link set veth0 netns at_ns0 ip link set veth1 netns at_ns1 ip link set veth2 netns at_ns2 ip netns exec at_ns0 ip addr add 172.16.1.100/24 dev veth0 ip netns exec at_ns0 ip addr add 2401:db00::1/64 dev veth0 nodad ip netns exec at_ns0 ip link set dev veth0 up ip netns exec at_ns1 ip addr add 172.16.1.101/24 dev veth1 ip netns exec at_ns1 ip addr add 2401:db00::2/64 dev veth1 nodad ip netns exec at_ns1 ip link set dev veth1 up ip netns exec at_ns2 ip addr add 172.16.1.200/24 dev veth2 ip netns exec at_ns2 ip addr add 2401:db00::3/64 dev veth2 nodad ip netns exec at_ns2 ip link set dev veth2 up ip link add br0 type bridge ip link set br0 up ip link set dev br0 mtu 1500 ip link set veth0b master br0 ip link set veth1b master br0 ip link set veth2b master br0 } function add_ipip_tunnel { ip netns exec at_ns0 \ ip link add dev $DEV_NS type ipip local 172.16.1.100 remote 172.16.1.200 ip netns exec at_ns0 ip link set dev $DEV_NS up ip netns exec at_ns0 ip addr add dev $DEV_NS 10.1.1.100/24 ip netns exec at_ns1 \ ip link add dev $DEV_NS type ipip local 172.16.1.101 remote 172.16.1.200 ip netns exec at_ns1 ip link set dev $DEV_NS up # same inner IP address in at_ns0 and at_ns1 ip netns exec at_ns1 ip addr add dev $DEV_NS 10.1.1.100/24 ip netns exec at_ns2 ip link add dev $DEV type ipip external ip netns exec at_ns2 ip link set dev $DEV up ip netns exec at_ns2 ip addr add dev $DEV 10.1.1.200/24 } function add_ipip6_tunnel { ip netns exec at_ns0 \ ip link add dev $DEV_NS type ip6tnl mode ipip6 local 2401:db00::1/64 remote 2401:db00::3/64 ip netns exec at_ns0 ip link set dev $DEV_NS up ip netns exec at_ns0 ip addr add dev $DEV_NS 10.1.1.100/24 ip netns exec at_ns1 \ ip link add dev $DEV_NS type ip6tnl mode ipip6 local 2401:db00::2/64 remote 2401:db00::3/64 ip netns exec at_ns1 ip link set dev $DEV_NS up # same inner IP address in at_ns0 and at_ns1 ip netns exec at_ns1 ip addr add dev $DEV_NS 10.1.1.100/24 ip netns exec at_ns2 ip link add dev $DEV type ip6tnl mode ipip6 external ip netns exec at_ns2 ip link set dev $DEV up ip netns exec at_ns2 ip addr add dev $DEV 10.1.1.200/24 } function add_ip6ip6_tunnel { ip netns exec at_ns0 \ ip link add dev $DEV_NS type ip6tnl mode ip6ip6 local 2401:db00::1/64 remote 2401:db00::3/64 ip netns exec at_ns0 ip link set dev $DEV_NS up ip netns exec at_ns0 ip addr add dev $DEV_NS 2601:646::1/64 ip netns exec at_ns1 \ ip link add dev $DEV_NS type ip6tnl mode ip6ip6 local 2401:db00::2/64 remote 2401:db00::3/64 ip netns exec at_ns1 ip link set dev $DEV_NS up # same inner IP address in at_ns0 and at_ns1 ip netns exec at_ns1 ip addr add dev $DEV_NS 2601:646::1/64 ip netns exec at_ns2 ip link add dev $DEV type ip6tnl mode ip6ip6 external ip netns exec at_ns2 ip link set dev $DEV up ip netns exec at_ns2 ip addr add dev $DEV 2601:646::2/64 } function attach_bpf { DEV=$1 SET_TUNNEL=$2 GET_TUNNEL=$3 ip netns exec at_ns2 tc qdisc add dev $DEV clsact ip netns exec at_ns2 tc filter add dev $DEV egress bpf da obj tcbpf2_kern.o sec $SET_TUNNEL ip netns exec at_ns2 tc filter add dev $DEV ingress bpf da obj tcbpf2_kern.o sec $GET_TUNNEL } function test_ipip { DEV_NS=ipip_std DEV=ipip_bpf config_device # tcpdump -nei br0 & cat /sys/kernel/debug/tracing/trace_pipe & add_ipip_tunnel attach_bpf $DEV ipip_set_tunnel ipip_get_tunnel ip netns exec at_ns0 ping -c 1 10.1.1.200 ip netns exec at_ns2 ping -c 1 10.1.1.100 ip netns exec at_ns0 iperf -sD -p 5200 > /dev/null ip netns exec at_ns1 iperf -sD -p 5201 > /dev/null sleep 0.2 # tcp check _same_ IP over different tunnels ip netns exec at_ns2 iperf -c 10.1.1.100 -n 5k -p 5200 ip netns exec at_ns2 iperf -c 10.1.1.100 -n 5k -p 5201 cleanup } # IPv4 over IPv6 tunnel function test_ipip6 { DEV_NS=ipip_std DEV=ipip_bpf config_device # tcpdump -nei br0 & cat /sys/kernel/debug/tracing/trace_pipe & add_ipip6_tunnel attach_bpf $DEV ipip6_set_tunnel ipip6_get_tunnel ip netns exec at_ns0 ping -c 1 10.1.1.200 ip netns exec at_ns2 ping -c 1 10.1.1.100 ip netns exec at_ns0 iperf -sD -p 5200 > /dev/null ip netns exec at_ns1 iperf -sD -p 5201 > /dev/null sleep 0.2 # tcp check _same_ IP over different tunnels ip netns exec at_ns2 iperf -c 10.1.1.100 -n 5k -p 5200 ip netns exec at_ns2 iperf -c 10.1.1.100 -n 5k -p 5201 cleanup } # IPv6 over IPv6 tunnel function test_ip6ip6 { DEV_NS=ipip_std DEV=ipip_bpf config_device # tcpdump -nei br0 & cat /sys/kernel/debug/tracing/trace_pipe & add_ip6ip6_tunnel attach_bpf $DEV ip6ip6_set_tunnel ip6ip6_get_tunnel ip netns exec at_ns0 ping -6 -c 1 2601:646::2 ip netns exec at_ns2 ping -6 -c 1 2601:646::1 ip netns exec at_ns0 iperf -6sD -p 5200 > /dev/null ip netns exec at_ns1 iperf -6sD -p 5201 > /dev/null sleep 0.2 # tcp check _same_ IP over different tunnels ip netns exec at_ns2 iperf -6c 2601:646::1 -n 5k -p 5200 ip netns exec at_ns2 iperf -6c 2601:646::1 -n 5k -p 5201 cleanup } function cleanup { set +ex pkill iperf ip netns delete at_ns0 ip netns delete at_ns1 ip netns delete at_ns2 ip link del veth0 ip link del veth1 ip link del veth2 ip link del br0 pkill tcpdump pkill cat set -ex } cleanup echo "Testing IP tunnels..." test_ipip test_ipip6 test_ip6ip6 echo "*** PASS ***" bpf/xdp2skb_meta.sh 0000755 00000011002 14722051373 0010233 0 ustar 00 #!/bin/bash # # SPDX-License-Identifier: GPL-2.0 # Copyright (c) 2018 Jesper Dangaard Brouer, Red Hat Inc. # # Bash-shell example on using iproute2 tools 'tc' and 'ip' to load # eBPF programs, both for XDP and clsbpf. Shell script function # wrappers and even long options parsing is illustrated, for ease of # use. # # Related to sample/bpf/xdp2skb_meta_kern.c, which contains BPF-progs # that need to collaborate between XDP and TC hooks. Thus, it is # convenient that the same tool load both programs that need to work # together. # BPF_FILE=xdp2skb_meta_kern.o DIR=$(dirname $0) [ -z "$TC" ] && TC=tc [ -z "$IP" ] && IP=ip function usage() { echo "" echo "Usage: $0 [-vfh] --dev ethX" echo " -d | --dev : Network device (required)" echo " --flush : Cleanup flush TC and XDP progs" echo " --list : (\$LIST) List TC and XDP progs" echo " -v | --verbose : (\$VERBOSE) Verbose" echo " --dry-run : (\$DRYRUN) Dry-run only (echo commands)" echo "" } ## -- General shell logging cmds -- function err() { local exitcode=$1 shift echo "ERROR: $@" >&2 exit $exitcode } function info() { if [[ -n "$VERBOSE" ]]; then echo "# $@" fi } ## -- Helper function calls -- # Wrapper call for TC and IP # - Will display the offending command on failure function _call_cmd() { local cmd="$1" local allow_fail="$2" shift 2 if [[ -n "$VERBOSE" ]]; then echo "$cmd $@" fi if [[ -n "$DRYRUN" ]]; then return fi $cmd "$@" local status=$? if (( $status != 0 )); then if [[ "$allow_fail" == "" ]]; then err 2 "Exec error($status) occurred cmd: \"$cmd $@\"" fi fi } function call_tc() { _call_cmd "$TC" "" "$@" } function call_tc_allow_fail() { _call_cmd "$TC" "allow_fail" "$@" } function call_ip() { _call_cmd "$IP" "" "$@" } ## --- Parse command line arguments / parameters --- # Using external program "getopt" to get --long-options OPTIONS=$(getopt -o vfhd: \ --long verbose,flush,help,list,dev:,dry-run -- "$@") if (( $? != 0 )); then err 4 "Error calling getopt" fi eval set -- "$OPTIONS" unset DEV unset FLUSH while true; do case "$1" in -d | --dev ) # device DEV=$2 info "Device set to: DEV=$DEV" >&2 shift 2 ;; -v | --verbose) VERBOSE=yes # info "Verbose mode: VERBOSE=$VERBOSE" >&2 shift ;; --dry-run ) DRYRUN=yes VERBOSE=yes info "Dry-run mode: enable VERBOSE and don't call TC+IP" >&2 shift ;; -f | --flush ) FLUSH=yes shift ;; --list ) LIST=yes shift ;; -- ) shift break ;; -h | --help ) usage; exit 0 ;; * ) shift break ;; esac done FILE="$DIR/$BPF_FILE" if [[ ! -e $FILE ]]; then err 3 "Missing BPF object file ($FILE)" fi if [[ -z $DEV ]]; then usage err 2 "Please specify network device -- required option --dev" fi ## -- Function calls -- function list_tc() { local device="$1" shift info "Listing current TC ingress rules" call_tc filter show dev $device ingress } function list_xdp() { local device="$1" shift info "Listing current XDP device($device) setting" call_ip link show dev $device | grep --color=auto xdp } function flush_tc() { local device="$1" shift info "Flush TC on device: $device" call_tc_allow_fail filter del dev $device ingress call_tc_allow_fail qdisc del dev $device clsact } function flush_xdp() { local device="$1" shift info "Flush XDP on device: $device" call_ip link set dev $device xdp off } function attach_tc_mark() { local device="$1" local file="$2" local prog="tc_mark" shift 2 # Re-attach clsact to clear/flush existing role call_tc_allow_fail qdisc del dev $device clsact 2> /dev/null call_tc qdisc add dev $device clsact # Attach BPF prog call_tc filter add dev $device ingress \ prio 1 handle 1 bpf da obj $file sec $prog } function attach_xdp_mark() { local device="$1" local file="$2" local prog="xdp_mark" shift 2 # Remove XDP prog in-case it's already loaded # TODO: Need ip-link option to override/replace existing XDP prog flush_xdp $device # Attach XDP/BPF prog call_ip link set dev $device xdp obj $file sec $prog } if [[ -n $FLUSH ]]; then flush_tc $DEV flush_xdp $DEV exit 0 fi if [[ -n $LIST ]]; then list_tc $DEV list_xdp $DEV exit 0 fi attach_tc_mark $DEV $FILE attach_xdp_mark $DEV $FILE bpf/lwt_len_hist.sh 0000755 00000002027 14722051373 0010352 0 ustar 00 #!/bin/bash # SPDX-License-Identifier: GPL-2.0 NS1=lwt_ns1 VETH0=tst_lwt1a VETH1=tst_lwt1b TRACE_ROOT=/sys/kernel/debug/tracing function cleanup { # To reset saved histogram, remove pinned map rm /sys/fs/bpf/tc/globals/lwt_len_hist_map ip route del 192.168.253.2/32 dev $VETH0 2> /dev/null ip link del $VETH0 2> /dev/null ip link del $VETH1 2> /dev/null ip netns exec $NS1 killall netserver ip netns delete $NS1 2> /dev/null } cleanup ip netns add $NS1 ip link add $VETH0 type veth peer name $VETH1 ip link set dev $VETH0 up ip addr add 192.168.253.1/24 dev $VETH0 ip link set $VETH1 netns $NS1 ip netns exec $NS1 ip link set dev $VETH1 up ip netns exec $NS1 ip addr add 192.168.253.2/24 dev $VETH1 ip netns exec $NS1 netserver echo 1 > ${TRACE_ROOT}/tracing_on cp /dev/null ${TRACE_ROOT}/trace ip route add 192.168.253.2/32 encap bpf out obj lwt_len_hist_kern.o section len_hist dev $VETH0 netperf -H 192.168.253.2 -t TCP_STREAM cat ${TRACE_ROOT}/trace | grep -v '^#' ./lwt_len_hist cleanup echo 0 > ${TRACE_ROOT}/tracing_on exit 0 bpf/test_lwt_bpf.sh 0000755 00000021722 14722051373 0010356 0 ustar 00 #!/bin/bash # SPDX-License-Identifier: GPL-2.0 # Uncomment to see generated bytecode #VERBOSE=verbose NS1=lwt_ns1 NS2=lwt_ns2 VETH0=tst_lwt1a VETH1=tst_lwt1b VETH2=tst_lwt2a VETH3=tst_lwt2b IPVETH0="192.168.254.1" IPVETH1="192.168.254.2" IPVETH1b="192.168.254.3" IPVETH2="192.168.111.1" IPVETH3="192.168.111.2" IP_LOCAL="192.168.99.1" TRACE_ROOT=/sys/kernel/debug/tracing function lookup_mac() { set +x if [ ! -z "$2" ]; then MAC=$(ip netns exec $2 ip link show $1 | grep ether | awk '{print $2}') else MAC=$(ip link show $1 | grep ether | awk '{print $2}') fi MAC="${MAC//:/}" echo "0x${MAC:10:2}${MAC:8:2}${MAC:6:2}${MAC:4:2}${MAC:2:2}${MAC:0:2}" set -x } function cleanup { set +ex rm test_lwt_bpf.o 2> /dev/null ip link del $VETH0 2> /dev/null ip link del $VETH1 2> /dev/null ip link del $VETH2 2> /dev/null ip link del $VETH3 2> /dev/null ip netns exec $NS1 killall netserver ip netns delete $NS1 2> /dev/null ip netns delete $NS2 2> /dev/null set -ex } function setup_one_veth { ip netns add $1 ip link add $2 type veth peer name $3 ip link set dev $2 up ip addr add $4/24 dev $2 ip link set $3 netns $1 ip netns exec $1 ip link set dev $3 up ip netns exec $1 ip addr add $5/24 dev $3 if [ "$6" ]; then ip netns exec $1 ip addr add $6/32 dev $3 fi } function get_trace { set +x cat ${TRACE_ROOT}/trace | grep -v '^#' set -x } function cleanup_routes { ip route del ${IPVETH1}/32 dev $VETH0 2> /dev/null || true ip route del table local local ${IP_LOCAL}/32 dev lo 2> /dev/null || true } function install_test { cleanup_routes cp /dev/null ${TRACE_ROOT}/trace OPTS="encap bpf headroom 14 $1 obj test_lwt_bpf.o section $2 $VERBOSE" if [ "$1" == "in" ]; then ip route add table local local ${IP_LOCAL}/32 $OPTS dev lo else ip route add ${IPVETH1}/32 $OPTS dev $VETH0 fi } function remove_prog { if [ "$1" == "in" ]; then ip route del table local local ${IP_LOCAL}/32 dev lo else ip route del ${IPVETH1}/32 dev $VETH0 fi } function filter_trace { # Add newline to allow starting EXPECT= variables on newline NL=$'\n' echo "${NL}$*" | sed -e 's/^.*: : //g' } function expect_fail { set +x echo "FAIL:" echo "Expected: $1" echo "Got: $2" set -x exit 1 } function match_trace { set +x RET=0 TRACE=$1 EXPECT=$2 GOT="$(filter_trace "$TRACE")" [ "$GOT" != "$EXPECT" ] && { expect_fail "$EXPECT" "$GOT" RET=1 } set -x return $RET } function test_start { set +x echo "----------------------------------------------------------------" echo "Starting test: $*" echo "----------------------------------------------------------------" set -x } function failure { get_trace echo "FAIL: $*" exit 1 } function test_ctx_xmit { test_start "test_ctx on lwt xmit" install_test xmit test_ctx ping -c 3 $IPVETH1 || { failure "test_ctx xmit: packets are dropped" } match_trace "$(get_trace)" " len 84 hash 0 protocol 8 cb 1234 ingress_ifindex 0 ifindex $DST_IFINDEX len 84 hash 0 protocol 8 cb 1234 ingress_ifindex 0 ifindex $DST_IFINDEX len 84 hash 0 protocol 8 cb 1234 ingress_ifindex 0 ifindex $DST_IFINDEX" || exit 1 remove_prog xmit } function test_ctx_out { test_start "test_ctx on lwt out" install_test out test_ctx ping -c 3 $IPVETH1 || { failure "test_ctx out: packets are dropped" } match_trace "$(get_trace)" " len 84 hash 0 protocol 0 cb 1234 ingress_ifindex 0 ifindex 0 len 84 hash 0 protocol 0 cb 1234 ingress_ifindex 0 ifindex 0 len 84 hash 0 protocol 0 cb 1234 ingress_ifindex 0 ifindex 0" || exit 1 remove_prog out } function test_ctx_in { test_start "test_ctx on lwt in" install_test in test_ctx ping -c 3 $IP_LOCAL || { failure "test_ctx out: packets are dropped" } # We will both request & reply packets as the packets will # be from $IP_LOCAL => $IP_LOCAL match_trace "$(get_trace)" " len 84 hash 0 protocol 8 cb 1234 ingress_ifindex 1 ifindex 1 len 84 hash 0 protocol 8 cb 1234 ingress_ifindex 1 ifindex 1 len 84 hash 0 protocol 8 cb 1234 ingress_ifindex 1 ifindex 1 len 84 hash 0 protocol 8 cb 1234 ingress_ifindex 1 ifindex 1 len 84 hash 0 protocol 8 cb 1234 ingress_ifindex 1 ifindex 1 len 84 hash 0 protocol 8 cb 1234 ingress_ifindex 1 ifindex 1" || exit 1 remove_prog in } function test_data { test_start "test_data on lwt $1" install_test $1 test_data ping -c 3 $IPVETH1 || { failure "test_data ${1}: packets are dropped" } match_trace "$(get_trace)" " src: 1fea8c0 dst: 2fea8c0 src: 1fea8c0 dst: 2fea8c0 src: 1fea8c0 dst: 2fea8c0" || exit 1 remove_prog $1 } function test_data_in { test_start "test_data on lwt in" install_test in test_data ping -c 3 $IP_LOCAL || { failure "test_data in: packets are dropped" } # We will both request & reply packets as the packets will # be from $IP_LOCAL => $IP_LOCAL match_trace "$(get_trace)" " src: 163a8c0 dst: 163a8c0 src: 163a8c0 dst: 163a8c0 src: 163a8c0 dst: 163a8c0 src: 163a8c0 dst: 163a8c0 src: 163a8c0 dst: 163a8c0 src: 163a8c0 dst: 163a8c0" || exit 1 remove_prog in } function test_cb { test_start "test_cb on lwt $1" install_test $1 test_cb ping -c 3 $IPVETH1 || { failure "test_cb ${1}: packets are dropped" } match_trace "$(get_trace)" " cb0: 0 cb1: 0 cb2: 0 cb3: 0 cb4: 0 cb0: 0 cb1: 0 cb2: 0 cb3: 0 cb4: 0 cb0: 0 cb1: 0 cb2: 0 cb3: 0 cb4: 0" || exit 1 remove_prog $1 } function test_cb_in { test_start "test_cb on lwt in" install_test in test_cb ping -c 3 $IP_LOCAL || { failure "test_cb in: packets are dropped" } # We will both request & reply packets as the packets will # be from $IP_LOCAL => $IP_LOCAL match_trace "$(get_trace)" " cb0: 0 cb1: 0 cb2: 0 cb3: 0 cb4: 0 cb0: 0 cb1: 0 cb2: 0 cb3: 0 cb4: 0 cb0: 0 cb1: 0 cb2: 0 cb3: 0 cb4: 0 cb0: 0 cb1: 0 cb2: 0 cb3: 0 cb4: 0 cb0: 0 cb1: 0 cb2: 0 cb3: 0 cb4: 0 cb0: 0 cb1: 0 cb2: 0 cb3: 0 cb4: 0" || exit 1 remove_prog in } function test_drop_all { test_start "test_drop_all on lwt $1" install_test $1 drop_all ping -c 3 $IPVETH1 && { failure "test_drop_all ${1}: Unexpected success of ping" } match_trace "$(get_trace)" " dropping with: 2 dropping with: 2 dropping with: 2" || exit 1 remove_prog $1 } function test_drop_all_in { test_start "test_drop_all on lwt in" install_test in drop_all ping -c 3 $IP_LOCAL && { failure "test_drop_all in: Unexpected success of ping" } match_trace "$(get_trace)" " dropping with: 2 dropping with: 2 dropping with: 2" || exit 1 remove_prog in } function test_push_ll_and_redirect { test_start "test_push_ll_and_redirect on lwt xmit" install_test xmit push_ll_and_redirect ping -c 3 $IPVETH1 || { failure "Redirected packets appear to be dropped" } match_trace "$(get_trace)" " redirected to $DST_IFINDEX redirected to $DST_IFINDEX redirected to $DST_IFINDEX" || exit 1 remove_prog xmit } function test_no_l2_and_redirect { test_start "test_no_l2_and_redirect on lwt xmit" install_test xmit fill_garbage_and_redirect ping -c 3 $IPVETH1 && { failure "Unexpected success despite lack of L2 header" } match_trace "$(get_trace)" " redirected to $DST_IFINDEX redirected to $DST_IFINDEX redirected to $DST_IFINDEX" || exit 1 remove_prog xmit } function test_rewrite { test_start "test_rewrite on lwt xmit" install_test xmit test_rewrite ping -c 3 $IPVETH1 || { failure "Rewritten packets appear to be dropped" } match_trace "$(get_trace)" " out: rewriting from 2fea8c0 to 3fea8c0 out: rewriting from 2fea8c0 to 3fea8c0 out: rewriting from 2fea8c0 to 3fea8c0" || exit 1 remove_prog out } function test_fill_garbage { test_start "test_fill_garbage on lwt xmit" install_test xmit fill_garbage ping -c 3 $IPVETH1 && { failure "test_drop_all ${1}: Unexpected success of ping" } match_trace "$(get_trace)" " Set initial 96 bytes of header to FF Set initial 96 bytes of header to FF Set initial 96 bytes of header to FF" || exit 1 remove_prog xmit } function test_netperf_nop { test_start "test_netperf_nop on lwt xmit" install_test xmit nop netperf -H $IPVETH1 -t TCP_STREAM || { failure "packets appear to be dropped" } match_trace "$(get_trace)" ""|| exit 1 remove_prog xmit } function test_netperf_redirect { test_start "test_netperf_redirect on lwt xmit" install_test xmit push_ll_and_redirect_silent netperf -H $IPVETH1 -t TCP_STREAM || { failure "Rewritten packets appear to be dropped" } match_trace "$(get_trace)" ""|| exit 1 remove_prog xmit } cleanup setup_one_veth $NS1 $VETH0 $VETH1 $IPVETH0 $IPVETH1 $IPVETH1b setup_one_veth $NS2 $VETH2 $VETH3 $IPVETH2 $IPVETH3 ip netns exec $NS1 netserver echo 1 > ${TRACE_ROOT}/tracing_on DST_MAC=$(lookup_mac $VETH1 $NS1) SRC_MAC=$(lookup_mac $VETH0) DST_IFINDEX=$(cat /sys/class/net/$VETH0/ifindex) CLANG_OPTS="-O2 -target bpf -I ../include/" CLANG_OPTS+=" -DSRC_MAC=$SRC_MAC -DDST_MAC=$DST_MAC -DDST_IFINDEX=$DST_IFINDEX" clang $CLANG_OPTS -c test_lwt_bpf.c -o test_lwt_bpf.o test_ctx_xmit test_ctx_out test_ctx_in test_data "xmit" test_data "out" test_data_in test_cb "xmit" test_cb "out" test_cb_in test_drop_all "xmit" test_drop_all "out" test_drop_all_in test_rewrite test_push_ll_and_redirect test_no_l2_and_redirect test_fill_garbage test_netperf_nop test_netperf_redirect cleanup echo 0 > ${TRACE_ROOT}/tracing_on exit 0 bpf/test_cls_bpf.sh 0000755 00000001623 14722051373 0010327 0 ustar 00 #!/bin/bash # SPDX-License-Identifier: GPL-2.0 function pktgen { ../pktgen/pktgen_bench_xmit_mode_netif_receive.sh -i $IFC -s 64 \ -m 90:e2:ba:ff:ff:ff -d 192.168.0.1 -t 4 local dropped=`tc -s qdisc show dev $IFC | tail -3 | awk '/drop/{print $7}'` if [ "$dropped" == "0," ]; then echo "FAIL" else echo "Successfully filtered " $dropped " packets" fi } function test { echo -n "Loading bpf program '$2'... " tc qdisc add dev $IFC clsact tc filter add dev $IFC ingress bpf da obj $1 sec $2 local status=$? if [ $status -ne 0 ]; then echo "FAIL" else echo "ok" pktgen fi tc qdisc del dev $IFC clsact } IFC=test_veth ip link add name $IFC type veth peer name pair_$IFC ip link set $IFC up ip link set pair_$IFC up test ./parse_simple.o simple test ./parse_varlen.o varlen test ./parse_ldabs.o ldabs ip link del dev $IFC bpf/Makefile 0000644 00000023735 14722051373 0006771 0 ustar 00 # SPDX-License-Identifier: GPL-2.0 BPF_SAMPLES_PATH ?= $(abspath $(srctree)/$(src)) TOOLS_PATH := $(BPF_SAMPLES_PATH)/../../tools # List of programs to build hostprogs-y := test_lru_dist hostprogs-y += sock_example hostprogs-y += fds_example hostprogs-y += sockex1 hostprogs-y += sockex2 hostprogs-y += sockex3 hostprogs-y += tracex1 hostprogs-y += tracex2 hostprogs-y += tracex3 hostprogs-y += tracex4 hostprogs-y += tracex5 hostprogs-y += tracex6 hostprogs-y += tracex7 hostprogs-y += test_probe_write_user hostprogs-y += trace_output hostprogs-y += lathist hostprogs-y += offwaketime hostprogs-y += spintest hostprogs-y += map_perf_test hostprogs-y += test_overhead hostprogs-y += test_cgrp2_array_pin hostprogs-y += test_cgrp2_attach hostprogs-y += test_cgrp2_sock hostprogs-y += test_cgrp2_sock2 hostprogs-y += xdp1 hostprogs-y += xdp2 hostprogs-y += xdp_router_ipv4 hostprogs-y += test_current_task_under_cgroup hostprogs-y += trace_event hostprogs-y += sampleip hostprogs-y += tc_l2_redirect hostprogs-y += lwt_len_hist hostprogs-y += xdp_tx_iptunnel hostprogs-y += test_map_in_map hostprogs-y += per_socket_stats_example hostprogs-y += xdp_redirect hostprogs-y += xdp_redirect_map hostprogs-y += xdp_redirect_cpu hostprogs-y += xdp_monitor hostprogs-y += xdp_rxq_info hostprogs-y += syscall_tp hostprogs-y += cpustat hostprogs-y += xdp_adjust_tail hostprogs-y += xdpsock hostprogs-y += xdp_fwd hostprogs-y += task_fd_query hostprogs-y += xdp_sample_pkts hostprogs-y += ibumad hostprogs-y += hbm # Libbpf dependencies LIBBPF = $(TOOLS_PATH)/lib/bpf/libbpf.a CGROUP_HELPERS := ../../tools/testing/selftests/bpf/cgroup_helpers.o TRACE_HELPERS := ../../tools/testing/selftests/bpf/trace_helpers.o fds_example-objs := fds_example.o sockex1-objs := sockex1_user.o sockex2-objs := sockex2_user.o sockex3-objs := bpf_load.o sockex3_user.o tracex1-objs := bpf_load.o tracex1_user.o tracex2-objs := bpf_load.o tracex2_user.o tracex3-objs := bpf_load.o tracex3_user.o tracex4-objs := bpf_load.o tracex4_user.o tracex5-objs := bpf_load.o tracex5_user.o tracex6-objs := bpf_load.o tracex6_user.o tracex7-objs := bpf_load.o tracex7_user.o test_probe_write_user-objs := bpf_load.o test_probe_write_user_user.o trace_output-objs := bpf_load.o trace_output_user.o $(TRACE_HELPERS) lathist-objs := bpf_load.o lathist_user.o offwaketime-objs := bpf_load.o offwaketime_user.o $(TRACE_HELPERS) spintest-objs := bpf_load.o spintest_user.o $(TRACE_HELPERS) map_perf_test-objs := bpf_load.o map_perf_test_user.o test_overhead-objs := bpf_load.o test_overhead_user.o test_cgrp2_array_pin-objs := test_cgrp2_array_pin.o test_cgrp2_attach-objs := test_cgrp2_attach.o test_cgrp2_sock-objs := test_cgrp2_sock.o test_cgrp2_sock2-objs := bpf_load.o test_cgrp2_sock2.o xdp1-objs := xdp1_user.o # reuse xdp1 source intentionally xdp2-objs := xdp1_user.o xdp_router_ipv4-objs := xdp_router_ipv4_user.o test_current_task_under_cgroup-objs := bpf_load.o $(CGROUP_HELPERS) \ test_current_task_under_cgroup_user.o trace_event-objs := bpf_load.o trace_event_user.o $(TRACE_HELPERS) sampleip-objs := bpf_load.o sampleip_user.o $(TRACE_HELPERS) tc_l2_redirect-objs := bpf_load.o tc_l2_redirect_user.o lwt_len_hist-objs := bpf_load.o lwt_len_hist_user.o xdp_tx_iptunnel-objs := xdp_tx_iptunnel_user.o test_map_in_map-objs := bpf_load.o test_map_in_map_user.o per_socket_stats_example-objs := cookie_uid_helper_example.o xdp_redirect-objs := xdp_redirect_user.o xdp_redirect_map-objs := xdp_redirect_map_user.o xdp_redirect_cpu-objs := bpf_load.o xdp_redirect_cpu_user.o xdp_monitor-objs := bpf_load.o xdp_monitor_user.o xdp_rxq_info-objs := xdp_rxq_info_user.o syscall_tp-objs := bpf_load.o syscall_tp_user.o cpustat-objs := bpf_load.o cpustat_user.o xdp_adjust_tail-objs := xdp_adjust_tail_user.o xdpsock-objs := xdpsock_user.o xdp_fwd-objs := xdp_fwd_user.o task_fd_query-objs := bpf_load.o task_fd_query_user.o $(TRACE_HELPERS) xdp_sample_pkts-objs := xdp_sample_pkts_user.o $(TRACE_HELPERS) ibumad-objs := bpf_load.o ibumad_user.o $(TRACE_HELPERS) hbm-objs := bpf_load.o hbm.o $(CGROUP_HELPERS) # Tell kbuild to always build the programs always := $(hostprogs-y) always += sockex1_kern.o always += sockex2_kern.o always += sockex3_kern.o always += tracex1_kern.o always += tracex2_kern.o always += tracex3_kern.o always += tracex4_kern.o always += tracex5_kern.o always += tracex6_kern.o always += tracex7_kern.o always += sock_flags_kern.o always += test_probe_write_user_kern.o always += trace_output_kern.o always += tcbpf1_kern.o always += tc_l2_redirect_kern.o always += lathist_kern.o always += offwaketime_kern.o always += spintest_kern.o always += map_perf_test_kern.o always += test_overhead_tp_kern.o always += test_overhead_raw_tp_kern.o always += test_overhead_kprobe_kern.o always += parse_varlen.o parse_simple.o parse_ldabs.o always += test_cgrp2_tc_kern.o always += xdp1_kern.o always += xdp2_kern.o always += xdp_router_ipv4_kern.o always += test_current_task_under_cgroup_kern.o always += trace_event_kern.o always += sampleip_kern.o always += lwt_len_hist_kern.o always += xdp_tx_iptunnel_kern.o always += test_map_in_map_kern.o always += cookie_uid_helper_example.o always += tcp_synrto_kern.o always += tcp_rwnd_kern.o always += tcp_bufs_kern.o always += tcp_cong_kern.o always += tcp_iw_kern.o always += tcp_clamp_kern.o always += tcp_basertt_kern.o always += tcp_tos_reflect_kern.o always += tcp_dumpstats_kern.o always += xdp_redirect_kern.o always += xdp_redirect_map_kern.o always += xdp_redirect_cpu_kern.o always += xdp_monitor_kern.o always += xdp_rxq_info_kern.o always += xdp2skb_meta_kern.o always += syscall_tp_kern.o always += cpustat_kern.o always += xdp_adjust_tail_kern.o always += xdp_fwd_kern.o always += task_fd_query_kern.o always += xdp_sample_pkts_kern.o always += ibumad_kern.o always += hbm_out_kern.o always += hbm_edt_kern.o KBUILD_HOSTCFLAGS += -I$(objtree)/usr/include KBUILD_HOSTCFLAGS += -I$(srctree)/tools/lib/bpf/ KBUILD_HOSTCFLAGS += -I$(srctree)/tools/testing/selftests/bpf/ KBUILD_HOSTCFLAGS += -I$(srctree)/tools/lib/ -I$(srctree)/tools/include KBUILD_HOSTCFLAGS += -I$(srctree)/tools/perf KBUILD_HOSTCFLAGS += -DHAVE_ATTR_TEST=0 HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable KBUILD_HOSTLDLIBS += $(LIBBPF) -lelf HOSTLDLIBS_tracex4 += -lrt HOSTLDLIBS_trace_output += -lrt HOSTLDLIBS_map_perf_test += -lrt HOSTLDLIBS_test_overhead += -lrt HOSTLDLIBS_xdpsock += -pthread # Allows pointing LLC/CLANG to a LLVM backend with bpf support, redefine on cmdline: # make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang LLC ?= llc CLANG ?= clang LLVM_OBJCOPY ?= llvm-objcopy BTF_PAHOLE ?= pahole # Detect that we're cross compiling and use the cross compiler ifdef CROSS_COMPILE HOSTCC = $(CROSS_COMPILE)gcc CLANG_ARCH_ARGS = -target $(ARCH) endif # Don't evaluate probes and warnings if we need to run make recursively ifneq ($(src),) HDR_PROBE := $(shell echo "\#include <linux/types.h>\n struct list_head { int a; }; int main() { return 0; }" | \ $(HOSTCC) $(KBUILD_HOSTCFLAGS) -x c - -o /dev/null 2>/dev/null && \ echo okay) ifeq ($(HDR_PROBE),) $(warning WARNING: Detected possible issues with include path.) $(warning WARNING: Please install kernel headers locally (make headers_install).) endif BTF_LLC_PROBE := $(shell $(LLC) -march=bpf -mattr=help 2>&1 | grep dwarfris) BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF) BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --help 2>&1 | grep -i 'usage.*llvm') BTF_LLVM_PROBE := $(shell echo "int main() { return 0; }" | \ $(CLANG) -target bpf -O2 -g -c -x c - -o ./llvm_btf_verify.o; \ readelf -S ./llvm_btf_verify.o | grep BTF; \ /bin/rm -f ./llvm_btf_verify.o) BPF_EXTRA_CFLAGS += -fno-stack-protector ifneq ($(BTF_LLVM_PROBE),) EXTRA_CFLAGS += -g else ifneq ($(and $(BTF_LLC_PROBE),$(BTF_PAHOLE_PROBE),$(BTF_OBJCOPY_PROBE)),) EXTRA_CFLAGS += -g LLC_FLAGS += -mattr=dwarfris DWARF2BTF = y endif endif endif # Trick to allow make to be run from this directory all: $(MAKE) -C ../../ $(CURDIR)/ BPF_SAMPLES_PATH=$(CURDIR) clean: $(MAKE) -C ../../ M=$(CURDIR) clean @find $(CURDIR) -type f -name '*~' -delete $(LIBBPF): FORCE # Fix up variables inherited from Kbuild that tools/ build system won't like $(MAKE) -C $(dir $@) RM='rm -rf' LDFLAGS= srctree=$(BPF_SAMPLES_PATH)/../../ O= $(obj)/syscall_nrs.h: $(obj)/syscall_nrs.s FORCE $(call filechk,offsets,__SYSCALL_NRS_H__) targets += syscall_nrs.s clean-files += syscall_nrs.h FORCE: # Verify LLVM compiler tools are available and bpf target is supported by llc .PHONY: verify_cmds verify_target_bpf $(CLANG) $(LLC) verify_cmds: $(CLANG) $(LLC) @for TOOL in $^ ; do \ if ! (which -- "$${TOOL}" > /dev/null 2>&1); then \ echo "*** ERROR: Cannot find LLVM tool $${TOOL}" ;\ exit 1; \ else true; fi; \ done verify_target_bpf: verify_cmds @if ! (${LLC} -march=bpf -mattr=help > /dev/null 2>&1); then \ echo "*** ERROR: LLVM (${LLC}) does not support 'bpf' target" ;\ echo " NOTICE: LLVM version >= 3.7.1 required" ;\ exit 2; \ else true; fi $(BPF_SAMPLES_PATH)/*.c: verify_target_bpf $(LIBBPF) $(src)/*.c: verify_target_bpf $(LIBBPF) $(obj)/tracex5_kern.o: $(obj)/syscall_nrs.h $(obj)/hbm_out_kern.o: $(src)/hbm.h $(src)/hbm_kern.h $(obj)/hbm.o: $(src)/hbm.h $(obj)/hbm_edt_kern.o: $(src)/hbm.h $(src)/hbm_kern.h # asm/sysreg.h - inline assembly used by it is incompatible with llvm. # But, there is no easy way to fix it, so just exclude it since it is # useless for BPF samples. $(obj)/%.o: $(src)/%.c @echo " CLANG-bpf " $@ $(Q)$(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) -I$(obj) \ -I$(srctree)/tools/testing/selftests/bpf/ \ -D__KERNEL__ -D__BPF_TRACING__ -Wno-unused-value -Wno-pointer-sign \ -D__TARGET_ARCH_$(SRCARCH) -Wno-compare-distinct-pointer-types \ -Wno-gnu-variable-sized-type-not-at-end \ -Wno-address-of-packed-member -Wno-tautological-compare \ -Wno-unknown-warning-option $(CLANG_ARCH_ARGS) \ -I$(srctree)/samples/bpf/ -include asm_goto_workaround.h \ -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf $(LLC_FLAGS) -filetype=obj -o $@ ifeq ($(DWARF2BTF),y) $(BTF_PAHOLE) -J $@ endif bpf/test_cgrp2_sock2.sh 0000755 00000003026 14722051373 0011034 0 ustar 00 #!/bin/bash # SPDX-License-Identifier: GPL-2.0 function config_device { ip netns add at_ns0 ip link add veth0 type veth peer name veth0b ip link set veth0b up ip link set veth0 netns at_ns0 ip netns exec at_ns0 ip addr add 172.16.1.100/24 dev veth0 ip netns exec at_ns0 ip addr add 2401:db00::1/64 dev veth0 nodad ip netns exec at_ns0 ip link set dev veth0 up ip addr add 172.16.1.101/24 dev veth0b ip addr add 2401:db00::2/64 dev veth0b nodad } function config_cgroup { rm -rf /tmp/cgroupv2 mkdir -p /tmp/cgroupv2 mount -t cgroup2 none /tmp/cgroupv2 mkdir -p /tmp/cgroupv2/foo echo $$ >> /tmp/cgroupv2/foo/cgroup.procs } function attach_bpf { test_cgrp2_sock2 /tmp/cgroupv2/foo sock_flags_kern.o $1 [ $? -ne 0 ] && exit 1 } function cleanup { if [ -d /tmp/cgroupv2/foo ]; then test_cgrp2_sock -d /tmp/cgroupv2/foo fi ip link del veth0b ip netns delete at_ns0 umount /tmp/cgroupv2 rm -rf /tmp/cgroupv2 } cleanup 2>/dev/null set -e config_device config_cgroup set +e # # Test 1 - fail ping6 # attach_bpf 0 ping -c1 -w1 172.16.1.100 if [ $? -ne 0 ]; then echo "ping failed when it should succeed" cleanup exit 1 fi ping6 -c1 -w1 2401:db00::1 if [ $? -eq 0 ]; then echo "ping6 succeeded when it should not" cleanup exit 1 fi # # Test 2 - fail ping # attach_bpf 1 ping6 -c1 -w1 2401:db00::1 if [ $? -ne 0 ]; then echo "ping6 failed when it should succeed" cleanup exit 1 fi ping -c1 -w1 172.16.1.100 if [ $? -eq 0 ]; then echo "ping succeeded when it should not" cleanup exit 1 fi cleanup echo echo "*** PASS ***" bpf/test_cgrp2_tc.sh 0000755 00000010236 14722051373 0010422 0 ustar 00 #!/bin/bash # SPDX-License-Identifier: GPL-2.0 MY_DIR=$(dirname $0) # Details on the bpf prog BPF_CGRP2_ARRAY_NAME='test_cgrp2_array_pin' BPF_PROG="$MY_DIR/test_cgrp2_tc_kern.o" BPF_SECTION='filter' [ -z "$TC" ] && TC='tc' [ -z "$IP" ] && IP='ip' # Names of the veth interface, net namespace...etc. HOST_IFC='ve' NS_IFC='vens' NS='ns' find_mnt() { cat /proc/mounts | \ awk '{ if ($3 == "'$1'" && mnt == "") { mnt = $2 }} END { print mnt }' } # Init cgroup2 vars init_cgrp2_vars() { CGRP2_ROOT=$(find_mnt cgroup2) if [ -z "$CGRP2_ROOT" ] then CGRP2_ROOT='/mnt/cgroup2' MOUNT_CGRP2="yes" fi CGRP2_TC="$CGRP2_ROOT/tc" CGRP2_TC_LEAF="$CGRP2_TC/leaf" } # Init bpf fs vars init_bpf_fs_vars() { local bpf_fs_root=$(find_mnt bpf) [ -n "$bpf_fs_root" ] || return -1 BPF_FS_TC_SHARE="$bpf_fs_root/tc/globals" } setup_cgrp2() { case $1 in start) if [ "$MOUNT_CGRP2" == 'yes' ] then [ -d $CGRP2_ROOT ] || mkdir -p $CGRP2_ROOT mount -t cgroup2 none $CGRP2_ROOT || return $? fi mkdir -p $CGRP2_TC_LEAF ;; *) rmdir $CGRP2_TC_LEAF && rmdir $CGRP2_TC [ "$MOUNT_CGRP2" == 'yes' ] && umount $CGRP2_ROOT ;; esac } setup_bpf_cgrp2_array() { local bpf_cgrp2_array="$BPF_FS_TC_SHARE/$BPF_CGRP2_ARRAY_NAME" case $1 in start) $MY_DIR/test_cgrp2_array_pin -U $bpf_cgrp2_array -v $CGRP2_TC ;; *) [ -d "$BPF_FS_TC_SHARE" ] && rm -f $bpf_cgrp2_array ;; esac } setup_net() { case $1 in start) $IP link add $HOST_IFC type veth peer name $NS_IFC || return $? $IP link set dev $HOST_IFC up || return $? sysctl -q net.ipv6.conf.$HOST_IFC.accept_dad=0 $IP netns add ns || return $? $IP link set dev $NS_IFC netns ns || return $? $IP -n $NS link set dev $NS_IFC up || return $? $IP netns exec $NS sysctl -q net.ipv6.conf.$NS_IFC.accept_dad=0 $TC qdisc add dev $HOST_IFC clsact || return $? $TC filter add dev $HOST_IFC egress bpf da obj $BPF_PROG sec $BPF_SECTION || return $? ;; *) $IP netns del $NS $IP link del $HOST_IFC ;; esac } run_in_cgrp() { # Fork another bash and move it under the specified cgroup. # It makes the cgroup cleanup easier at the end of the test. cmd='echo $$ > ' cmd="$cmd $1/cgroup.procs; exec $2" bash -c "$cmd" } do_test() { run_in_cgrp $CGRP2_TC_LEAF "ping -6 -c3 ff02::1%$HOST_IFC >& /dev/null" local dropped=$($TC -s qdisc show dev $HOST_IFC | tail -3 | \ awk '/drop/{print substr($7, 0, index($7, ",")-1)}') if [[ $dropped -eq 0 ]] then echo "FAIL" return 1 else echo "Successfully filtered $dropped packets" return 0 fi } do_exit() { if [ "$DEBUG" == "yes" ] && [ "$MODE" != 'cleanuponly' ] then echo "------ DEBUG ------" echo "mount: "; mount | egrep '(cgroup2|bpf)'; echo echo "$CGRP2_TC_LEAF: "; ls -l $CGRP2_TC_LEAF; echo if [ -d "$BPF_FS_TC_SHARE" ] then echo "$BPF_FS_TC_SHARE: "; ls -l $BPF_FS_TC_SHARE; echo fi echo "Host net:" $IP netns $IP link show dev $HOST_IFC $IP -6 a show dev $HOST_IFC $TC -s qdisc show dev $HOST_IFC echo echo "$NS net:" $IP -n $NS link show dev $NS_IFC $IP -n $NS -6 link show dev $NS_IFC echo "------ DEBUG ------" echo fi if [ "$MODE" != 'nocleanup' ] then setup_net stop setup_bpf_cgrp2_array stop setup_cgrp2 stop fi } init_cgrp2_vars init_bpf_fs_vars while [[ $# -ge 1 ]] do a="$1" case $a in debug) DEBUG='yes' shift 1 ;; cleanup-only) MODE='cleanuponly' shift 1 ;; no-cleanup) MODE='nocleanup' shift 1 ;; *) echo "test_cgrp2_tc [debug] [cleanup-only | no-cleanup]" echo " debug: Print cgrp and network setup details at the end of the test" echo " cleanup-only: Try to cleanup things from last test. No test will be run" echo " no-cleanup: Run the test but don't do cleanup at the end" echo "[Note: If no arg is given, it will run the test and do cleanup at the end]" echo exit -1 ;; esac done trap do_exit 0 [ "$MODE" == 'cleanuponly' ] && exit setup_cgrp2 start || exit $? setup_net start || exit $? init_bpf_fs_vars || exit $? setup_bpf_cgrp2_array start || exit $? do_test echo bpf/do_hbm_test.sh 0000755 00000030105 14722051373 0010144 0 ustar 00 #!/bin/bash # SPDX-License-Identifier: GPL-2.0 # # Copyright (c) 2019 Facebook # # This program is free software; you can redistribute it and/or # modify it under the terms of version 2 of the GNU General Public # License as published by the Free Software Foundation. Usage() { echo "Script for testing HBM (Host Bandwidth Manager) framework." echo "It creates a cgroup to use for testing and load a BPF program to limit" echo "egress or ingress bandwidht. It then uses iperf3 or netperf to create" echo "loads. The output is the goodput in Mbps (unless -D was used)." echo "" echo "USAGE: $name [out] [-b=<prog>|--bpf=<prog>] [-c=<cc>|--cc=<cc>]" echo " [-D] [-d=<delay>|--delay=<delay>] [--debug] [-E] [--edt]" echo " [-f=<#flows>|--flows=<#flows>] [-h] [-i=<id>|--id=<id >]" echo " [-l] [-N] [--no_cn] [-p=<port>|--port=<port>] [-P]" echo " [-q=<qdisc>] [-R] [-s=<server>|--server=<server]" echo " [-S|--stats] -t=<time>|--time=<time>] [-w] [cubic|dctcp]" echo " Where:" echo " out egress (default)" echo " -b or --bpf BPF program filename to load and attach." echo " Default is hbm_out_kern.o for egress," echo " -c or -cc TCP congestion control (cubic or dctcp)" echo " --debug print BPF trace buffer" echo " -d or --delay add a delay in ms using netem" echo " -D In addition to the goodput in Mbps, it also outputs" echo " other detailed information. This information is" echo " test dependent (i.e. iperf3 or netperf)." echo " -E enable ECN (not required for dctcp)" echo " --edt use fq's Earliest Departure Time (requires fq)" echo " -f or --flows number of concurrent flows (default=1)" echo " -i or --id cgroup id (an integer, default is 1)" echo " -N use netperf instead of iperf3" echo " --no_cn Do not return CN notifications" echo " -l do not limit flows using loopback" echo " -h Help" echo " -p or --port iperf3 port (default is 5201)" echo " -P use an iperf3 instance for each flow" echo " -q use the specified qdisc" echo " -r or --rate rate in Mbps (default 1s 1Gbps)" echo " -R Use TCP_RR for netperf. 1st flow has req" echo " size of 10KB, rest of 1MB. Reply in all" echo " cases is 1 byte." echo " More detailed output for each flow can be found" echo " in the files netperf.<cg>.<flow>, where <cg> is the" echo " cgroup id as specified with the -i flag, and <flow>" echo " is the flow id starting at 1 and increasing by 1 for" echo " flow (as specified by -f)." echo " -s or --server hostname of netperf server. Used to create netperf" echo " test traffic between to hosts (default is within host)" echo " netserver must be running on the host." echo " -S or --stats whether to update hbm stats (default is yes)." echo " -t or --time duration of iperf3 in seconds (default=5)" echo " -w Work conserving flag. cgroup can increase its" echo " bandwidth beyond the rate limit specified" echo " while there is available bandwidth. Current" echo " implementation assumes there is only one NIC" echo " (eth0), but can be extended to support multiple" echo " NICs." echo " cubic or dctcp specify which TCP CC to use" echo " " exit } #set -x debug_flag=0 args="$@" name="$0" netem=0 cc=x dir="-o" dir_name="out" dur=5 flows=1 id=1 prog="" port=5201 rate=1000 multi_iperf=0 flow_cnt=1 use_netperf=0 rr=0 ecn=0 details=0 server="" qdisc="" flags="" do_stats=0 function start_hbm () { rm -f hbm.out echo "./hbm $dir -n $id -r $rate -t $dur $flags $dbg $prog" > hbm.out echo " " >> hbm.out ./hbm $dir -n $id -r $rate -t $dur $flags $dbg $prog >> hbm.out 2>&1 & echo $! } processArgs () { for i in $args ; do case $i in # Support for upcomming ingress rate limiting #in) # support for upcoming ingress rate limiting # dir="-i" # dir_name="in" # ;; out) dir="-o" dir_name="out" ;; -b=*|--bpf=*) prog="${i#*=}" ;; -c=*|--cc=*) cc="${i#*=}" ;; --no_cn) flags="$flags --no_cn" ;; --debug) flags="$flags -d" debug_flag=1 ;; -d=*|--delay=*) netem="${i#*=}" ;; -D) details=1 ;; -E) ecn=1 ;; --edt) flags="$flags --edt" qdisc="fq" ;; -f=*|--flows=*) flows="${i#*=}" ;; -i=*|--id=*) id="${i#*=}" ;; -l) flags="$flags -l" ;; -N) use_netperf=1 ;; -p=*|--port=*) port="${i#*=}" ;; -P) multi_iperf=1 ;; -q=*) qdisc="${i#*=}" ;; -r=*|--rate=*) rate="${i#*=}" ;; -R) rr=1 ;; -s=*|--server=*) server="${i#*=}" ;; -S|--stats) flags="$flags -s" do_stats=1 ;; -t=*|--time=*) dur="${i#*=}" ;; -w) flags="$flags -w" ;; cubic) cc=cubic ;; dctcp) cc=dctcp ;; *) echo "Unknown arg:$i" Usage ;; esac done } processArgs if [ $debug_flag -eq 1 ] ; then rm -f hbm_out.log fi hbm_pid=$(start_hbm) usleep 100000 host=`hostname` cg_base_dir=/sys/fs/cgroup cg_dir="$cg_base_dir/cgroup-test-work-dir/hbm$id" echo $$ >> $cg_dir/cgroup.procs ulimit -l unlimited rm -f ss.out rm -f hbm.[0-9]*.$dir_name if [ $ecn -ne 0 ] ; then sysctl -w -q -n net.ipv4.tcp_ecn=1 fi if [ $use_netperf -eq 0 ] ; then cur_cc=`sysctl -n net.ipv4.tcp_congestion_control` if [ "$cc" != "x" ] ; then sysctl -w -q -n net.ipv4.tcp_congestion_control=$cc fi fi if [ "$netem" -ne "0" ] ; then if [ "$qdisc" != "" ] ; then echo "WARNING: Ignoring -q options because -d option used" fi tc qdisc del dev lo root > /dev/null 2>&1 tc qdisc add dev lo root netem delay $netem\ms > /dev/null 2>&1 elif [ "$qdisc" != "" ] ; then tc qdisc del dev eth0 root > /dev/null 2>&1 tc qdisc add dev eth0 root $qdisc > /dev/null 2>&1 fi n=0 m=$[$dur * 5] hn="::1" if [ $use_netperf -ne 0 ] ; then if [ "$server" != "" ] ; then hn=$server fi fi ( ping6 -i 0.2 -c $m $hn > ping.out 2>&1 ) & if [ $use_netperf -ne 0 ] ; then begNetserverPid=`ps ax | grep netserver | grep --invert-match "grep" | \ awk '{ print $1 }'` if [ "$begNetserverPid" == "" ] ; then if [ "$server" == "" ] ; then ( ./netserver > /dev/null 2>&1) & usleep 100000 fi fi flow_cnt=1 if [ "$server" == "" ] ; then np_server=$host else np_server=$server fi if [ "$cc" == "x" ] ; then np_cc="" else np_cc="-K $cc,$cc" fi replySize=1 while [ $flow_cnt -le $flows ] ; do if [ $rr -ne 0 ] ; then reqSize=1M if [ $flow_cnt -eq 1 ] ; then reqSize=10K fi if [ "$dir" == "-i" ] ; then replySize=$reqSize reqSize=1 fi ( ./netperf -H $np_server -l $dur -f m -j -t TCP_RR -- -r $reqSize,$replySize $np_cc -k P50_lATENCY,P90_LATENCY,LOCAL_TRANSPORT_RETRANS,REMOTE_TRANSPORT_RETRANS,LOCAL_SEND_THROUGHPUT,LOCAL_RECV_THROUGHPUT,REQUEST_SIZE,RESPONSE_SIZE > netperf.$id.$flow_cnt ) & else if [ "$dir" == "-i" ] ; then ( ./netperf -H $np_server -l $dur -f m -j -t TCP_RR -- -r 1,10M $np_cc -k P50_LATENCY,P90_LATENCY,LOCAL_TRANSPORT_RETRANS,LOCAL_SEND_THROUGHPUT,REMOTE_TRANSPORT_RETRANS,REMOTE_SEND_THROUGHPUT,REQUEST_SIZE,RESPONSE_SIZE > netperf.$id.$flow_cnt ) & else ( ./netperf -H $np_server -l $dur -f m -j -t TCP_STREAM -- $np_cc -k P50_lATENCY,P90_LATENCY,LOCAL_TRANSPORT_RETRANS,LOCAL_SEND_THROUGHPUT,REQUEST_SIZE,RESPONSE_SIZE > netperf.$id.$flow_cnt ) & fi fi flow_cnt=$[flow_cnt+1] done # sleep for duration of test (plus some buffer) n=$[dur+2] sleep $n # force graceful termination of netperf pids=`pgrep netperf` for p in $pids ; do kill -SIGALRM $p done flow_cnt=1 rate=0 if [ $details -ne 0 ] ; then echo "" echo "Details for HBM in cgroup $id" if [ $do_stats -eq 1 ] ; then if [ -e hbm.$id.$dir_name ] ; then cat hbm.$id.$dir_name fi fi fi while [ $flow_cnt -le $flows ] ; do if [ "$dir" == "-i" ] ; then r=`cat netperf.$id.$flow_cnt | grep -o "REMOTE_SEND_THROUGHPUT=[0-9]*" | grep -o "[0-9]*"` else r=`cat netperf.$id.$flow_cnt | grep -o "LOCAL_SEND_THROUGHPUT=[0-9]*" | grep -o "[0-9]*"` fi echo "rate for flow $flow_cnt: $r" rate=$[rate+r] if [ $details -ne 0 ] ; then echo "-----" echo "Details for cgroup $id, flow $flow_cnt" cat netperf.$id.$flow_cnt fi flow_cnt=$[flow_cnt+1] done if [ $details -ne 0 ] ; then echo "" delay=`grep "avg" ping.out | grep -o "= [0-9.]*/[0-9.]*" | grep -o "[0-9.]*$"` echo "PING AVG DELAY:$delay" echo "AGGREGATE_GOODPUT:$rate" else echo $rate fi elif [ $multi_iperf -eq 0 ] ; then (iperf3 -s -p $port -1 > /dev/null 2>&1) & usleep 100000 iperf3 -c $host -p $port -i 0 -P $flows -f m -t $dur > iperf.$id rates=`grep receiver iperf.$id | grep -o "[0-9.]* Mbits" | grep -o "^[0-9]*"` rate=`echo $rates | grep -o "[0-9]*$"` if [ $details -ne 0 ] ; then echo "" echo "Details for HBM in cgroup $id" if [ $do_stats -eq 1 ] ; then if [ -e hbm.$id.$dir_name ] ; then cat hbm.$id.$dir_name fi fi delay=`grep "avg" ping.out | grep -o "= [0-9.]*/[0-9.]*" | grep -o "[0-9.]*$"` echo "PING AVG DELAY:$delay" echo "AGGREGATE_GOODPUT:$rate" else echo $rate fi else flow_cnt=1 while [ $flow_cnt -le $flows ] ; do (iperf3 -s -p $port -1 > /dev/null 2>&1) & ( iperf3 -c $host -p $port -i 0 -P 1 -f m -t $dur | grep receiver | grep -o "[0-9.]* Mbits" | grep -o "^[0-9]*" | grep -o "[0-9]*$" > iperf3.$id.$flow_cnt ) & port=$[port+1] flow_cnt=$[flow_cnt+1] done n=$[dur+1] sleep $n flow_cnt=1 rate=0 if [ $details -ne 0 ] ; then echo "" echo "Details for HBM in cgroup $id" if [ $do_stats -eq 1 ] ; then if [ -e hbm.$id.$dir_name ] ; then cat hbm.$id.$dir_name fi fi fi while [ $flow_cnt -le $flows ] ; do r=`cat iperf3.$id.$flow_cnt` # echo "rate for flow $flow_cnt: $r" if [ $details -ne 0 ] ; then echo "Rate for cgroup $id, flow $flow_cnt LOCAL_SEND_THROUGHPUT=$r" fi rate=$[rate+r] flow_cnt=$[flow_cnt+1] done if [ $details -ne 0 ] ; then delay=`grep "avg" ping.out | grep -o "= [0-9.]*/[0-9.]*" | grep -o "[0-9.]*$"` echo "PING AVG DELAY:$delay" echo "AGGREGATE_GOODPUT:$rate" else echo $rate fi fi if [ $use_netperf -eq 0 ] ; then sysctl -w -q -n net.ipv4.tcp_congestion_control=$cur_cc fi if [ $ecn -ne 0 ] ; then sysctl -w -q -n net.ipv4.tcp_ecn=0 fi if [ "$netem" -ne "0" ] ; then tc qdisc del dev lo root > /dev/null 2>&1 fi if [ "$qdisc" != "" ] ; then tc qdisc del dev eth0 root > /dev/null 2>&1 fi sleep 2 hbmPid=`ps ax | grep "hbm " | grep --invert-match "grep" | awk '{ print $1 }'` if [ "$hbmPid" == "$hbm_pid" ] ; then kill $hbm_pid fi sleep 1 # Detach any BPF programs that may have lingered ttx=`bpftool cgroup tree | grep hbm` v=2 for x in $ttx ; do if [ "${x:0:36}" == "/sys/fs/cgroup/cgroup-test-work-dir/" ] ; then cg=$x ; v=0 else if [ $v -eq 0 ] ; then id=$x ; v=1 else if [ $v -eq 1 ] ; then type=$x ; bpftool cgroup detach $cg $type id $id v=0 fi fi fi done if [ $use_netperf -ne 0 ] ; then if [ "$server" == "" ] ; then if [ "$begNetserverPid" == "" ] ; then netserverPid=`ps ax | grep netserver | grep --invert-match "grep" | awk '{ print $1 }'` if [ "$netserverPid" != "" ] ; then kill $netserverPid fi fi fi fi exit kobject/Makefile 0000644 00000000151 14722051373 0007626 0 ustar 00 # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_SAMPLE_KOBJECT) += kobject-example.o kset-example.o kfifo/Makefile 0000644 00000000214 14722051373 0007303 0 ustar 00 # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_SAMPLE_KFIFO) += bytestream-example.o dma-example.o inttype-example.o record-example.o trace_events/Makefile 0000644 00000001127 14722051373 0010673 0 ustar 00 # SPDX-License-Identifier: GPL-2.0-only # builds the trace events example kernel modules; # then to use one (as root): insmod <module_name.ko> # If you include a trace header outside of include/trace/events # then the file that does the #define CREATE_TRACE_POINTS must # have that tracer file in its main search path. This is because # define_trace.h will include it, and must be able to find it from # the include/trace directory. # # Here trace-events-sample.c does the CREATE_TRACE_POINTS. # CFLAGS_trace-events-sample.o := -I$(src) obj-$(CONFIG_SAMPLE_TRACE_EVENTS) += trace-events-sample.o binderfs/Makefile 0000644 00000000144 14722051373 0010003 0 ustar 00 # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_SAMPLE_ANDROID_BINDERFS) += binderfs_example.o qmi/Makefile 0000644 00000000137 14722051373 0006777 0 ustar 00 # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_SAMPLE_QMI_CLIENT) += qmi_sample_client.o livepatch/Makefile 0000644 00000000703 14722051373 0010167 0 ustar 00 # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_SAMPLE_LIVEPATCH) += livepatch-sample.o obj-$(CONFIG_SAMPLE_LIVEPATCH) += livepatch-shadow-mod.o obj-$(CONFIG_SAMPLE_LIVEPATCH) += livepatch-shadow-fix1.o obj-$(CONFIG_SAMPLE_LIVEPATCH) += livepatch-shadow-fix2.o obj-$(CONFIG_SAMPLE_LIVEPATCH) += livepatch-callbacks-demo.o obj-$(CONFIG_SAMPLE_LIVEPATCH) += livepatch-callbacks-mod.o obj-$(CONFIG_SAMPLE_LIVEPATCH) += livepatch-callbacks-busymod.o configfs/Makefile 0000644 00000000134 14722051373 0010004 0 ustar 00 # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_SAMPLE_CONFIGFS) += configfs_sample.o vfio-mdev/Makefile 0000644 00000000352 14722051373 0010104 0 ustar 00 # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_SAMPLE_VFIO_MDEV_MTTY) += mtty.o obj-$(CONFIG_SAMPLE_VFIO_MDEV_MDPY) += mdpy.o obj-$(CONFIG_SAMPLE_VFIO_MDEV_MDPY_FB) += mdpy-fb.o obj-$(CONFIG_SAMPLE_VFIO_MDEV_MBOCHS) += mbochs.o connector/Makefile 0000644 00000000527 14722051373 0010206 0 ustar 00 # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_SAMPLE_CONNECTOR) += cn_test.o # List of programs to build ifdef CONFIG_SAMPLE_CONNECTOR hostprogs-y := ucon endif # Tell kbuild to always build the programs always := $(hostprogs-y) HOSTCFLAGS_ucon.o += -I$(objtree)/usr/include all: modules modules clean: $(MAKE) -C ../.. M=$(CURDIR) $@ Kconfig 0000644 00000012437 14722051373 0006062 0 ustar 00 # SPDX-License-Identifier: GPL-2.0-only menuconfig SAMPLES bool "Sample kernel code" help You can build and test sample kernel code here. if SAMPLES config SAMPLE_TRACE_EVENTS tristate "Build trace_events examples -- loadable modules only" depends on EVENT_TRACING && m help This build trace event example modules. config SAMPLE_TRACE_PRINTK tristate "Build trace_printk module - tests various trace_printk formats" depends on EVENT_TRACING && m help This builds a module that calls trace_printk() and can be used to test various trace_printk() calls from a module. config SAMPLE_KOBJECT tristate "Build kobject examples" help This config option will allow you to build a number of different kobject sample modules showing how to use kobjects, ksets, and ktypes properly. If in doubt, say "N" here. config SAMPLE_KPROBES tristate "Build kprobes examples -- loadable modules only" depends on KPROBES && m help This build several kprobes example modules. config SAMPLE_KRETPROBES tristate "Build kretprobes example -- loadable modules only" default m depends on SAMPLE_KPROBES && KRETPROBES config SAMPLE_HW_BREAKPOINT tristate "Build kernel hardware breakpoint examples -- loadable module only" depends on HAVE_HW_BREAKPOINT && m help This builds kernel hardware breakpoint example modules. config SAMPLE_KFIFO tristate "Build kfifo examples -- loadable modules only" depends on m help This config option will allow you to build a number of different kfifo sample modules showing how to use the generic kfifo API. If in doubt, say "N" here. config SAMPLE_KDB tristate "Build kdb command example -- loadable modules only" depends on KGDB_KDB && m help Build an example of how to dynamically add the hello command to the kdb shell. config SAMPLE_QMI_CLIENT tristate "Build qmi client sample -- loadable modules only" depends on m depends on ARCH_QCOM depends on NET select QCOM_QMI_HELPERS help Build an QMI client sample driver, which demonstrates how to communicate with a remote QRTR service, using QMI encoded messages. config SAMPLE_RPMSG_CLIENT tristate "Build rpmsg client sample -- loadable modules only" depends on RPMSG && m help Build an rpmsg client sample driver, which demonstrates how to communicate with an AMP-configured remote processor over the rpmsg bus. config SAMPLE_LIVEPATCH tristate "Build live patching samples -- loadable modules only" depends on LIVEPATCH && m help Build sample live patch demonstrations. config SAMPLE_CONFIGFS tristate "Build configfs patching sample -- loadable modules only" depends on CONFIGFS_FS && m help Builds a sample configfs interface. config SAMPLE_CONNECTOR tristate "Build connector sample -- loadable modules only" depends on CONNECTOR && HEADERS_INSTALL && m help When enabled, this builds both a sample kernel module for the connector interface and a user space tool to communicate with it. See also Documentation/driver-api/connector.rst config SAMPLE_HIDRAW bool "hidraw sample" depends on HEADERS_INSTALL config SAMPLE_PIDFD bool "pidfd sample" depends on HEADERS_INSTALL config SAMPLE_SECCOMP bool "Build seccomp sample code" depends on SECCOMP_FILTER && HEADERS_INSTALL help Build samples of seccomp filters using various methods of BPF filter construction. config SAMPLE_VFIO_MDEV_MTTY tristate "Build VFIO mtty example mediated device sample code -- loadable modules only" depends on VFIO_MDEV_DEVICE && m help Build a virtual tty sample driver for use as a VFIO mediated device config SAMPLE_VFIO_MDEV_MDPY tristate "Build VFIO mdpy example mediated device sample code -- loadable modules only" depends on VFIO_MDEV_DEVICE && m help Build a virtual display sample driver for use as a VFIO mediated device. It is a simple framebuffer and supports the region display interface (VFIO_GFX_PLANE_TYPE_REGION). config SAMPLE_VFIO_MDEV_MDPY_FB tristate "Build VFIO mdpy example guest fbdev driver -- loadable module only" depends on FB && m select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT help Guest fbdev driver for the virtual display sample driver. config SAMPLE_VFIO_MDEV_MBOCHS tristate "Build VFIO mdpy example mediated device sample code -- loadable modules only" depends on VFIO_MDEV_DEVICE && m select DMA_SHARED_BUFFER help Build a virtual display sample driver for use as a VFIO mediated device. It supports the region display interface (VFIO_GFX_PLANE_TYPE_DMABUF). Emulate enough of qemu stdvga to make bochs-drm.ko happy. That is basically the vram memory bar and the bochs dispi interface vbe registers in the mmio register bar. Specifically it does *not* include any legacy vga stuff. Device looks a lot like "qemu -device secondary-vga". config SAMPLE_ANDROID_BINDERFS bool "Build Android binderfs example" depends on CONFIG_ANDROID_BINDERFS help Builds a sample program to illustrate the use of the Android binderfs filesystem. config SAMPLE_VFS bool "Build example programs that use new VFS system calls" depends on HEADERS_INSTALL help Build example userspace programs that use new VFS system calls such as mount API and statx(). Note that this is restricted to the x86 arch whilst it accesses system calls that aren't yet in all arches. endif # SAMPLES auxdisplay/Makefile 0000644 00000000240 14722051373 0010367 0 ustar 00 # SPDX-License-Identifier: GPL-2.0 CC := $(CROSS_COMPILE)gcc CFLAGS := -I../../usr/include PROGS := cfag12864b-example all: $(PROGS) clean: rm -fr $(PROGS) vfs/Makefile 0000644 00000000441 14722051373 0007005 0 ustar 00 # SPDX-License-Identifier: GPL-2.0-only # List of programs to build hostprogs-y := \ test-fsmount \ test-statx # Tell kbuild to always build the programs always := $(hostprogs-y) HOSTCFLAGS_test-fsmount.o += -I$(objtree)/usr/include HOSTCFLAGS_test-statx.o += -I$(objtree)/usr/include rpmsg/Makefile 0000644 00000000143 14722051373 0007336 0 ustar 00 # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_SAMPLE_RPMSG_CLIENT) += rpmsg_client_sample.o mic/mpssd/Makefile 0000644 00000001045 14722051373 0010106 0 ustar 00 # SPDX-License-Identifier: GPL-2.0 ifndef CROSS_COMPILE uname_M := $(shell uname -m 2>/dev/null || echo not) ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/) ifeq ($(ARCH),x86) PROGS := mpssd CC = $(CROSS_COMPILE)gcc CFLAGS := -I../../../usr/include -I../../../tools/include ifdef DEBUG CFLAGS += -DDEBUG=$(DEBUG) endif all: $(PROGS) mpssd: mpssd.c sysfs.c $(CC) $(CFLAGS) mpssd.c sysfs.c -o mpssd -lpthread install: install mpssd /usr/sbin/mpssd install micctrl /usr/sbin/micctrl clean: rm -fr $(PROGS) endif endif seccomp/Makefile 0000644 00000002402 14722051373 0007637 0 ustar 00 # SPDX-License-Identifier: GPL-2.0 ifndef CROSS_COMPILE hostprogs-y := bpf-fancy dropper bpf-direct user-trap HOSTCFLAGS_bpf-fancy.o += -I$(objtree)/usr/include HOSTCFLAGS_bpf-fancy.o += -idirafter $(objtree)/include HOSTCFLAGS_bpf-helper.o += -I$(objtree)/usr/include HOSTCFLAGS_bpf-helper.o += -idirafter $(objtree)/include bpf-fancy-objs := bpf-fancy.o bpf-helper.o HOSTCFLAGS_dropper.o += -I$(objtree)/usr/include HOSTCFLAGS_dropper.o += -idirafter $(objtree)/include dropper-objs := dropper.o HOSTCFLAGS_bpf-direct.o += -I$(objtree)/usr/include HOSTCFLAGS_bpf-direct.o += -idirafter $(objtree)/include bpf-direct-objs := bpf-direct.o HOSTCFLAGS_user-trap.o += -I$(objtree)/usr/include HOSTCFLAGS_user-trap.o += -idirafter $(objtree)/include user-trap-objs := user-trap.o # Try to match the kernel target. ifndef CONFIG_64BIT # s390 has -m31 flag to build 31 bit binaries ifndef CONFIG_S390 MFLAG = -m32 else MFLAG = -m31 endif HOSTCFLAGS_bpf-direct.o += $(MFLAG) HOSTCFLAGS_dropper.o += $(MFLAG) HOSTCFLAGS_bpf-helper.o += $(MFLAG) HOSTCFLAGS_bpf-fancy.o += $(MFLAG) HOSTCFLAGS_user-trap.o += $(MFLAG) HOSTLDLIBS_bpf-direct += $(MFLAG) HOSTLDLIBS_bpf-fancy += $(MFLAG) HOSTLDLIBS_dropper += $(MFLAG) HOSTLDLIBS_user-trap += $(MFLAG) endif always := $(hostprogs-y) endif watchdog/Makefile 0000644 00000000177 14722051373 0010015 0 ustar 00 # SPDX-License-Identifier: GPL-2.0 CC := $(CROSS_COMPILE)gcc PROGS := watchdog-simple all: $(PROGS) clean: rm -fr $(PROGS) uhid/Makefile 0000644 00000000334 14722051373 0007141 0 ustar 00 # SPDX-License-Identifier: GPL-2.0-only # List of programs to build hostprogs-y := uhid-example # Tell kbuild to always build the programs always := $(hostprogs-y) HOSTCFLAGS_uhid-example.o += -I$(objtree)/usr/include timers/Makefile 0000644 00000000455 14722051373 0007517 0 ustar 00 # SPDX-License-Identifier: GPL-2.0 ifndef CROSS_COMPILE uname_M := $(shell uname -m 2>/dev/null || echo not) ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/) ifeq ($(ARCH),x86) CC := $(CROSS_COMPILE)gcc PROGS := hpet_example all: $(PROGS) clean: rm -fr $(PROGS) endif endif mei/Makefile 0000644 00000000235 14722051373 0006762 0 ustar 00 # SPDX-License-Identifier: GPL-2.0 CC := $(CROSS_COMPILE)gcc CFLAGS := -I../../usr/include PROGS := mei-amt-version all: $(PROGS) clean: rm -fr $(PROGS) v4l/Makefile 0000644 00000000140 14722051373 0006710 0 ustar 00 # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_VIDEO_PCI_SKELETON) := v4l2-pci-skeleton.o kdb/Makefile 0000644 00000000120 14722051373 0006741 0 ustar 00 # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_SAMPLE_KDB) += kdb_hello.o hw_breakpoint/Makefile 0000644 00000000140 14722051373 0011037 0 ustar 00 # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_SAMPLE_HW_BREAKPOINT) += data_breakpoint.o pktgen/pktgen_sample04_many_flows.sh 0000755 00000005553 14722051373 0013642 0 ustar 00 #!/bin/bash # SPDX-License-Identifier: GPL-2.0 # # Script example for many flows testing # # Number of simultaneous flows limited by variable $FLOWS # and number of packets per flow controlled by variable $FLOWLEN # basedir=`dirname $0` source ${basedir}/functions.sh root_check_run_with_sudo "$@" # Parameter parsing via include source ${basedir}/parameters.sh # Set some default params, if they didn't get set [ -z "$DEST_IP" ] && DEST_IP="198.18.0.42" [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff" [ -z "$CLONE_SKB" ] && CLONE_SKB="0" [ -z "$COUNT" ] && COUNT="0" # Zero means indefinitely if [ -n "$DST_PORT" ]; then read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT) validate_ports $DST_MIN $DST_MAX fi # NOTICE: Script specific settings # ======= # Limiting the number of concurrent flows ($FLOWS) # and also set how many packets each flow contains ($FLOWLEN) # [ -z "$FLOWS" ] && FLOWS="8000" [ -z "$FLOWLEN" ] && FLOWLEN="10" # Base Config DELAY="0" # Zero means max speed if [[ -n "$BURST" ]]; then err 1 "Bursting not supported for this mode" fi # General cleanup everything since last run pg_ctrl "reset" # Threads are specified with parameter -t value in $THREADS for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do dev=${DEV}@${thread} # Add remove all other devices and add_device $dev to thread pg_thread $thread "rem_device_all" pg_thread $thread "add_device" $dev # Base config pg_set $dev "flag QUEUE_MAP_CPU" pg_set $dev "count $COUNT" pg_set $dev "clone_skb $CLONE_SKB" pg_set $dev "pkt_size $PKT_SIZE" pg_set $dev "delay $DELAY" pg_set $dev "flag NO_TIMESTAMP" # Single destination pg_set $dev "dst_mac $DST_MAC" pg_set $dev "dst $DEST_IP" if [ -n "$DST_PORT" ]; then # Single destination port or random port range pg_set $dev "flag UDPDST_RND" pg_set $dev "udp_dst_min $DST_MIN" pg_set $dev "udp_dst_max $DST_MAX" fi # Randomize source IP-addresses pg_set $dev "flag IPSRC_RND" pg_set $dev "src_min 198.18.0.0" pg_set $dev "src_max 198.19.255.255" # Limit number of flows (max 65535) pg_set $dev "flows $FLOWS" # # How many packets a flow will send, before flow "entry" is # re-generated/setup. pg_set $dev "flowlen $FLOWLEN" # # Flag FLOW_SEQ will cause $FLOWLEN packets from the same flow # being send back-to-back, before next flow is selected # incrementally. This helps lookup caches, and is more realistic. # pg_set $dev "flag FLOW_SEQ" done # Run if user hits control-c function print_result() { # Print results for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do dev=${DEV}@${thread} echo "Device: $dev" cat /proc/net/pktgen/$dev | grep -A2 "Result:" done } # trap keyboard interrupt (Ctrl-C) trap true SIGINT echo "Running... ctrl^C to stop" >&2 pg_ctrl "start" print_result pktgen/pktgen_sample05_flow_per_thread.sh 0000755 00000005170 14722051373 0014624 0 ustar 00 #!/bin/bash # SPDX-License-Identifier: GPL-2.0 # # Script will generate one flow per thread (-t N) # - Same destination IP # - Fake source IPs for each flow (fixed based on thread number) # # Useful for scale testing on receiver, to see whether silo'ing flows # works and scales. For optimal scalability (on receiver) each # separate-flow should not access shared variables/data. This script # helps magnify any of these scaling issues by overloading the receiver. # basedir=`dirname $0` source ${basedir}/functions.sh root_check_run_with_sudo "$@" # Parameter parsing via include source ${basedir}/parameters.sh # Set some default params, if they didn't get set [ -z "$DEST_IP" ] && DEST_IP="198.18.0.42" [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff" [ -z "$CLONE_SKB" ] && CLONE_SKB="0" [ -z "$BURST" ] && BURST=32 [ -z "$COUNT" ] && COUNT="0" # Zero means indefinitely if [ -n "$DST_PORT" ]; then read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT) validate_ports $DST_MIN $DST_MAX fi # Base Config DELAY="0" # Zero means max speed # General cleanup everything since last run pg_ctrl "reset" # Threads are specified with parameter -t value in $THREADS for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do dev=${DEV}@${thread} # Add remove all other devices and add_device $dev to thread pg_thread $thread "rem_device_all" pg_thread $thread "add_device" $dev # Base config pg_set $dev "flag QUEUE_MAP_CPU" pg_set $dev "count $COUNT" pg_set $dev "clone_skb $CLONE_SKB" pg_set $dev "pkt_size $PKT_SIZE" pg_set $dev "delay $DELAY" pg_set $dev "flag NO_TIMESTAMP" # Single destination pg_set $dev "dst_mac $DST_MAC" pg_set $dev "dst $DEST_IP" if [ -n "$DST_PORT" ]; then # Single destination port or random port range pg_set $dev "flag UDPDST_RND" pg_set $dev "udp_dst_min $DST_MIN" pg_set $dev "udp_dst_max $DST_MAX" fi # Setup source IP-addresses based on thread number pg_set $dev "src_min 198.18.$((thread+1)).1" pg_set $dev "src_max 198.18.$((thread+1)).1" # Setup burst, for easy testing -b 0 disable bursting # (internally in pktgen default and minimum burst=1) if [[ ${BURST} -ne 0 ]]; then pg_set $dev "burst $BURST" else info "$dev: Not using burst" fi done # Run if user hits control-c function print_result() { # Print results for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do dev=${DEV}@${thread} echo "Device: $dev" cat /proc/net/pktgen/$dev | grep -A2 "Result:" done } # trap keyboard interrupt (Ctrl-C) trap true SIGINT echo "Running... ctrl^C to stop" >&2 pg_ctrl "start" print_result pktgen/pktgen_sample02_multiqueue.sh 0000755 00000005052 14722051373 0013653 0 ustar 00 #!/bin/bash # SPDX-License-Identifier: GPL-2.0 # # Multiqueue: Using pktgen threads for sending on multiple CPUs # * adding devices to kernel threads # * notice the naming scheme for keeping device names unique # * nameing scheme: dev@thread_number # * flow variation via random UDP source port # basedir=`dirname $0` source ${basedir}/functions.sh root_check_run_with_sudo "$@" # # Required param: -i dev in $DEV source ${basedir}/parameters.sh [ -z "$COUNT" ] && COUNT="100000" # Zero means indefinitely # Base Config DELAY="0" # Zero means max speed [ -z "$CLONE_SKB" ] && CLONE_SKB="0" # Flow variation random source port between min and max UDP_MIN=9 UDP_MAX=109 # (example of setting default params in your script) if [ -z "$DEST_IP" ]; then [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1" fi [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff" if [ -n "$DST_PORT" ]; then read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT) validate_ports $DST_MIN $DST_MAX fi # General cleanup everything since last run pg_ctrl "reset" # Threads are specified with parameter -t value in $THREADS for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do # The device name is extended with @name, using thread number to # make then unique, but any name will do. dev=${DEV}@${thread} # Add remove all other devices and add_device $dev to thread pg_thread $thread "rem_device_all" pg_thread $thread "add_device" $dev # Notice config queue to map to cpu (mirrors smp_processor_id()) # It is beneficial to map IRQ /proc/irq/*/smp_affinity 1:1 to CPU number pg_set $dev "flag QUEUE_MAP_CPU" # Base config of dev pg_set $dev "count $COUNT" pg_set $dev "clone_skb $CLONE_SKB" pg_set $dev "pkt_size $PKT_SIZE" pg_set $dev "delay $DELAY" # Flag example disabling timestamping pg_set $dev "flag NO_TIMESTAMP" # Destination pg_set $dev "dst_mac $DST_MAC" pg_set $dev "dst$IP6 $DEST_IP" if [ -n "$DST_PORT" ]; then # Single destination port or random port range pg_set $dev "flag UDPDST_RND" pg_set $dev "udp_dst_min $DST_MIN" pg_set $dev "udp_dst_max $DST_MAX" fi # Setup random UDP port src range pg_set $dev "flag UDPSRC_RND" pg_set $dev "udp_src_min $UDP_MIN" pg_set $dev "udp_src_max $UDP_MAX" done # start_run echo "Running... ctrl^C to stop" >&2 pg_ctrl "start" echo "Done" >&2 # Print results for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do dev=${DEV}@${thread} echo "Device: $dev" cat /proc/net/pktgen/$dev | grep -A2 "Result:" done pktgen/functions.sh 0000644 00000011424 14722051373 0010406 0 ustar 00 # # Common functions used by pktgen scripts # - Depending on bash 3 (or higher) syntax # # Author: Jesper Dangaaard Brouer # License: GPL set -o errexit ## -- General shell logging cmds -- function err() { local exitcode=$1 shift echo "ERROR: $@" >&2 exit $exitcode } function warn() { echo "WARN : $@" >&2 } function info() { if [[ -n "$VERBOSE" ]]; then echo "INFO : $@" >&2 fi } ## -- Pktgen proc config commands -- ## export PROC_DIR=/proc/net/pktgen # # Three different shell functions for configuring the different # components of pktgen: # pg_ctrl(), pg_thread() and pg_set(). # # These functions correspond to pktgens different components. # * pg_ctrl() control "pgctrl" (/proc/net/pktgen/pgctrl) # * pg_thread() control the kernel threads and binding to devices # * pg_set() control setup of individual devices function pg_ctrl() { local proc_file="pgctrl" proc_cmd ${proc_file} "$@" } function pg_thread() { local thread=$1 local proc_file="kpktgend_${thread}" shift proc_cmd ${proc_file} "$@" } function pg_set() { local dev=$1 local proc_file="$dev" shift proc_cmd ${proc_file} "$@" } # More generic replacement for pgset(), that does not depend on global # variable for proc file. function proc_cmd() { local result local proc_file=$1 local status=0 # after shift, the remaining args are contained in $@ shift local proc_ctrl=${PROC_DIR}/$proc_file if [[ ! -e "$proc_ctrl" ]]; then err 3 "proc file:$proc_ctrl does not exists (dev added to thread?)" else if [[ ! -w "$proc_ctrl" ]]; then err 4 "proc file:$proc_ctrl not writable, not root?!" fi fi if [[ "$DEBUG" == "yes" ]]; then echo "cmd: $@ > $proc_ctrl" fi # Quoting of "$@" is important for space expansion echo "$@" > "$proc_ctrl" || status=$? if [[ "$proc_file" != "pgctrl" ]]; then result=$(grep "Result: OK:" $proc_ctrl) || true if [[ "$result" == "" ]]; then grep "Result:" $proc_ctrl >&2 fi fi if (( $status != 0 )); then err 5 "Write error($status) occurred cmd: \"$@ > $proc_ctrl\"" fi } # Old obsolete "pgset" function, with slightly improved err handling function pgset() { local result if [[ "$DEBUG" == "yes" ]]; then echo "cmd: $1 > $PGDEV" fi echo $1 > $PGDEV local status=$? result=`cat $PGDEV | fgrep "Result: OK:"` if [[ "$result" == "" ]]; then cat $PGDEV | fgrep Result: fi if (( $status != 0 )); then err 5 "Write error($status) occurred cmd: \"$1 > $PGDEV\"" fi } [[ $EUID -eq 0 ]] && trap 'pg_ctrl "reset"' EXIT ## -- General shell tricks -- function root_check_run_with_sudo() { # Trick so, program can be run as normal user, will just use "sudo" # call as root_check_run_as_sudo "$@" if [ "$EUID" -ne 0 ]; then if [ -x $0 ]; then # Directly executable use sudo info "Not root, running with sudo" sudo "$0" "$@" exit $? fi err 4 "cannot perform sudo run of $0" fi } # Exact input device's NUMA node info function get_iface_node() { local node=$(</sys/class/net/$1/device/numa_node) if [[ $node == -1 ]]; then echo 0 else echo $node fi } # Given an Dev/iface, get its queues' irq numbers function get_iface_irqs() { local IFACE=$1 local queues="${IFACE}-.*TxRx" irqs=$(grep "$queues" /proc/interrupts | cut -f1 -d:) [ -z "$irqs" ] && irqs=$(grep $IFACE /proc/interrupts | cut -f1 -d:) [ -z "$irqs" ] && irqs=$(for i in `ls -Ux /sys/class/net/$IFACE/device/msi_irqs` ;\ do grep "$i:.*TxRx" /proc/interrupts | grep -v fdir | cut -f 1 -d : ;\ done) [ -z "$irqs" ] && err 3 "Could not find interrupts for $IFACE" echo $irqs } # Given a NUMA node, return cpu ids belonging to it. function get_node_cpus() { local node=$1 local node_cpu_list local node_cpu_range_list=`cut -f1- -d, --output-delimiter=" " \ /sys/devices/system/node/node$node/cpulist` for cpu_range in $node_cpu_range_list do node_cpu_list="$node_cpu_list "`seq -s " " ${cpu_range//-/ }` done echo $node_cpu_list } # Given a single or range of port(s), return minimum and maximum port number. function parse_ports() { local port_str=$1 local port_list local min_port local max_port IFS="-" read -ra port_list <<< $port_str min_port=${port_list[0]} max_port=${port_list[1]:-$min_port} echo $min_port $max_port } # Given a minimum and maximum port, verify port number. function validate_ports() { local min_port=$1 local max_port=$2 # 0 < port < 65536 if [[ $min_port -gt 0 && $min_port -lt 65536 ]]; then if [[ $max_port -gt 0 && $max_port -lt 65536 ]]; then if [[ $min_port -le $max_port ]]; then return 0 fi fi fi err 5 "Invalid port(s): $min_port-$max_port" } pktgen/pktgen_sample06_numa_awared_queue_irq_affinity.sh 0000755 00000006556 14722051373 0017725 0 ustar 00 #!/bin/bash # # Multiqueue: Using pktgen threads for sending on multiple CPUs # * adding devices to kernel threads which are in the same NUMA node # * bound devices queue's irq affinity to the threads, 1:1 mapping # * notice the naming scheme for keeping device names unique # * nameing scheme: dev@thread_number # * flow variation via random UDP source port # basedir=`dirname $0` source ${basedir}/functions.sh root_check_run_with_sudo "$@" # # Required param: -i dev in $DEV source ${basedir}/parameters.sh # Base Config DELAY="0" # Zero means max speed [ -z "$COUNT" ] && COUNT="20000000" # Zero means indefinitely [ -z "$CLONE_SKB" ] && CLONE_SKB="0" # Flow variation random source port between min and max UDP_MIN=9 UDP_MAX=109 node=`get_iface_node $DEV` irq_array=(`get_iface_irqs $DEV`) cpu_array=(`get_node_cpus $node`) [ $THREADS -gt ${#irq_array[*]} -o $THREADS -gt ${#cpu_array[*]} ] && \ err 1 "Thread number $THREADS exceeds: min (${#irq_array[*]},${#cpu_array[*]})" # (example of setting default params in your script) if [ -z "$DEST_IP" ]; then [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1" fi [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff" if [ -n "$DST_PORT" ]; then read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT) validate_ports $DST_MIN $DST_MAX fi # General cleanup everything since last run pg_ctrl "reset" # Threads are specified with parameter -t value in $THREADS for ((i = 0; i < $THREADS; i++)); do # The device name is extended with @name, using thread number to # make then unique, but any name will do. # Set the queue's irq affinity to this $thread (processor) # if '-f' is designated, offset cpu id thread=${cpu_array[$((i+F_THREAD))]} dev=${DEV}@${thread} echo $thread > /proc/irq/${irq_array[$i]}/smp_affinity_list info "irq ${irq_array[$i]} is set affinity to `cat /proc/irq/${irq_array[$i]}/smp_affinity_list`" # Add remove all other devices and add_device $dev to thread pg_thread $thread "rem_device_all" pg_thread $thread "add_device" $dev # select queue and bind the queue and $dev in 1:1 relationship queue_num=$i info "queue number is $queue_num" pg_set $dev "queue_map_min $queue_num" pg_set $dev "queue_map_max $queue_num" # Notice config queue to map to cpu (mirrors smp_processor_id()) # It is beneficial to map IRQ /proc/irq/*/smp_affinity 1:1 to CPU number pg_set $dev "flag QUEUE_MAP_CPU" # Base config of dev pg_set $dev "count $COUNT" pg_set $dev "clone_skb $CLONE_SKB" pg_set $dev "pkt_size $PKT_SIZE" pg_set $dev "delay $DELAY" # Flag example disabling timestamping pg_set $dev "flag NO_TIMESTAMP" # Destination pg_set $dev "dst_mac $DST_MAC" pg_set $dev "dst$IP6 $DEST_IP" if [ -n "$DST_PORT" ]; then # Single destination port or random port range pg_set $dev "flag UDPDST_RND" pg_set $dev "udp_dst_min $DST_MIN" pg_set $dev "udp_dst_max $DST_MAX" fi # Setup random UDP port src range pg_set $dev "flag UDPSRC_RND" pg_set $dev "udp_src_min $UDP_MIN" pg_set $dev "udp_src_max $UDP_MAX" done # start_run echo "Running... ctrl^C to stop" >&2 pg_ctrl "start" echo "Done" >&2 # Print results for ((i = 0; i < $THREADS; i++)); do thread=${cpu_array[$((i+F_THREAD))]} dev=${DEV}@${thread} echo "Device: $dev" cat /proc/net/pktgen/$dev | grep -A2 "Result:" done pktgen/pktgen_bench_xmit_mode_netif_receive.sh 0000755 00000006037 14722051373 0015770 0 ustar 00 #!/bin/bash # SPDX-License-Identifier: GPL-2.0 # # Benchmark script: # - developed for benchmarking ingress qdisc path # # Script for injecting packets into RX path of the stack with pktgen # "xmit_mode netif_receive". With an invalid dst_mac this will only # measure the ingress code path as packets gets dropped in ip_rcv(). # # This script don't really need any hardware. It benchmarks software # RX path just after NIC driver level. With bursting is also # "removes" the SKB alloc/free overhead. # # Setup scenarios for measuring ingress qdisc (with invalid dst_mac): # ------------------------------------------------------------------ # (1) no ingress (uses static_key_false(&ingress_needed)) # # (2) ingress on other dev (change ingress_needed and calls # handle_ing() but exit early) # # config: tc qdisc add dev $SOMEDEV handle ffff: ingress # # (3) ingress on this dev, handle_ing() -> tc_classify() # # config: tc qdisc add dev $DEV handle ffff: ingress # # (4) ingress on this dev + drop at u32 classifier/action. # basedir=`dirname $0` source ${basedir}/functions.sh root_check_run_with_sudo "$@" # Parameter parsing via include source ${basedir}/parameters.sh # Using invalid DST_MAC will cause the packets to get dropped in # ip_rcv() which is part of the test if [ -z "$DEST_IP" ]; then [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1" fi [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff" [ -z "$BURST" ] && BURST=1024 [ -z "$COUNT" ] && COUNT="10000000" # Zero means indefinitely if [ -n "$DST_PORT" ]; then read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT) validate_ports $DST_MIN $DST_MAX fi # Base Config DELAY="0" # Zero means max speed # General cleanup everything since last run pg_ctrl "reset" # Threads are specified with parameter -t value in $THREADS for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do # The device name is extended with @name, using thread number to # make then unique, but any name will do. dev=${DEV}@${thread} # Add remove all other devices and add_device $dev to thread pg_thread $thread "rem_device_all" pg_thread $thread "add_device" $dev # Base config of dev pg_set $dev "flag QUEUE_MAP_CPU" pg_set $dev "count $COUNT" pg_set $dev "pkt_size $PKT_SIZE" pg_set $dev "delay $DELAY" pg_set $dev "flag NO_TIMESTAMP" # Destination pg_set $dev "dst_mac $DST_MAC" pg_set $dev "dst$IP6 $DEST_IP" if [ -n "$DST_PORT" ]; then # Single destination port or random port range pg_set $dev "flag UDPDST_RND" pg_set $dev "udp_dst_min $DST_MIN" pg_set $dev "udp_dst_max $DST_MAX" fi # Inject packet into RX path of stack pg_set $dev "xmit_mode netif_receive" # Burst allow us to avoid measuring SKB alloc/free overhead pg_set $dev "burst $BURST" done # start_run echo "Running... ctrl^C to stop" >&2 pg_ctrl "start" echo "Done" >&2 # Print results for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do dev=${DEV}@${thread} echo "Device: $dev" cat /proc/net/pktgen/$dev | grep -A2 "Result:" done pktgen/pktgen_sample03_burst_single_flow.sh 0000755 00000005677 14722051373 0015221 0 ustar 00 #!/bin/bash # SPDX-License-Identifier: GPL-2.0 # # Script for max single flow performance # - If correctly tuned[1], single CPU 10G wirespeed small pkts is possible[2] # # Using pktgen "burst" option (use -b $N) # - To boost max performance # - Avail since: kernel v3.18 # * commit 38b2cf2982dc73 ("net: pktgen: packet bursting via skb->xmit_more") # - This avoids writing the HW tailptr on every driver xmit # - The performance boost is impressive, see commit and blog [2] # # Notice: On purpose generates a single (UDP) flow towards target, # reason behind this is to only overload/activate a single CPU on # target host. And no randomness for pktgen also makes it faster. # # Tuning see: # [1] http://netoptimizer.blogspot.dk/2014/06/pktgen-for-network-overload-testing.html # [2] http://netoptimizer.blogspot.dk/2014/10/unlocked-10gbps-tx-wirespeed-smallest.html # basedir=`dirname $0` source ${basedir}/functions.sh root_check_run_with_sudo "$@" # Parameter parsing via include source ${basedir}/parameters.sh # Set some default params, if they didn't get set if [ -z "$DEST_IP" ]; then [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1" fi [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff" [ -z "$BURST" ] && BURST=32 [ -z "$CLONE_SKB" ] && CLONE_SKB="0" # No need for clones when bursting [ -z "$COUNT" ] && COUNT="0" # Zero means indefinitely if [ -n "$DST_PORT" ]; then read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT) validate_ports $DST_MIN $DST_MAX fi # Base Config DELAY="0" # Zero means max speed # General cleanup everything since last run pg_ctrl "reset" # Threads are specified with parameter -t value in $THREADS for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do dev=${DEV}@${thread} # Add remove all other devices and add_device $dev to thread pg_thread $thread "rem_device_all" pg_thread $thread "add_device" $dev # Base config pg_set $dev "flag QUEUE_MAP_CPU" pg_set $dev "count $COUNT" pg_set $dev "clone_skb $CLONE_SKB" pg_set $dev "pkt_size $PKT_SIZE" pg_set $dev "delay $DELAY" pg_set $dev "flag NO_TIMESTAMP" # Destination pg_set $dev "dst_mac $DST_MAC" pg_set $dev "dst$IP6 $DEST_IP" if [ -n "$DST_PORT" ]; then # Single destination port or random port range pg_set $dev "flag UDPDST_RND" pg_set $dev "udp_dst_min $DST_MIN" pg_set $dev "udp_dst_max $DST_MAX" fi # Setup burst, for easy testing -b 0 disable bursting # (internally in pktgen default and minimum burst=1) if [[ ${BURST} -ne 0 ]]; then pg_set $dev "burst $BURST" else info "$dev: Not using burst" fi done # Run if user hits control-c function control_c() { # Print results for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do dev=${DEV}@${thread} echo "Device: $dev" cat /proc/net/pktgen/$dev | grep -A2 "Result:" done } # trap keyboard interrupt (Ctrl-C) trap control_c SIGINT echo "Running... ctrl^C to stop" >&2 pg_ctrl "start" pktgen/parameters.sh 0000644 00000006134 14722051373 0010543 0 ustar 00 # # SPDX-License-Identifier: GPL-2.0 # Common parameter parsing for pktgen scripts # function usage() { echo "" echo "Usage: $0 [-vx] -i ethX" echo " -i : (\$DEV) output interface/device (required)" echo " -s : (\$PKT_SIZE) packet size" echo " -d : (\$DEST_IP) destination IP" echo " -m : (\$DST_MAC) destination MAC-addr" echo " -p : (\$DST_PORT) destination PORT range (e.g. 433-444) is also allowed" echo " -t : (\$THREADS) threads to start" echo " -f : (\$F_THREAD) index of first thread (zero indexed CPU number)" echo " -c : (\$SKB_CLONE) SKB clones send before alloc new SKB" echo " -n : (\$COUNT) num messages to send per thread, 0 means indefinitely" echo " -b : (\$BURST) HW level bursting of SKBs" echo " -v : (\$VERBOSE) verbose" echo " -x : (\$DEBUG) debug" echo " -6 : (\$IP6) IPv6" echo "" } ## --- Parse command line arguments / parameters --- ## echo "Commandline options:" while getopts "s:i:d:m:p:f:t:c:n:b:vxh6" option; do case $option in i) # interface export DEV=$OPTARG info "Output device set to: DEV=$DEV" ;; s) export PKT_SIZE=$OPTARG info "Packet size set to: PKT_SIZE=$PKT_SIZE bytes" ;; d) # destination IP export DEST_IP=$OPTARG info "Destination IP set to: DEST_IP=$DEST_IP" ;; m) # MAC export DST_MAC=$OPTARG info "Destination MAC set to: DST_MAC=$DST_MAC" ;; p) # PORT export DST_PORT=$OPTARG info "Destination PORT set to: DST_PORT=$DST_PORT" ;; f) export F_THREAD=$OPTARG info "Index of first thread (zero indexed CPU number): $F_THREAD" ;; t) export THREADS=$OPTARG info "Number of threads to start: $THREADS" ;; c) export CLONE_SKB=$OPTARG info "CLONE_SKB=$CLONE_SKB" ;; n) export COUNT=$OPTARG info "COUNT=$COUNT" ;; b) export BURST=$OPTARG info "SKB bursting: BURST=$BURST" ;; v) export VERBOSE=yes info "Verbose mode: VERBOSE=$VERBOSE" ;; x) export DEBUG=yes info "Debug mode: DEBUG=$DEBUG" ;; 6) export IP6=6 info "IP6: IP6=$IP6" ;; h|?|*) usage; err 2 "[ERROR] Unknown parameters!!!" esac done shift $(( $OPTIND - 1 )) if [ -z "$PKT_SIZE" ]; then # NIC adds 4 bytes CRC export PKT_SIZE=60 info "Default packet size set to: set to: $PKT_SIZE bytes" fi if [ -z "$F_THREAD" ]; then # First thread (F_THREAD) reference the zero indexed CPU number export F_THREAD=0 fi if [ -z "$THREADS" ]; then export THREADS=1 fi export L_THREAD=$(( THREADS + F_THREAD - 1 )) if [ -z "$DEV" ]; then usage err 2 "Please specify output device" fi if [ -z "$DST_MAC" ]; then warn "Missing destination MAC address" fi if [ -z "$DEST_IP" ]; then warn "Missing destination IP address" fi if [ ! -d /proc/net/pktgen ]; then info "Loading kernel module: pktgen" modprobe pktgen fi pktgen/pktgen_bench_xmit_mode_queue_xmit.sh 0000755 00000004346 14722051373 0015347 0 ustar 00 #!/bin/bash # SPDX-License-Identifier: GPL-2.0 # # Benchmark script: # - developed for benchmarking egress qdisc path, derived (more # like cut'n'pasted) from ingress benchmark script. # # Script for injecting packets into egress qdisc path of the stack # with pktgen "xmit_mode queue_xmit". # basedir=`dirname $0` source ${basedir}/functions.sh root_check_run_with_sudo "$@" # Parameter parsing via include source ${basedir}/parameters.sh if [ -z "$DEST_IP" ]; then [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1" fi [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff" # Burst greater than 1 are invalid for queue_xmit mode if [[ -n "$BURST" ]]; then err 1 "Bursting not supported for this mode" fi [ -z "$COUNT" ] && COUNT="10000000" # Zero means indefinitely if [ -n "$DST_PORT" ]; then read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT) validate_ports $DST_MIN $DST_MAX fi # Base Config DELAY="0" # Zero means max speed # General cleanup everything since last run pg_ctrl "reset" # Threads are specified with parameter -t value in $THREADS for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do # The device name is extended with @name, using thread number to # make then unique, but any name will do. dev=${DEV}@${thread} # Add remove all other devices and add_device $dev to thread pg_thread $thread "rem_device_all" pg_thread $thread "add_device" $dev # Base config of dev pg_set $dev "flag QUEUE_MAP_CPU" pg_set $dev "count $COUNT" pg_set $dev "pkt_size $PKT_SIZE" pg_set $dev "delay $DELAY" pg_set $dev "flag NO_TIMESTAMP" # Destination pg_set $dev "dst_mac $DST_MAC" pg_set $dev "dst$IP6 $DEST_IP" if [ -n "$DST_PORT" ]; then # Single destination port or random port range pg_set $dev "flag UDPDST_RND" pg_set $dev "udp_dst_min $DST_MIN" pg_set $dev "udp_dst_max $DST_MAX" fi # Inject packet into TX qdisc egress path of stack pg_set $dev "xmit_mode queue_xmit" done # start_run echo "Running... ctrl^C to stop" >&2 pg_ctrl "start" echo "Done" >&2 # Print results for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do dev=${DEV}@${thread} echo "Device: $dev" cat /proc/net/pktgen/$dev | grep -A2 "Result:" done pktgen/pktgen_sample01_simple.sh 0000755 00000004407 14722051373 0012747 0 ustar 00 #!/bin/bash # SPDX-License-Identifier: GPL-2.0 # # Simple example: # * pktgen sending with single thread and single interface # * flow variation via random UDP source port # basedir=`dirname $0` source ${basedir}/functions.sh root_check_run_with_sudo "$@" # Parameter parsing via include # - go look in parameters.sh to see which setting are avail # - required param is the interface "-i" stored in $DEV source ${basedir}/parameters.sh # # Set some default params, if they didn't get set if [ -z "$DEST_IP" ]; then [ -z "$IP6" ] && DEST_IP="198.18.0.42" || DEST_IP="FD00::1" fi [ -z "$CLONE_SKB" ] && CLONE_SKB="0" # Example enforce param "-m" for dst_mac [ -z "$DST_MAC" ] && usage && err 2 "Must specify -m dst_mac" [ -z "$COUNT" ] && COUNT="100000" # Zero means indefinitely if [ -n "$DST_PORT" ]; then read -r DST_MIN DST_MAX <<< $(parse_ports $DST_PORT) validate_ports $DST_MIN $DST_MAX fi # Base Config DELAY="0" # Zero means max speed # Flow variation random source port between min and max UDP_MIN=9 UDP_MAX=109 # General cleanup everything since last run # (especially important if other threads were configured by other scripts) pg_ctrl "reset" # Add remove all other devices and add_device $DEV to thread 0 thread=0 pg_thread $thread "rem_device_all" pg_thread $thread "add_device" $DEV # How many packets to send (zero means indefinitely) pg_set $DEV "count $COUNT" # Reduce alloc cost by sending same SKB many times # - this obviously affects the randomness within the packet pg_set $DEV "clone_skb $CLONE_SKB" # Set packet size pg_set $DEV "pkt_size $PKT_SIZE" # Delay between packets (zero means max speed) pg_set $DEV "delay $DELAY" # Flag example disabling timestamping pg_set $DEV "flag NO_TIMESTAMP" # Destination pg_set $DEV "dst_mac $DST_MAC" pg_set $DEV "dst$IP6 $DEST_IP" if [ -n "$DST_PORT" ]; then # Single destination port or random port range pg_set $DEV "flag UDPDST_RND" pg_set $DEV "udp_dst_min $DST_MIN" pg_set $DEV "udp_dst_max $DST_MAX" fi # Setup random UDP port src range pg_set $DEV "flag UDPSRC_RND" pg_set $DEV "udp_src_min $UDP_MIN" pg_set $DEV "udp_src_max $UDP_MAX" # start_run echo "Running... ctrl^C to stop" >&2 pg_ctrl "start" echo "Done" >&2 # Print results echo "Result device: $DEV" cat /proc/net/pktgen/$DEV trace_printk/Makefile 0000644 00000000415 14722051373 0010675 0 ustar 00 # SPDX-License-Identifier: GPL-2.0-only # builds a module that calls various trace_printk routines # then to use one (as root): insmod <module_name.ko> # This module can also be used to test the trace_printk code. obj-$(CONFIG_SAMPLE_TRACE_PRINTK) += trace-printk.o Makefile 0000644 00000001560 14722051373 0006212 0 ustar 00 # SPDX-License-Identifier: GPL-2.0 # Makefile for Linux samples code obj-$(CONFIG_SAMPLE_ANDROID_BINDERFS) += binderfs/ obj-$(CONFIG_SAMPLE_CONFIGFS) += configfs/ obj-$(CONFIG_SAMPLE_CONNECTOR) += connector/ subdir-$(CONFIG_SAMPLE_HIDRAW) += hidraw obj-$(CONFIG_SAMPLE_HW_BREAKPOINT) += hw_breakpoint/ obj-$(CONFIG_SAMPLE_KDB) += kdb/ obj-$(CONFIG_SAMPLE_KFIFO) += kfifo/ obj-$(CONFIG_SAMPLE_KOBJECT) += kobject/ obj-$(CONFIG_SAMPLE_KPROBES) += kprobes/ obj-$(CONFIG_SAMPLE_LIVEPATCH) += livepatch/ subdir-$(CONFIG_SAMPLE_PIDFD) += pidfd obj-$(CONFIG_SAMPLE_QMI_CLIENT) += qmi/ obj-$(CONFIG_SAMPLE_RPMSG_CLIENT) += rpmsg/ subdir-$(CONFIG_SAMPLE_SECCOMP) += seccomp obj-$(CONFIG_SAMPLE_TRACE_EVENTS) += trace_events/ obj-$(CONFIG_SAMPLE_TRACE_PRINTK) += trace_printk/ obj-$(CONFIG_VIDEO_PCI_SKELETON) += v4l/ obj-y += vfio-mdev/ subdir-$(CONFIG_SAMPLE_VFS) += vfs pidfd/Makefile 0000644 00000000247 14722051373 0007301 0 ustar 00 # SPDX-License-Identifier: GPL-2.0 hostprogs-y := pidfd-metadata always := $(hostprogs-y) HOSTCFLAGS_pidfd-metadata.o += -I$(objtree)/usr/include all: pidfd-metadata kprobes/Makefile 0000644 00000000364 14722051373 0007660 0 ustar 00 # SPDX-License-Identifier: GPL-2.0-only # builds the kprobes example kernel modules; # then to use one (as root): insmod <module_name.ko> obj-$(CONFIG_SAMPLE_KPROBES) += kprobe_example.o obj-$(CONFIG_SAMPLE_KRETPROBES) += kretprobe_example.o hidraw/Makefile 0000644 00000000347 14722051373 0007472 0 ustar 00 # SPDX-License-Identifier: GPL-2.0 # List of programs to build hostprogs-y := hid-example # Tell kbuild to always build the programs always := $(hostprogs-y) HOSTCFLAGS_hid-example.o += -I$(objtree)/usr/include all: hid-example
| ver. 1.4 |
Github
|
.
| PHP 7.4.3-4ubuntu2.24 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка