2023-01-23 18:54:21 +07:00
|
|
|
#!/bin/bash
|
2023-01-30 14:50:55 +07:00
|
|
|
lan=docker0
|
2024-10-30 00:06:13 +07:00
|
|
|
wan=enp5s0
|
2023-01-23 18:54:21 +07:00
|
|
|
|
2023-01-30 14:50:55 +07:00
|
|
|
sudo tc qdisc add dev $lan clsact > /dev/null 2>&1
|
2023-02-07 20:11:12 +07:00
|
|
|
sudo tc qdisc add dev $wan clsact > /dev/null 2>&1
|
2023-01-23 18:54:21 +07:00
|
|
|
|
|
|
|
set -ex
|
|
|
|
|
2023-01-27 01:10:27 +07:00
|
|
|
sudo rm -rf /sys/fs/bpf/tc/globals/*
|
|
|
|
|
2023-06-27 09:04:07 +07:00
|
|
|
# clang -fno-stack-protector -O2 -g -emit-llvm -c ../../control/kern/tproxy.c -o - | llc -march=bpf -mcpu=v3 -mattr=+alu32 -filetype=obj -o foo.o
|
2024-10-30 00:06:13 +07:00
|
|
|
clang -O2 -g -Wall -c ../../control/kern/tproxy.c -target bpf -D__TARGET_ARCH_x86 -o foo.o
|
2023-01-30 14:50:55 +07:00
|
|
|
sudo tc filter del dev $lan ingress
|
|
|
|
sudo tc filter del dev $lan egress
|
2023-02-07 20:11:12 +07:00
|
|
|
sudo tc filter del dev $wan ingress
|
|
|
|
sudo tc filter del dev $wan egress
|
|
|
|
|
2023-01-30 22:21:00 +07:00
|
|
|
sudo tc filter add dev $lan ingress bpf direct-action obj foo.o sec tc/ingress
|
2023-02-12 20:50:15 +07:00
|
|
|
sudo tc filter add dev $lan egress bpf direct-action obj foo.o sec tc/egress
|
2023-02-13 02:41:59 +07:00
|
|
|
sudo tc filter add dev $wan ingress bpf direct-action obj foo.o sec tc/wan_ingress
|
|
|
|
sudo tc filter add dev $wan egress bpf direct-action obj foo.o sec tc/wan_egress
|
2023-02-11 12:34:12 +07:00
|
|
|
|
|
|
|
sudo tc filter del dev $lan ingress
|
|
|
|
sudo tc filter del dev $lan egress
|
|
|
|
sudo tc filter del dev $wan ingress
|
|
|
|
sudo tc filter del dev $wan egress
|
2023-01-23 18:54:21 +07:00
|
|
|
|
2023-06-27 09:04:07 +07:00
|
|
|
exit 0
|