Skip to content

Commit

Permalink
net: cleanup init_dummy_netdev_core()
Browse files Browse the repository at this point in the history
init_dummy_netdev_core() used to cater to net_devices which
did not come from alloc_netdev_mqs(). Since that's no longer
supported remove the init logic which duplicates alloc_netdev_mqs().

While at it rename back to init_dummy_netdev().

Reviewed-by: Joe Damato <jdamato@fastly.com>
Link: https://patch.msgid.link/20250113003456.3904110-2-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Jan 14, 2025
1 parent f835bda commit 37adf10
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -10736,26 +10736,20 @@ int register_netdevice(struct net_device *dev)
EXPORT_SYMBOL(register_netdevice);

/* Initialize the core of a dummy net device.
* This is useful if you are calling this function after alloc_netdev(),
* since it does not memset the net_device fields.
* The setup steps dummy netdevs need which normal netdevs get by going
* through register_netdevice().
*/
static void init_dummy_netdev_core(struct net_device *dev)
static void init_dummy_netdev(struct net_device *dev)
{
/* make sure we BUG if trying to hit standard
* register/unregister code path
*/
dev->reg_state = NETREG_DUMMY;

/* NAPI wants this */
INIT_LIST_HEAD(&dev->napi_list);

/* a dummy interface is started by default */
set_bit(__LINK_STATE_PRESENT, &dev->state);
set_bit(__LINK_STATE_START, &dev->state);

/* napi_busy_loop stats accounting wants this */
dev_net_set(dev, &init_net);

/* Note : We dont allocate pcpu_refcnt for dummy devices,
* because users of this 'device' dont need to change
* its refcount.
Expand Down Expand Up @@ -11440,7 +11434,7 @@ EXPORT_SYMBOL(free_netdev);
struct net_device *alloc_netdev_dummy(int sizeof_priv)
{
return alloc_netdev(sizeof_priv, "dummy#", NET_NAME_UNKNOWN,
init_dummy_netdev_core);
init_dummy_netdev);
}
EXPORT_SYMBOL_GPL(alloc_netdev_dummy);

Expand Down

0 comments on commit 37adf10

Please sign in to comment.