[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAEf4BzaZvVCfk3Enhak4C4LFvHSBCPCkZNUUBtrOp-NnGSAj0A@mail.gmail.com>
Date: Tue, 28 Apr 2020 11:35:59 -0700
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Alexei Starovoitov <alexei.starovoitov@...il.com>
Cc: Andrii Nakryiko <andriin@...com>, bpf <bpf@...r.kernel.org>,
Networking <netdev@...r.kernel.org>,
Alexei Starovoitov <ast@...com>,
Daniel Borkmann <daniel@...earbox.net>,
Toke Høiland-Jørgensen <toke@...hat.com>,
Kernel Team <kernel-team@...com>
Subject: Re: [PATCH v2 bpf-next 3/3] libbpf: add BTF-defined map-in-map support
On Tue, Apr 28, 2020 at 11:03 AM Alexei Starovoitov
<alexei.starovoitov@...il.com> wrote:
>
> On Mon, Apr 27, 2020 at 11:41:39PM -0700, Andrii Nakryiko wrote:
> > diff --git a/tools/lib/bpf/bpf_helpers.h b/tools/lib/bpf/bpf_helpers.h
> > index 60aad054eea1..e3a6e9a1f5b4 100644
> > --- a/tools/lib/bpf/bpf_helpers.h
> > +++ b/tools/lib/bpf/bpf_helpers.h
> > @@ -12,6 +12,7 @@
> >
> > #define __uint(name, val) int (*name)[val]
> > #define __type(name, val) typeof(val) *name
> > +#define __inner(name, val) typeof(val) *name[]
> ...
> > +++ b/tools/testing/selftests/bpf/progs/test_btf_map_in_map.c
> > @@ -0,0 +1,76 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +/* Copyright (c) 2020 Facebook */
> > +#include <linux/bpf.h>
> > +#include <bpf/bpf_helpers.h>
> > +
> > +struct inner_map {
> > + __uint(type, BPF_MAP_TYPE_ARRAY);
> > + __uint(max_entries, 1);
> > + __type(key, int);
> > + __type(value, int);
> > +} inner_map1 SEC(".maps"),
> > + inner_map2 SEC(".maps");
> > +
> > +struct outer_arr {
> > + __uint(type, BPF_MAP_TYPE_ARRAY_OF_MAPS);
> > + __uint(max_entries, 3);
> > + __uint(key_size, sizeof(int));
> > + __uint(value_size, sizeof(int));
> > + /* it's possible to use anonymous struct as inner map definition here */
> > + __inner(values, struct {
> > + __uint(type, BPF_MAP_TYPE_ARRAY);
> > + /* changing max_entries to 2 will fail during load
> > + * due to incompatibility with inner_map definition */
> > + __uint(max_entries, 1);
> > + __type(key, int);
> > + __type(value, int);
> > + });
>
> How about renaming it s/__inner/__array/ ?
> Because that's what it defines from BTF pov.
Sounds good, will update.
Powered by blists - more mailing lists