On Sat, Apr 02, 2016 at 08:40:55PM +0200, Johannes Berg wrote: > On Fri, 2016-04-01 at 18:21 -0700, Brenden Blanco wrote: > > > +static int mlx4_bpf_set(struct net_device *dev, int fd) > > +{ > [...] > > + if (prog->type != BPF_PROG_TYPE_PHYS_DEV) { > > + bpf_prog_put(prog); > > + return -EINVAL; > > + } > > + } > > Why wouldn't this check be done in the generic code that calls > ndo_bpf_set()? Having a common check makes sense. The tricky thing is that the type can only be checked after taking the reference, and I wanted to keep the scope of the prog brief in the case of errors. I would have to move the bpf_prog_get logic into dev_change_bpf_fd and pass a bpf_prog * into the ndo instead. Would that API look fine to you?
A possible extension of this is just to keep the bpf_prog * in the netdev itself and expose a feature flag from the driver rather than an ndo. But that would mean another 8 bytes in the netdev. > > johannes