代码拉取完成,页面将自动刷新
ROOT ?= $(abspath ../)
bpf_progs := progs/kprobe
progs := nettrace
utils := $(ROOT)/utils
prog-nettrace-origin = \
$(utils)/parse_sym.c $(utils)/net_utils.c \
$(utils)/arg_parse.c $(utils)/sys_utils.c \
$(utils)/bpf_utils.c \
trace.c trace_probe.c output.c \
analysis.c trace_group.c \
dropreason.c rstreason.c
prog-nettrace = $(prog-nettrace-origin) nettrace.c
ifdef COMPAT
NO_GLOBAL_DATA := 1
NO_BTF := 1
INLINE := 1
endif
BPF_EXTRA_DEP := kheaders.h progs/core.h
include ../common.mk
cmd_kversion := awk -F '=' 'NR>10{exit;} \
$$1~/^VERSION/{ \
sub(/ /, "", $$2); a=$$2; \
} \
$$1~/^PATCHLEVEL/{ \
sub(/ /, "", $$2); b=$$2 \
} \
$$1~/^SUBLEVEL/{ \
sub(/ /, "", $$2); c=$$2 \
} \
END{printf "%s.%s.%s\n", a, b, c}' \
$(HEADERS)/Makefile
str_count = $(shell grep -c $2 $(HEADERS)/$1 2>/dev/null)
struct_field = $(shell awk 'BEGIN{start=0}/struct $2 {/{start=1} \
/$3/{if (start==1) print 1} \
/}/{start=0}' $(HEADERS)/$1 2>/dev/null)
ifdef NO_BTF
ifeq ($(call str_count,include/uapi/linux/bpf.h,BPF_PROG_TYPE_TRACEPOINT),0)
$(error BPF_PROG_TYPE_TRACEPOINT not supported by your kernel!)
endif
ifneq ($(call str_count,include/uapi/linux/bpf.h,get_stackid),0)
CFLAGS += -D__F_STACK_TRACE
endif
ifneq ($(call str_count,include/net/sock.h,sk_protocol.*8),0)
BPF_CFLAGS += -D__F_SK_PRPTOCOL_LEGACY
endif
ifeq ($(call str_count,include/net/sock.h,__sk_flags_offset),0)
BPF_CFLAGS += -D__F_NO_SK_FLAGS_OFFSET
endif
ifeq ($(call str_count,include/linux/netfilter.h,nf_hook_entries),0)
BPF_CFLAGS += -D__F_NO_NF_HOOK_ENTRIES
endif
ifeq ($(call str_count,include/uapi/linux/bpf.h,bpf_probe_read_str),0)
BPF_CFLAGS += -D__F_NO_PROBE_READ_STR
endif
ifeq ($(call struct_field,include/net/netfilter/nf_tables.h,nft_chain,\*name),)
CFLAGS += -D__F_NFT_NAME_ARRAY
endif
__KERN_VER := $(shell $(cmd_kversion))
CFLAGS += -D__KERN_VER=$(__KERN_VER)
CFLAGS += -D__KERN_MAJOR=$(shell echo $(__KERN_VER) | cut -c 1)
else
CFLAGS += -D__F_STACK_TRACE
endif
progs/kprobe_trace.h:
python3 gen_trace.py probe > progs/kprobe_trace.h
trace_group.c: trace.yaml
python3 gen_trace.py > trace_group.c
progs/*.c: progs/kprobe_trace.h
@:
nettrace.c: $(prog-nettrace-origin)
all: $(progs)
install: all
@mkdir -p ${PREFIX}/usr/bin/
@cp nettrace ${PREFIX}/usr/bin/
pack: all
@cp nettrace ${PREFIX}/
clean:
rm -rf $(progs) trace_group.c progs/kprobe_trace.h \
$(bpf_progs) progs/*.o progs/*.skel.h \
kheaders.h
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。