Subject: Re: [PATCH iproute2-next v2 4/4] devlink: Drop now duplicate pid fallback for netns

From: Leon Romanovsky <[email-masked]>
Date: Wed, 13 May 2026 08:40:45 +0300

On Tue, May 12, 2026 at 01:34:07PM -0600, David Ahern wrote:
> From: David Ahern <[email-masked]>
> 
> Now that netns_get_fd handles by name and pid, the special
> handling in devlink to fallback to PID can be removed with
> both cases handled by the FD attribute.
> 
> Signed-off-by: David Ahern <[email-masked]>
> ---
>  devlink/devlink.c | 25 +++++++------------------
>  1 file changed, 7 insertions(+), 18 deletions(-)

<...>

>  static char *dl_argv_next(struct dl *dl)
>  {
>  	char *ret;
> @@ -2153,14 +2147,12 @@ static int dl_argv_parse(struct dl *dl, uint64_t o_required,
>  			err = dl_argv_str(dl, &netns_str);
>  			if (err)
>  				return err;
> -			opts->netns = netns_get_fd(netns_str);
> -			if ((int)opts->netns < 0) {
> -				dl_arg_dec(dl);
> -				err = dl_argv_uint32_t(dl, &opts->netns);
> -				if (err)
> -					return err;
> -				opts->netns_is_pid = true;
> -			}
> +
> +			err = netns_get_fd(netns_str);
> +			if (err < 0)
> +				return err;
> +
> +			opts->netns = err;
>  			o_found |= DL_OPT_NETNS;
>  		} else if (dl_argv_match(dl, "action") &&
>  			   (o_all & DL_OPT_RELOAD_ACTION)) {
> @@ -2725,10 +2717,7 @@ static void dl_opts_put(struct nlmsghdr *nlh, struct dl *dl)
>  		mnl_attr_put_u8(nlh, DEVLINK_ATTR_TRAP_ACTION,
>  				opts->trap_action);
>  	if (opts->present & DL_OPT_NETNS)
> -		mnl_attr_put_u32(nlh,
> -				 opts->netns_is_pid ? DEVLINK_ATTR_NETNS_PID :
> -						      DEVLINK_ATTR_NETNS_FD,
> -				 opts->netns);
> +		mnl_attr_put_u32(nlh, DEVLINK_ATTR_NETNS_FD, opts->netns);

You can also remove netns_is_pid from struct dl_opts.

It is unfortunate that devlink implements DEVLINK_ATTR_NETNS_PID in  
the kernel, given that user space can provide this functionality  
with trivial effort.

Thanks