Re: [RFC PATCH v3 12/12] selftests: add ncdevmem, netcat for devmem TCP

From: Jakub Kicinski
Date: Fri Nov 10 2023 - 21:36:02 EST


On Fri, 10 Nov 2023 18:27:08 -0800 Mina Almasry wrote:
> Thanks for the clear requirement. I clearly had something different in mind.
>
> Might be dumb suggestions, but instead of creating a new ndo that we
> maybe end up wanting to deprecate once the queue API is ready, how
> about we use either of those existing APIs?
>
> +void netdev_reset(struct net_device *dev)
> +{
> + int flags = ETH_RESET_ALL;
> + int err;
> +
> +#if 1
> + __dev_close(dev);
> + err = __dev_open(dev, NULL);
> +#else
> + err = dev->ethtool_ops->reset(dev, &flags);
> +#endif
> +}
> +
>
> I've tested both of these to work with GVE on both bind via the
> netlink API and unbind via the netlink socket close, but I'm not
> enough of an expert to tell if there is some bad side effect that can
> happen or something.

We generally don't accept drivers doing device reconfiguration with
full close() + open() because if the open() fails your machine
may be cut off.

There are drivers which do it, but they are either old... or weren't
reviewed hard enough.

The driver should allocate memory and whether else it can without
stopping the queues first. Once it has all those, stop the queues,
reconfigure with already allocated resources, start queues, free old.

Even without the queue API in place, good drivers do full device
reconfig this way. Hence my mind goes towards a new (temporary?)
ndo. It will be replaced by the queue API, but whoever implements
it for now has to follow this careful reconfig strategy...