From: Breno Leitao <leitao@xxxxxxxxxx> Date: Thu, 4 Apr 2024 04:48:41 -0700 > It is impossible to use init_dummy_netdev together with alloc_netdev() > as the 'setup' argument. > > This is because alloc_netdev() initializes some fields in the net_device > structure, and later init_dummy_netdev() memzero them all. This causes > some problems as reported here: > > https://lore.kernel.org/all/20240322082336.49f110cc@xxxxxxxxxx/ > > Split the init_dummy_netdev() function in two. Create a new function called > init_dummy_netdev_core() that does not memzero the net_device structure. > Then have init_dummy_netdev() memzero-ing and calling > init_dummy_netdev_core(), keeping the old behaviour. > > init_dummy_netdev_core() is the new function that could be called as an > argument for alloc_netdev(). > > Also, create a helper to allocate and initialize dummy net devices, > leveraging init_dummy_netdev_core() as the setup argument. This function > basically simplify the allocation of dummy devices, by allocating and > initializing it. Freeing the device continue to be done through > free_netdev() [...] > @@ -11063,6 +11070,17 @@ void free_netdev(struct net_device *dev) > } > EXPORT_SYMBOL(free_netdev); > > +/** > + * alloc_netdev_dummy - Allocate and initialize a dummy net device. > + * @sizeof_priv: size of private data to allocate space for > + */ > +struct net_device *alloc_netdev_dummy(int sizeof_priv) Repeating my question from the previous thread: I see that in your series you always pass 0 as @sizeof_priv, does it make sense to have this argument or we can just pass 0 here to alloc_netdev() unconditionally? Drivers that have &net_device embedded can't have any private data there anyway. > +{ > + return alloc_netdev(sizeof_priv, "dummy#", NET_NAME_UNKNOWN, > + init_dummy_netdev_core); > +} > +EXPORT_SYMBOL_GPL(alloc_netdev_dummy); > + > /** > * synchronize_net - Synchronize with packet receive processing > * Thanks, Olek