Re: [PATCH RFC net-next 03/14] bpf: introduce syscall(BPF, ...) and BPF maps
From: Alexei Starovoitov <hidden>
Date: 2014-07-05 21:59:11
Also in:
lkml, netdev
On Fri, Jul 4, 2014 at 8:17 AM, Andy Lutomirski [off-list ref] wrote:
On Wed, Jul 2, 2014 at 7:29 PM, Alexei Starovoitov [off-list ref] wrote:quoted
non-root API: ufd = bpf_create_map(local_map_id,… ) bpf_map_update/delete/lookup_elem(ufd,…) ufd = bpf_prog_load(insns) close(ufd) root only API: global_id = bpf_get_id(ufd) // returns either map or prog global id bpf_map_delete(global_map_id) bpf_prog_unload(global_prog_id) Details: ufd = bpf_create_map(local_map_id, ...); local_map_id - process local map_id (this id is used to access maps from eBPF program loaded by this process) ufd - process local file descriptor (used to update/lookup maps from this process) global_map_id = bpf_get_id(ufd) this is root only call to get global_ids and pass them to global events like tracing. global ids will only be seen by root. There is no way for root or non-root to influence id ranges. I think it will be cleaner once I finish fd conversion as a patch.OK FWIW, per-process local id maps sound almost equivalent to relocations -- the latter could be as simple as an extra nlattr giving a list of pairs of (per-eBPF-program id, fd).
I thought about array of such pairs as well, but it felt cleaner to remember the (per-eBPF-program id, fd) pair in a kernel, instead of asking user space to keep track of them. Either way I think it's minor. I'll implement both and see which way is cleaner. So far I did 3-way enum split in verifier and addressed Namhyung's and Chema's comments. Updated in the same place: git://git.kernel.org/pub/scm/linux/kernel/git/ast/bpf master I'll be traveling next week. Once I'm done with fd-style interface, I'll post a v2. Thanks