From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jakub Kicinski Subject: Re: [PATCH bpf-next] tools: bpftool: add map create command Date: Mon, 15 Oct 2018 09:49:08 -0700 Message-ID: <20181015094908.2993a27b@cakuba.netronome.com> References: <20181012180614.22611-1-jakub.kicinski@netronome.com> <20181013061657.a5jxlxr7h3nvdass@ast-mbp.dhcp.thefacebook.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: daniel@iogearbox.net, netdev@vger.kernel.org, oss-drivers@netronome.com To: Alexei Starovoitov Return-path: Received: from mail-qt1-f194.google.com ([209.85.160.194]:42858 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726638AbeJPAfO (ORCPT ); Mon, 15 Oct 2018 20:35:14 -0400 Received: by mail-qt1-f194.google.com with SMTP id j46-v6so22224685qtc.9 for ; Mon, 15 Oct 2018 09:49:13 -0700 (PDT) In-Reply-To: <20181013061657.a5jxlxr7h3nvdass@ast-mbp.dhcp.thefacebook.com> Sender: netdev-owner@vger.kernel.org List-ID: On Fri, 12 Oct 2018 23:16:59 -0700, Alexei Starovoitov wrote: > On Fri, Oct 12, 2018 at 11:06:14AM -0700, Jakub Kicinski wrote: > > Add a way of creating maps from user space. The command takes > > as parameters most of the attributes of the map creation system > > call command. After map is created its pinned to bpffs. This makes > > it possible to easily and dynamically (without rebuilding programs) > > test various corner cases related to map creation. > > > > Map type names are taken from bpftool's array used for printing. > > In general these days we try to make use of libbpf type names, but > > there are no map type names in libbpf as of today. > > > > As with most features I add the motivation is testing (offloads) :) > > > > Signed-off-by: Jakub Kicinski > > Reviewed-by: Quentin Monnet > ... > > fprintf(stderr, > > "Usage: %s %s { show | list } [MAP]\n" > > + " %s %s create FILE type TYPE key KEY_SIZE value VALUE_SIZE \\\n" > > + " entries MAX_ENTRIES [name NAME] [flags FLAGS] \\\n" > > + " [dev NAME]\n" > > I suspect as soon as bpftool has an ability to create standalone maps > some folks will start relying on such interface. That'd be cool, do you see any real life use cases where its useful outside of corner case testing? > Therefore I'd like to request to make 'name' argument to be mandatory. Will do in v2! > I think in the future we will require BTF to be mandatory too. > We need to move towards more transparent and debuggable infra. > Do you think requiring json description of key/value would be managable to implement? > Then bpftool could convert it to BTF and the map full be fully defined. > I certainly understand that bpf prog can disregard the key/value layout today, > but we will make verifier to enforce that in the future too. I was hoping that we can leave BTF support as a future extension, and then once we have the option for the verifier to enforce BTF (a sysctl?) the bpftool map create without a BTF will get rejected as one would expect. IOW it's fine not to make BTF required at bpftool level and leave it to system configuration. I'd love to implement the BTF support right away, but I'm not sure I can afford that right now time-wise. The whole map create command is pretty trivial, but for BTF we don't even have a way of dumping it AFAICT. We can pretty print values, but what is the format in which to express the BTF itself? We could do JSON, do we use an external library? Should we have a separate BTF command for that?