Subject: Re: [PATCH net-next 05/13] genetlink: check for callback type at op load time

From: Jakub Kicinski <[email-masked]>
Date: Wed, 19 Oct 2022 14:45:34 -0700

On Wed, 19 Oct 2022 14:33:39 -0700 Jacob Keller wrote:
> > +static int
> >  genl_cmd_full_to_split(struct genl_split_ops *op,
> >  		       const struct genl_family *family,
> >  		       const struct genl_ops *full, u8 flags)
> >  {
> > +	if ((flags & GENL_CMD_CAP_DO && !full->doit) ||
> > +	    (flags & GENL_CMD_CAP_DUMP && !full->dumpit)) {
> > +		memset(op, 0, sizeof(*op));
> > +		return -ENOENT;
> > +	}
> > +  
> 
> Should this check that exactly one of GENL_CMD_CAP_DO and
> GENL_CMD_CAP_DUMP is set? Or is some earlier flow enforcing this?

I check at registration time that the family-provided flags only 
have one of those two set. Internally, inside genetlink.c it'd be 
a programming error to request both at the same time, IOW it'd be
defensive programming to check for it.