Subject: Re: [PATCH net-next v13 1/4] netdevsim: allow two netdevsim ports to be connected

From: Jakub Kicinski <[email-masked]>
Date: Fri, 23 Feb 2024 16:44:23 -0800

On Wed, 21 Feb 2024 21:08:37 -0800 David Wei wrote:
> +	if (!netdev_is_nsim(dev_b)) {
> +		pr_err("Device with ifindex %u in netnsfd %d is not a netdevsim\n", ifidx_b, netnsfd_b);

nit: the string format can overflow the 80 char limit, but if there 
are arguments and they don't fit in the limit, please put them on 
the next line.

> +		goto out_err;
> +	}
> +
> +	if (dev_a == dev_b) {
> +		pr_err("Cannot link a netdevsim to itself\n");
> +		goto out_err;
> +	}
> +
> +	err = 0;

Why zero.. 

> +	nsim_a = netdev_priv(dev_a);
> +	peer = rtnl_dereference(nsim_a->peer);
> +	if (peer) {
> +		pr_err("Netdevsim %d:%u is already linked\n", netnsfd_a, ifidx_a);
> +		goto out_err;

I'd think if we hit this we should return -EBUSY?
Unless peer == dev_b, but that may be splitting hair.

You should also implement .ndo_get_iflink, so that ip link can display
the peer information.
-- 
pw-bot: cr