xref: /OK3568_Linux_fs/kernel/samples/bpf/run_cookie_uid_helper_example.sh (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun#!/bin/bash
2*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0
3*4882a593Smuzhiyunlocal_dir="$(pwd)"
4*4882a593Smuzhiyunroot_dir=$local_dir/../..
5*4882a593Smuzhiyunmnt_dir=$(mktemp -d --tmp)
6*4882a593Smuzhiyun
7*4882a593Smuzhiyunon_exit() {
8*4882a593Smuzhiyun	iptables -D OUTPUT -m bpf --object-pinned ${mnt_dir}/bpf_prog -j ACCEPT
9*4882a593Smuzhiyun	umount ${mnt_dir}
10*4882a593Smuzhiyun	rm -r ${mnt_dir}
11*4882a593Smuzhiyun}
12*4882a593Smuzhiyun
13*4882a593Smuzhiyuntrap on_exit EXIT
14*4882a593Smuzhiyunmount -t bpf bpf ${mnt_dir}
15*4882a593Smuzhiyun./per_socket_stats_example ${mnt_dir}/bpf_prog $1
16