-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
42 lines (30 loc) · 850 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
BINDIR=bin
EXEC=main
IFACE ?= eth0
BPFDIR=ebpf
BPFBIN=${BINDIR}/bpf
BPFEXEC=drop
.PHONY: all
.default: ${EXEC}
${EXEC}: ${BINDIR} drop
go build -o ${BINDIR}/${EXEC} ${EXEC}.go
drop: ${BPFBIN}
clang -O2 -g -Wall -emit-llvm -c ${BPFDIR}/drop.c -o ${BPFBIN}/drop.bc
llc -march=bpf -mcpu=probe -filetype=obj ${BPFBIN}/drop.bc -o ${BPFBIN}/drop.o
drop-install: drop
tc qdisc add dev ${IFACE} clsact
tc filter add dev ${IFACE} ingress bpf da obj ${BPFBIN}/drop.o sec classifier_ingress_drop
tc filter add dev ${IFACE} egress bpf da obj ${BPFBIN}/drop.o sec classifier_egress_drop
drop-uninstall:
tc qdisc del dev ${IFACE} clsact
show:
tc filter show dev ${IFACE} ingress
tc filter show dev ${IFACE} egress
${BINDIR}:
mkdir -p ${BINDIR}
${BPFBIN}:
mkdir -p ${BPFBIN}
clean:
rm -r ${BINDIR}
clean-maps:
rm -r /sys/fs/bpf/tc/globals/*