Re: Genetlink per cmd policies

2020-10-01 Thread Johannes Berg
On Thu, 2020-10-01 at 08:50 -0700, Jakub Kicinski wrote: > > > > > > > + memcpy(op, &family->ops[i], sizeof(*op)); > > > > > > > > > > > > What's wrong with struct assignment? :) > FWIW the 400 was without the -Os with -Os it's more like 50. So I'll > just go for it and do the struct assig

Re: Genetlink per cmd policies

2020-10-01 Thread Jakub Kicinski
On Thu, 1 Oct 2020 03:53:23 +0200 Andrew Lunn wrote: > On Wed, Sep 30, 2020 at 05:23:17PM -0700, Jakub Kicinski wrote: > > On Thu, 1 Oct 2020 01:38:17 +0200 Andrew Lunn wrote: > > > > > > +static void genl_op_from_full(const struct genl_family *family, > > > > > > + unsign

Re: Genetlink per cmd policies

2020-09-30 Thread Andrew Lunn
On Wed, Sep 30, 2020 at 05:23:17PM -0700, Jakub Kicinski wrote: > On Thu, 1 Oct 2020 01:38:17 +0200 Andrew Lunn wrote: > > > > > +static void genl_op_from_full(const struct genl_family *family, > > > > > + unsigned int i, struct genl_ops *op) > > > > > +{ > > > > > + m

Re: Genetlink per cmd policies

2020-09-30 Thread Jakub Kicinski
On Thu, 1 Oct 2020 01:38:17 +0200 Andrew Lunn wrote: > > > > +static void genl_op_from_full(const struct genl_family *family, > > > > + unsigned int i, struct genl_ops *op) > > > > +{ > > > > + memcpy(op, &family->ops[i], sizeof(*op)); > > > > > > What's wrong

Re: Genetlink per cmd policies

2020-09-30 Thread Andrew Lunn
> > > +static void genl_op_from_full(const struct genl_family *family, > > > + unsigned int i, struct genl_ops *op) > > > +{ > > > + memcpy(op, &family->ops[i], sizeof(*op)); > > > > What's wrong with struct assignment? :) > > > > *op = family->ops[i]; > > Code size :

Re: Genetlink per cmd policies

2020-09-30 Thread Jakub Kicinski
On Wed, 30 Sep 2020 22:13:07 +0200 Johannes Berg wrote: > > +/** > > + * struct genl_light_ops - generic netlink operations (small version) > > + * @cmd: command identifier > > + * @internal_flags: flags used by the family > > + * @flags: flags > > + * @validate: validation flags from enum genl_val

Re: Genetlink per cmd policies

2020-09-30 Thread Johannes Berg
On Wed, 2020-09-30 at 12:46 -0700, Jakub Kicinski wrote: > This builds (I think) - around 100 extra LoC: Looks good to me, couple of comments below. > +/** > + * struct genl_light_ops - generic netlink operations (small version) > + * @cmd: command identifier > + * @internal_flags: flags used by

Re: Genetlink per cmd policies

2020-09-30 Thread Jakub Kicinski
On Wed, 30 Sep 2020 21:15:33 +0200 Johannes Berg wrote: > On Wed, 2020-09-30 at 12:14 -0700, Jakub Kicinski wrote: > > > > Hm. I guess you could even have both? > > > > > > struct genl_ops *ops; > > > struct genl_ops_ext *extops; > > > > > > and then search both arrays, no need for memcpy/po

Re: Genetlink per cmd policies

2020-09-30 Thread Johannes Berg
On Wed, 2020-09-30 at 12:14 -0700, Jakub Kicinski wrote: > > Hm. I guess you could even have both? > > > > struct genl_ops *ops; > > struct genl_ops_ext *extops; > > > > and then search both arrays, no need for memcpy/pointer assignment? > > Yup, both should work quite nicely, too. No r

Re: Genetlink per cmd policies

2020-09-30 Thread Jakub Kicinski
On Wed, 30 Sep 2020 21:03:08 +0200 Johannes Berg wrote: > On Wed, 2020-09-30 at 12:01 -0700, Jakub Kicinski wrote: > > On Wed, 30 Sep 2020 20:36:24 +0200 Johannes Berg wrote: > > > On Wed, 2020-09-30 at 09:44 -0700, Jakub Kicinski wrote: > > > > > > > I started with a get_policy() callback, bu

Re: Genetlink per cmd policies

2020-09-30 Thread Johannes Berg
On Wed, 2020-09-30 at 12:01 -0700, Jakub Kicinski wrote: > On Wed, 30 Sep 2020 20:36:24 +0200 Johannes Berg wrote: > > On Wed, 2020-09-30 at 09:44 -0700, Jakub Kicinski wrote: > > > > > I started with a get_policy() callback, but I didn't like it much. > > > Static data is much more pleasant for a

Re: Genetlink per cmd policies

2020-09-30 Thread Jakub Kicinski
On Wed, 30 Sep 2020 20:36:24 +0200 Johannes Berg wrote: > On Wed, 2020-09-30 at 09:44 -0700, Jakub Kicinski wrote: > > > I started with a get_policy() callback, but I didn't like it much. > > Static data is much more pleasant for a client of the API IMHO. > > Yeah, true. > > > What do you thin

Re: Genetlink per cmd policies

2020-09-30 Thread Johannes Berg
On Wed, 2020-09-30 at 20:42 +0200, Michal Kubecek wrote: > > Not really good either but how about embedding struct genl_ops as first > member of struct genl_ops_ext like we do with sockets? That won't work, we need to make an *array* out of these... johannes

Re: Genetlink per cmd policies

2020-09-30 Thread Michal Kubecek
On Wed, Sep 30, 2020 at 08:36:24PM +0200, Johannes Berg wrote: > On Wed, 2020-09-30 at 09:44 -0700, Jakub Kicinski wrote: > > > I started with a get_policy() callback, but I didn't like it much. > > Static data is much more pleasant for a client of the API IMHO. > > Yeah, true. > > > What do you

Re: Genetlink per cmd policies

2020-09-30 Thread Johannes Berg
On Wed, 2020-09-30 at 09:44 -0700, Jakub Kicinski wrote: > I started with a get_policy() callback, but I didn't like it much. > Static data is much more pleasant for a client of the API IMHO. Yeah, true. > What do you think about "ops light"? Insufficiently flexible? TBH, I'm not really sure ho

Re: Genetlink per cmd policies

2020-09-30 Thread Jakub Kicinski
On Wed, 30 Sep 2020 18:17:47 +0200 Johannes Berg wrote: > On Wed, 2020-09-30 at 18:06 +0200, Johannes Berg wrote: > > > > That's the historic info I guess - I'll take a look at ethtool later and > > see what it's doing there. > > Oh, ok, I see how that works ... you *do* have a sort of common/a

Re: Genetlink per cmd policies

2020-09-30 Thread Jakub Kicinski
On Wed, 30 Sep 2020 18:06:28 +0200 Johannes Berg wrote: > Hi Jakub, > > > I'd like to be able to dump ethtool nl policies, but right now policy > > dumping is only supported for "global" family policies. > > Did ethtool add per-command policies? Yup. > > Is there any reason not to put the pol

Re: Genetlink per cmd policies

2020-09-30 Thread Johannes Berg
On Wed, 2020-09-30 at 18:06 +0200, Johannes Berg wrote: > > That's the historic info I guess - I'll take a look at ethtool later and > see what it's doing there. Oh, ok, I see how that works ... you *do* have a sort of common/aliased attribute inside each per-op family that then carries common su

Re: Genetlink per cmd policies

2020-09-30 Thread Jakub Kicinski
On Wed, 30 Sep 2020 18:03:03 +0200 Michal Kubecek wrote: > On Wed, Sep 30, 2020 at 08:49:55AM -0700, Jakub Kicinski wrote: > > Hi! > > > > I'd like to be able to dump ethtool nl policies, but right now policy > > dumping is only supported for "global" family policies. > > > > Is there any reason

Re: Genetlink per cmd policies

2020-09-30 Thread Johannes Berg
Hi Jakub, > I'd like to be able to dump ethtool nl policies, but right now policy > dumping is only supported for "global" family policies. Did ethtool add per-command policies? > Is there any reason not to put the policy in struct genl_ops, > or just nobody got to it, yet? > > I get the feeli

Re: Genetlink per cmd policies

2020-09-30 Thread Michal Kubecek
On Wed, Sep 30, 2020 at 08:49:55AM -0700, Jakub Kicinski wrote: > Hi! > > I'd like to be able to dump ethtool nl policies, but right now policy > dumping is only supported for "global" family policies. > > Is there any reason not to put the policy in struct genl_ops, > or just nobody got to it,

Genetlink per cmd policies

2020-09-30 Thread Jakub Kicinski
Hi! I'd like to be able to dump ethtool nl policies, but right now policy dumping is only supported for "global" family policies. Is there any reason not to put the policy in struct genl_ops, or just nobody got to it, yet? I get the feeling that this must have been discussed before...