Re: [PATCH net-next v1] netdevsim: Forbid devlink reload when adding or deleting ports

Jakub Kicinski
2021-08-05T13:15:51Z

On Thu, 5 Aug 2021 14:05:41 +0300 Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@nvidia.com>
>
> In order to remove complexity in devlink core related to
> devlink_reload_enable/disable, let's rewrite new_port/del_port
> logic to rely on internal to netdevsim lock.
>
> We should protect only reload_down flow because it destroys nsim_dev,
> which is needed for nsim_dev_port_add/nsim_dev_port_del to hold
> port_list_lock.

I don't understand why we only have to protect reload_down.

What protects us from adding a port right after down? That'd hit a
destroyed mutex, up wipes the port list etc...

> + nsim_bus_dev = nsim_dev->nsim_bus_dev;
> + if (!mutex_trylock(&nsim_bus_dev->nsim_bus_reload_lock))
> + return -EOPNOTSUPP;

Why not -EBUSY?