[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJ+HfNgAggmm0ti09O8MeyZ+qwWpug-_kHRZQFaMROUC5B3LDQ@mail.gmail.com>
Date: Fri, 1 Nov 2019 09:31:04 +0100
From: Björn Töpel <bjorn.topel@...il.com>
To: Daniel Borkmann <daniel@...earbox.net>
Cc: Netdev <netdev@...r.kernel.org>,
Alexei Starovoitov <ast@...nel.org>,
Jakub Kicinski <jakub.kicinski@...ronome.com>,
Maciej Fijalkowski <maciej.fijalkowski@...el.com>,
bpf <bpf@...r.kernel.org>,
Magnus Karlsson <magnus.karlsson@...il.com>,
"Karlsson, Magnus" <magnus.karlsson@...el.com>,
Jonathan Lemon <jonathan.lemon@...il.com>,
Toke Høiland-Jørgensen <toke@...hat.com>
Subject: Re: [PATCH bpf-next v4 2/3] bpf: implement map_gen_lookup() callback
for XSKMAP
On Fri, 1 Nov 2019 at 00:48, Daniel Borkmann <daniel@...earbox.net> wrote:
>
> On Thu, Oct 31, 2019 at 09:47:48AM +0100, Björn Töpel wrote:
> > From: Maciej Fijalkowski <maciej.fijalkowski@...el.com>
[...]
> > +static u32 xsk_map_gen_lookup(struct bpf_map *map, struct bpf_insn *insn_buf)
> > +{
> > + const int ret = BPF_REG_0, mp = BPF_REG_1, index = BPF_REG_2;
> > + struct bpf_insn *insn = insn_buf;
> > +
> > + *insn++ = BPF_LDX_MEM(BPF_W, ret, index, 0);
> > + *insn++ = BPF_JMP_IMM(BPF_JGE, ret, map->max_entries, 5);
> > + *insn++ = BPF_ALU64_IMM(BPF_LSH, ret, ilog2(sizeof(struct xsk_sock *)));
> > + *insn++ = BPF_ALU64_IMM(BPF_ADD, mp, offsetof(struct xsk_map, xsk_map));
> > + *insn++ = BPF_ALU64_REG(BPF_ADD, ret, mp);
> > + *insn++ = BPF_LDX_MEM(BPF_DW, ret, ret, 0);
>
> Your map slots are always exactly sizeof(struct xdp_sock *), right? Wouldn't
> this BPF_DW crash on 32 bit?
>
> Meaning, it would have to be BPF_LDX_MEM(BPF_SIZEOF(struct xsk_sock *), ...)?
>
Indeed. Thanks for finding this. I'll do a respin.
Björn
Powered by blists - more mailing lists