]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: introduce current->pid, tgid, uid, gid, comm accessors
authorAlexei Starovoitov <ast@plumgrid.com>
Sat, 13 Jun 2015 02:39:12 +0000 (19:39 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 15 Jun 2015 22:53:50 +0000 (15:53 -0700)
commitc704bb1b4373d1d050d9c057253da913df14c906
treee00f1b0bba1c217afbcf4dda00ef950afdfcafbc
parent92f07cec6c48be9ec498d48aedf5837e9f8ddee2
bpf: introduce current->pid, tgid, uid, gid, comm accessors

eBPF programs attached to kprobes need to filter based on
current->pid, uid and other fields, so introduce helper functions:

u64 bpf_get_current_pid_tgid(void)
Return: current->tgid << 32 | current->pid

u64 bpf_get_current_uid_gid(void)
Return: current_gid << 32 | current_uid

bpf_get_current_comm(char *buf, int size_of_buf)
stores current->comm into buf

They can be used from the programs attached to TC as well to classify packets
based on current task fields.

Update tracex2 example to print histogram of write syscalls for each process
instead of aggregated for all.

Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/bpf.h
include/uapi/linux/bpf.h
kernel/bpf/core.c
kernel/bpf/helpers.c
kernel/trace/bpf_trace.c
net/core/filter.c
samples/bpf/bpf_helpers.h
samples/bpf/tracex2_kern.c
samples/bpf/tracex2_user.c