Skip to content

Commit 8dc8055

Browse files
DanielTimLeeAlexei Starovoitov
authored andcommitted
samples/bpf: refactor syscall tracing programs using BPF_KSYSCALL macro
This commit refactors the syscall tracing programs by adopting the BPF_KSYSCALL macro. This change aims to enhance the clarity and simplicity of the BPF programs by reducing the complexity of argument parsing from pt_regs. Signed-off-by: Daniel T. Lee <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent d93a7cf commit 8dc8055

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

samples/bpf/test_map_in_map.bpf.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,19 +103,15 @@ static __always_inline int do_inline_hash_lookup(void *inner_map, u32 port)
103103
return result ? *result : -ENOENT;
104104
}
105105

106-
SEC("kprobe/__sys_connect")
107-
int trace_sys_connect(struct pt_regs *ctx)
106+
SEC("ksyscall/connect")
107+
int BPF_KSYSCALL(trace_sys_connect, unsigned int fd, struct sockaddr_in6 *in6, int addrlen)
108108
{
109-
struct sockaddr_in6 *in6;
110109
u16 test_case, port, dst6[8];
111-
int addrlen, ret, inline_ret, ret_key = 0;
110+
int ret, inline_ret, ret_key = 0;
112111
u32 port_key;
113112
void *outer_map, *inner_map;
114113
bool inline_hash = false;
115114

116-
in6 = (struct sockaddr_in6 *)PT_REGS_PARM2_CORE(ctx);
117-
addrlen = (int)PT_REGS_PARM3_CORE(ctx);
118-
119115
if (addrlen != sizeof(*in6))
120116
return 0;
121117

0 commit comments

Comments
 (0)