Re: [PATCH bpf-next v4 2/3] bpf: implement map_gen_lookup() callback for XSKMAP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 1 Nov 2019 at 00:48, Daniel Borkmann <daniel@xxxxxxxxxxxxx> wrote:
>
> On Thu, Oct 31, 2019 at 09:47:48AM +0100, Björn Töpel wrote:
> > From: Maciej Fijalkowski <maciej.fijalkowski@xxxxxxxxx>
[...]
> > +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




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux