-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libbpf-tools/profile: Add support for PID-namespacing #5152
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1248,6 +1248,28 @@ bool probe_ringbuf() | |||||
return true; | ||||||
} | ||||||
|
||||||
bool probe_bpf_ns_current_pid_tgid(void) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would first add a commit introducing this helper, then using it in another commit in profile.c. |
||||||
{ | ||||||
int fd, insn_cnt; | ||||||
struct bpf_insn insns[] = { | ||||||
{ .code = BPF_ALU64 | BPF_MOV | BPF_X, .dst_reg = 3, .src_reg = BPF_REG_10 }, | ||||||
{ .code = BPF_ALU64 | BPF_ADD | BPF_K, .dst_reg = 3, .imm = -8 }, | ||||||
{ .code = BPF_ALU64 | BPF_MOV | BPF_K, .dst_reg = 1, .imm = 0 }, | ||||||
{ .code = BPF_ALU64 | BPF_MOV | BPF_K, .dst_reg = 2, .imm = 0 }, | ||||||
{ .code = BPF_ALU64 | BPF_MOV | BPF_K, .dst_reg = 4, .imm = 8 }, | ||||||
{ .code = BPF_JMP | BPF_CALL, .imm = BPF_FUNC_get_ns_current_pid_tgid }, | ||||||
{ .code = BPF_JMP | BPF_EXIT }, | ||||||
}; | ||||||
|
||||||
insn_cnt = sizeof(insns) / sizeof(struct bpf_insn); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This way, you do not have problem if one day we need to change the type. |
||||||
|
||||||
fd = bpf_prog_load(BPF_PROG_TYPE_KPROBE, NULL, "GPL", insns, insn_cnt, NULL); | ||||||
if (fd >= 0) | ||||||
close(fd); | ||||||
|
||||||
return fd >= 0; | ||||||
} | ||||||
|
||||||
int split_convert(char *s, const char* delim, void *elems, size_t elems_size, | ||||||
size_t elem_size, convert_fn_t convert) | ||||||
{ | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
ns
for sizeof instead of the type name?