From 9a4692bc1e6932e14cb939ba8db1035057c919b5 Mon Sep 17 00:00:00 2001 From: wenzhiwei11 Date: Wed, 21 Jun 2023 11:20:11 +0800 Subject: [PATCH] add tcpconnect bpf map --- observation/src/tcpconnect/tcpconnect.bpf.c | 43 +++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 observation/src/tcpconnect/tcpconnect.bpf.c diff --git a/observation/src/tcpconnect/tcpconnect.bpf.c b/observation/src/tcpconnect/tcpconnect.bpf.c new file mode 100644 index 00000000..ba7c3a23 --- /dev/null +++ b/observation/src/tcpconnect/tcpconnect.bpf.c @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "vmlinux.h" +#include +#include +#include +#include + +#include "tcpconnect.h" +#include "compat.bpf.h" +#include "maps.bpf.h" + +const volatile int filter_ports[MAX_PORTS] = {}; +const volatile int filter_ports_len = 0; +const volatile uid_t filter_uid = -1; +const volatile pid_t filter_pid = 0; +const volatile bool do_count = false; +const volatile bool source_port = false; + +/* Define here, because there are conflicts with include files */ +#define AF_INET 2 +#define AF_INET6 10 + +struct { + __uint(type, BPF_MAP_TYPE_HASH); + __uint(max_entries, MAX_ENTRIES); + __type(key, u32); + __type(value, struct sock *); +} sockets SEC(".maps"); + +struct { + __uint(type, BPF_MAP_TYPE_HASH); + __uint(max_entries, MAX_ENTRIES); + __type(key, struct ipv4_flow_key); + __type(value, u64); +} ipv4_count SEC(".maps"); + +struct { + __uint(type, BPF_MAP_TYPE_HASH); + __uint(max_entries, MAX_ENTRIES); + __type(key, struct ipv6_flow_key); + __type(value, u64); +} ipv6_count SEC(".maps"); + -- Gitee