netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
	pabeni@redhat.com, jiri@resnulli.us, razor@blackwall.org,
	nicolas.dichtel@6wind.com, gnault@redhat.com,
	jacob.e.keller@intel.com, fw@strlen.de,
	mareklindner@neomailbox.ch, sw@simonwunderlich.de, a@unstable.cc,
	sven@narfation.org, jiri@nvidia.com, nhorman@tuxdriver.com,
	alex.aring@gmail.com, stefan@datenfreihafen.org
Subject: Re: [PATCH net-next 03/13] genetlink: introduce split op representation
Date: Wed, 19 Oct 2022 12:14:22 -0700	[thread overview]
Message-ID: <20221019121422.799eee78@kernel.org> (raw)
In-Reply-To: <93e9137fb80f63cd13fa226bcca3007c473a74d4.camel@sipsolutions.net>

On Wed, 19 Oct 2022 09:59:24 +0200 Johannes Berg wrote:
> On Tue, 2022-10-18 at 16:07 -0700, Jakub Kicinski wrote:
> > + * Do callbacks:
> > + * @pre_doit: called before an operation's @doit callback, it may
> > + *	do additional, common, filtering and return an error
> > + * @doit: standard command callback
> > + * @post_doit: called after an operation's @doit callback, it may
> > + *	undo operations done by pre_doit, for example release locks  
> 
> Is that really worth it? I mean, if you need pre/post for a *specific*
> op, you can just roll that into it.
> 
> Maybe the use case would be something like "groups" where some commands
> need one set of pre/post, and some other commands need another set, and

Exactly - groups of ops. Different groups of ops need different
handling. But as I think I mentioned in the commit messages the 
separate policies are the real reason, this is just done "while 
at it".

> then it's still simpler to do as pre/post rather than calling them
> inside the doit()?

A little bit, it simplifies the unwind in case you need to take some
references and some locks you save dealing with success path vs error 
path handling in the doit.

> (and you also have space for the pointers given the dump part of the
> union, so ...)

Yes, we have the space... I think I lost your thread of thought..
Do you want to define more info for each group than just the pre/post?

> > +static void
> > +genl_cmd_full_to_split(struct genl_split_ops *op,
> > +		       const struct genl_family *family,
> > +		       const struct genl_ops *full, u8 flags)
> > +{  
> 
> [...]
> 
> 
> > +	op->flags		|= flags;  
> 
> why |= ?

op->flags should already have all the existing flags (i.e. ADMIN_PERM)
from the op, I'm adding the DO/DUMP to them.

> > @@ -776,8 +821,9 @@ static int genl_family_rcv_msg(const struct genl_family *family,
> >  {
> >  	struct net *net = sock_net(skb->sk);
> >  	struct genlmsghdr *hdr = nlmsg_data(nlh);
> > -	struct genl_ops op;
> > +	struct genl_split_ops op;  
> 
> it's not even initialized?
> 
> > +	flags = (nlh->nlmsg_flags & NLM_F_DUMP) == NLM_F_DUMP ?
> > +		GENL_CMD_CAP_DUMP : GENL_CMD_CAP_DO;
> > +	if (genl_get_cmd_split(hdr->cmd, flags, family, &op))
> >  		return -EOPNOTSUPP;  
> 
> before being used
> 
> or am I misreading something?

It's used as an output argument here, so that's what initializes it.
genl_get_cmd* should always init the split command because in policy
dumping we don't care about the errors, we just want the structure
to be zeroed if do/dump is not implemented, and we'll skip accordingly.
Wiping the 40B just to write all the fields felt... wrong. 
Let KASAN catch us if we fail to init something.

  reply	other threads:[~2022-10-19 19:14 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-18 23:07 [PATCH net-next 00/13] genetlink: support per op type policies Jakub Kicinski
2022-10-18 23:07 ` [PATCH net-next 01/13] genetlink: refactor the cmd <> policy mapping dump Jakub Kicinski
2022-10-19  7:50   ` Johannes Berg
2022-10-19 15:59     ` Jakub Kicinski
2022-10-19 21:20       ` Jacob Keller
2022-10-18 23:07 ` [PATCH net-next 02/13] genetlink: move the private fields in struct genl_family Jakub Kicinski
2022-10-19  7:51   ` Johannes Berg
2022-10-19 21:21   ` Jacob Keller
2022-10-18 23:07 ` [PATCH net-next 03/13] genetlink: introduce split op representation Jakub Kicinski
2022-10-19  7:59   ` Johannes Berg
2022-10-19 19:14     ` Jakub Kicinski [this message]
2022-10-19 19:36       ` Johannes Berg
2022-10-19 19:50         ` Jakub Kicinski
2022-10-19 21:28         ` Jacob Keller
2022-10-18 23:07 ` [PATCH net-next 04/13] genetlink: load policy based on validation flags Jakub Kicinski
2022-10-19  8:01   ` Johannes Berg
2022-10-19 19:20     ` Jakub Kicinski
2022-10-19 19:33       ` Johannes Berg
2022-10-19 19:49         ` Jakub Kicinski
2022-10-18 23:07 ` [PATCH net-next 05/13] genetlink: check for callback type at op load time Jakub Kicinski
2022-10-19 21:33   ` Jacob Keller
2022-10-19 21:45     ` Jakub Kicinski
2022-10-18 23:07 ` [PATCH net-next 06/13] genetlink: add policies for both doit and dumpit in ctrl_dumppolicy_start() Jakub Kicinski
2022-10-19  8:08   ` Johannes Berg
2022-10-19 19:22     ` Jakub Kicinski
2022-10-18 23:07 ` [PATCH net-next 07/13] genetlink: support split policies in ctrl_dumppolicy_put_op() Jakub Kicinski
2022-10-19 21:38   ` Jacob Keller
2022-10-19 21:46     ` Jakub Kicinski
2022-10-18 23:07 ` [PATCH net-next 08/13] genetlink: inline genl_get_cmd() Jakub Kicinski
2022-10-19 21:46   ` Jacob Keller
2022-10-18 23:07 ` [PATCH net-next 09/13] genetlink: add iterator for walking family ops Jakub Kicinski
2022-10-19 21:49   ` Jacob Keller
2022-10-18 23:07 ` [PATCH net-next 10/13] genetlink: use iterator in the op to policy map dumping Jakub Kicinski
2022-10-19 21:53   ` Jacob Keller
2022-10-18 23:07 ` [PATCH net-next 11/13] genetlink: inline old iteration helpers Jakub Kicinski
2022-10-19 22:15   ` Jacob Keller
2022-10-18 23:07 ` [PATCH net-next 12/13] genetlink: allow families to use split ops directly Jakub Kicinski
2022-10-19  8:15   ` Johannes Berg
2022-10-19 19:25     ` Jakub Kicinski
2022-10-19 19:37       ` Johannes Berg
2022-10-19 19:57         ` Jakub Kicinski
2022-10-20  7:32           ` Johannes Berg
2022-10-20 18:09             ` Jakub Kicinski
2022-10-21 11:02               ` Johannes Berg
2022-10-21 15:01                 ` Jakub Kicinski
2022-10-18 23:07 ` [PATCH net-next 13/13] genetlink: convert control family to split ops Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221019121422.799eee78@kernel.org \
    --to=kuba@kernel.org \
    --cc=a@unstable.cc \
    --cc=alex.aring@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=gnault@redhat.com \
    --cc=jacob.e.keller@intel.com \
    --cc=jiri@nvidia.com \
    --cc=jiri@resnulli.us \
    --cc=johannes@sipsolutions.net \
    --cc=mareklindner@neomailbox.ch \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=nicolas.dichtel@6wind.com \
    --cc=pabeni@redhat.com \
    --cc=razor@blackwall.org \
    --cc=stefan@datenfreihafen.org \
    --cc=sven@narfation.org \
    --cc=sw@simonwunderlich.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).