Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965154AbaGEV7L (ORCPT ); Sat, 5 Jul 2014 17:59:11 -0400 Received: from mail-we0-f172.google.com ([74.125.82.172]:47975 "EHLO mail-we0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753401AbaGEV7I convert rfc822-to-8bit (ORCPT ); Sat, 5 Jul 2014 17:59:08 -0400 MIME-Version: 1.0 In-Reply-To: References: <1403913966-4927-1-git-send-email-ast@plumgrid.com> <1403913966-4927-4-git-send-email-ast@plumgrid.com> Date: Sat, 5 Jul 2014 14:59:07 -0700 Message-ID: Subject: Re: [PATCH RFC net-next 03/14] bpf: introduce syscall(BPF, ...) and BPF maps From: Alexei Starovoitov To: Andy Lutomirski Cc: "David S. Miller" , Ingo Molnar , Linus Torvalds , Steven Rostedt , Daniel Borkmann , Chema Gonzalez , Eric Dumazet , Peter Zijlstra , Arnaldo Carvalho de Melo , Jiri Olsa , Thomas Gleixner , "H. Peter Anvin" , Andrew Morton , Kees Cook , Linux API , Network Development , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 4, 2014 at 8:17 AM, Andy Lutomirski wrote: > On Wed, Jul 2, 2014 at 7:29 PM, Alexei Starovoitov wrote: >> >> 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/