On Fri, 6 Oct 2017 13:17:48 +0200
Jesper Dangaard Brouer <[email protected]> wrote:
> > > +static void *__xdp_map_lookup_elem(struct bpf_map *map, u32 index)
> > > +{
> > > + switch (map->map_type) {
> > > + case BPF_MAP_TYPE_DEVMAP:
> > > + return __dev_map_lookup_elem(map, index);
> > > + case BPF_MAP_TYPE_CPUMAP:
> > > + return __cpu_map_lookup_elem(map, index);
> > > + default:
> > > + return NULL;
> > > + }
> >
> > Should we just have a callback and instead of the above use
> > map->ptr_lookup_elem() (or however we name it) ... lot of it
> > is pretty much the same logic as with devmap.
>
> We could extend struct bpf_map *map with such a callback, I was just
> afraid that this would be too invasive.
>
> Performance wise, I don't thinks will hurt too much.
> http://www.cipht.net/2017/10/03/are-jump-tables-always-fastest.html
Looking at the code, I would like to postpone this callback work until
after this patchset is merged. As this work will also touch devmap +
sockmap.
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer