1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2022 Google */
4 #include <bpf/bpf_helpers.h>
5 #include <bpf/bpf_tracing.h>
7 char _license[] SEC("license") = "GPL";
8 int terminate_early = 0;
9 u64 terminal_cgroup = 0;
11 static inline u64 cgroup_id(struct cgroup *cgrp)
17 int cgroup_id_printer(struct bpf_iter__cgroup *ctx)
19 struct seq_file *seq = ctx->meta->seq;
20 struct cgroup *cgrp = ctx->cgroup;
24 BPF_SEQ_PRINTF(seq, "epilogue\n");
29 if (ctx->meta->seq_num == 0)
30 BPF_SEQ_PRINTF(seq, "prologue\n");
32 BPF_SEQ_PRINTF(seq, "%8llu\n", cgroup_id(cgrp));
34 if (terminal_cgroup == cgroup_id(cgrp))
37 return terminate_early ? 1 : 0;