Skip to content

Commit faf975c

Browse files
Merge pull request #26593 from Luap99/ebpf
hack/podman_cleanup_tracer.bt: fixes to make it work on newer versions
2 parents a479783 + b59648a commit faf975c

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

hack/podman_cleanup_tracer.bt

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ BEGIN {
2626
// netavark and aardvark-dns as they have podman in the path as well but this is
2727
// good so we can see any errors there as well.
2828
tracepoint:syscalls:sys_enter_exec*
29-
/ strcontains(str(args.argv[0]),"podman") || strcontains(str(args.argv[0]), "conmon") /
29+
/ strcontains(str(args.argv[0], 128), "podman") || strcontains(str(args.argv[0], 128), "conmon") /
3030
{
3131

3232
// create entry in pid map so we can check the pid later
@@ -36,7 +36,7 @@ tracepoint:syscalls:sys_enter_exec*
3636
// I tried matching argv but there seems to be no way to iterate over it.
3737
// In practise parent name conmon and argv0 podman should contain all the
3838
// cleanup processes we care about.
39-
if (comm == "conmon" && strcontains(str(args.argv[0]), "podman")) {
39+
if (comm == "conmon" && strcontains(str(args.argv[0], 128), "podman")) {
4040
@cleanupPids[pid] = 1;
4141
}
4242

@@ -89,7 +89,9 @@ tracepoint:sched:sched_process_exit
8989

9090
// process is done remove pid from map
9191
delete(@pids[pid]);
92-
delete(@cleanupPids[pid]);
92+
if (@cleanupPids[pid]) {
93+
delete(@cleanupPids[pid]);
94+
}
9395
}
9496

9597
// Trace all kill calls that target our pids.
@@ -133,19 +135,5 @@ tracepoint:syscalls:sys_enter_write
133135
comm
134136
);
135137

136-
// String size limit is is 64 by default, this includes the 0 byte and when we
137-
// hit the string limit it also adds "..." when using 63 so we use 63 as len here.
138-
// While upstream fixed these low string limits (https://github.com/bpftrace/bpftrace/issues/305)
139-
// it is not yet in older distro version we use so we cannot use that yet.
140-
// Thus manually print several times.
141-
$len = 62;
142-
$offset = 62;
143-
printf("%s", str(args.buf, $len));
144-
145-
unroll(10) {
146-
if ((int64)args.count > $offset ) {
147-
printf("%s", str(args.buf + $offset, $len));
148-
}
149-
$offset += $len
150-
}
138+
printf("%s", str(args.buf, args.count));
151139
}

0 commit comments

Comments
 (0)