Re: [PATCH net-next v2 1/2] libbpf: parse maps sections of varying size

2017-10-04 Thread Alexei Starovoitov
On 10/4/17 12:27 PM, Daniel Borkmann wrote: On 10/04/2017 03:59 PM, Craig Gallek wrote: On Tue, Oct 3, 2017 at 10:39 AM, Daniel Borkmann wrote: On 10/03/2017 01:07 AM, Alexei Starovoitov wrote: On 10/2/17 9:41 AM, Craig Gallek wrote: +/* Assume equally sized map definitions */ +map_

Re: [PATCH net-next v2 1/2] libbpf: parse maps sections of varying size

2017-10-04 Thread Daniel Borkmann
On 10/04/2017 03:59 PM, Craig Gallek wrote: On Tue, Oct 3, 2017 at 10:39 AM, Daniel Borkmann wrote: On 10/03/2017 01:07 AM, Alexei Starovoitov wrote: On 10/2/17 9:41 AM, Craig Gallek wrote: +/* Assume equally sized map definitions */ +map_def_sz = data->d_size / nr_maps; +if (!da

RE: [PATCH net-next v2 1/2] libbpf: parse maps sections of varying size

2017-10-04 Thread David Laight
From: Craig Gallek > Sent: 04 October 2017 14:58 > >> + obj->maps[map_idx].def = *def; > > > > I'm not too happy/comfortable with this way of copying the memory of > > "def" (the type-cased struct bpf_map_def). I guess it works, and is > > part of the C-standard(?). > > I beli

Re: [PATCH net-next v2 1/2] libbpf: parse maps sections of varying size

2017-10-04 Thread Craig Gallek
On Tue, Oct 3, 2017 at 10:39 AM, Daniel Borkmann wrote: > On 10/03/2017 01:07 AM, Alexei Starovoitov wrote: >> >> On 10/2/17 9:41 AM, Craig Gallek wrote: >>> >>> +/* Assume equally sized map definitions */ >>> +map_def_sz = data->d_size / nr_maps; >>> +if (!data->d_size || (data->d_siz

Re: [PATCH net-next v2 1/2] libbpf: parse maps sections of varying size

2017-10-04 Thread Craig Gallek
On Tue, Oct 3, 2017 at 10:11 AM, Jesper Dangaard Brouer wrote: > On Mon, 2 Oct 2017 12:41:28 -0400 > Craig Gallek wrote: > >> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c >> index 4f402dcdf372..28b300868ad7 100644 >> --- a/tools/lib/bpf/libbpf.c >> +++ b/tools/lib/bpf/libbpf.c >>

Re: [PATCH net-next v2 1/2] libbpf: parse maps sections of varying size

2017-10-04 Thread Craig Gallek
On Tue, Oct 3, 2017 at 10:11 AM, Jesper Dangaard Brouer wrote: > On Mon, 2 Oct 2017 12:41:28 -0400 > Craig Gallek wrote: > >> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c >> index 4f402dcdf372..28b300868ad7 100644 >> --- a/tools/lib/bpf/libbpf.c >> +++ b/tools/lib/bpf/libbpf.c >>

Re: [PATCH net-next v2 1/2] libbpf: parse maps sections of varying size

2017-10-04 Thread Craig Gallek
On Tue, Oct 3, 2017 at 10:03 AM, Jesper Dangaard Brouer wrote: > > > First of all, thank you Craig for working on this. As Alexei says, we > need to improve tools/lib/bpf/libbpf and move towards converting users > of bpf_load.c to this lib instead. > > Comments inlined below. > >> +

Re: [PATCH net-next v2 1/2] libbpf: parse maps sections of varying size

2017-10-03 Thread Daniel Borkmann
On 10/03/2017 01:07 AM, Alexei Starovoitov wrote: On 10/2/17 9:41 AM, Craig Gallek wrote: +/* Assume equally sized map definitions */ +map_def_sz = data->d_size / nr_maps; +if (!data->d_size || (data->d_size % nr_maps) != 0) { +pr_warning("unable to determine map definition s

Re: [PATCH net-next v2 1/2] libbpf: parse maps sections of varying size

2017-10-03 Thread Jesper Dangaard Brouer
On Mon, 2 Oct 2017 12:41:28 -0400 Craig Gallek wrote: > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c > index 4f402dcdf372..28b300868ad7 100644 > --- a/tools/lib/bpf/libbpf.c > +++ b/tools/lib/bpf/libbpf.c > @@ -580,7 +580,7 @@ bpf_object__init_kversion(struct bpf_object *obj, >

Re: [PATCH net-next v2 1/2] libbpf: parse maps sections of varying size

2017-10-03 Thread Jesper Dangaard Brouer
First of all, thank you Craig for working on this. As Alexei says, we need to improve tools/lib/bpf/libbpf and move towards converting users of bpf_load.c to this lib instead. Comments inlined below. On Mon, 2 Oct 2017 12:41:28 -0400 Craig Gallek wrote: > From: Craig Gallek > > This libra

Re: [PATCH net-next v2 1/2] libbpf: parse maps sections of varying size

2017-10-02 Thread Alexei Starovoitov
On 10/2/17 9:41 AM, Craig Gallek wrote: + /* Assume equally sized map definitions */ + map_def_sz = data->d_size / nr_maps; + if (!data->d_size || (data->d_size % nr_maps) != 0) { + pr_warning("unable to determine map definition size " + "s

[PATCH net-next v2 1/2] libbpf: parse maps sections of varying size

2017-10-02 Thread Craig Gallek
From: Craig Gallek This library previously assumed a fixed-size map options structure. Any new options were ignored. In order to allow the options structure to grow and to support parsing older programs, this patch updates the maps section parsing to handle varying sizes. Object files with maps