Subject: Re: [PATCH net-next 3/8] devlink: report extended error message in region_read_dumpit

From: Jacob Keller <[email-masked]>
Date: Mon, 21 Nov 2022 13:18:37 -0800

On 11/21/2022 11:23 AM, Jakub Kicinski wrote:
> On Mon, 21 Nov 2022 11:10:37 -0800 Jacob Keller wrote:
>>>> @@ -6453,8 +6453,14 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb,
>>>>    
>>>>    	devl_lock(devlink);
>>>>    
>>>> -	if (!attrs[DEVLINK_ATTR_REGION_NAME] ||
>>>> -	    !attrs[DEVLINK_ATTR_REGION_SNAPSHOT_ID]) {
>>>> +	if (!attrs[DEVLINK_ATTR_REGION_NAME]) {
>>>> +		NL_SET_ERR_MSG_MOD(cb->extack, "No region name provided");
>>>> +		err = -EINVAL;
>>>> +		goto out_unlock;
>>>> +	}
>>>> +
>>>> +	if (!attrs[DEVLINK_ATTR_REGION_SNAPSHOT_ID]) {
>>>
>>> Please use GENL_REQ_ATTR_CHECK() instead of adding strings.
>>>    
>>
>> Ahhh. Figured out why GENL_REQ_ATTR_CHECK wasn't used here already. It
>> happens because the dumpit functions don't get a genl_info * struct,
>> they get a netlink_cb and a genl_dumpit_info.
>>
>> I can look at improving this.
> 
> Ah damn, you're right, I thought I just missed it because it wasn't
> at the top of the function.

I also saw a few other cases where it might make sense to use a 
GENL_CB_REQ_ATTR_CHECK or similar.

Unfortunately there's at least one area where we check for attributes 
inside a function that is used in both flows which would get a bit 
problematic :( Will see what I can come up with.

Thanks,
Jake