Skip to contentSkip to conversation

net: un-export init_dummy_netdev()

PATCH In review Jakub Kicinski 3 participants 8 messages Jan 11, 2025 – Jan 14, 2025

Subsystems (2)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/2 net: un-export init_dummy_netdev()

There are no in-tree module callers of init_dummy_netdev(), AFAICT.

---
 net/core/dev.c | 1 -
 1 file changed, 1 deletion(-)
net/core/dev.c +0 -1
index 1a90ed8cc6cc..23e7f6a3925b 100644
@@ -10782,7 +10782,6 @@ void init_dummy_netdev(struct net_device *dev)
 	memset(dev, 0, sizeof(struct net_device));
 	init_dummy_netdev_core(dev);
 }
-EXPORT_SYMBOL_GPL(init_dummy_netdev);
 
 /**
  *	register_netdev	- register a network device
Signature · 1 line
2.47.1
author maintainer
#1 lore raw

PATCH 2/2 net: initialize netdev->lock on dummy devices

Make sure netdev->lock is always valid, even on dummy netdevs.

Apparently it's legal to call mutex_destroy() on an uninitialized mutex (and we do that in free_netdev()), but it doesn't seem right. Plus we'll soon want to take netdev->lock on more paths which dummy netdevs may reach.

---
 net/core/dev.c | 2 ++
 1 file changed, 2 insertions(+)
net/core/dev.c +2 -0
index 23e7f6a3925b..00552197d601 100644
@@ -10756,6 +10756,8 @@ static void init_dummy_netdev_core(struct net_device *dev)
 	/* napi_busy_loop stats accounting wants this */
 	dev_net_set(dev, &init_net);
 
+	mutex_init(&dev->lock);
+
 	/* Note : We dont allocate pcpu_refcnt for dummy devices,
 	 * because users of this 'device' dont need to change
 	 * its refcount.
Signature · 1 line
2.47.1
#2 lore raw

Re: [PATCH net-next 2/2] net: initialize netdev->lock on dummy devices

Quoted 6 lines · Jakub Kicinski

Make sure netdev->lock is always valid, even on dummy netdevs.

Apparently it's legal to call mutex_destroy() on an uninitialized mutex (and we do that in free_netdev()), but it doesn't seem right. Plus we'll soon want to take netdev->lock on more paths which dummy netdevs may reach.

I assume here that dummy does not call alloc_netdev_mqs() or one of it wrappers? That is how the lock seems to get initialised for real MAC drivers. Are there other bits of initialisation in that function which dummy is missing? Should we really be refactoring alloc_netdev_mqs() to expose an initialisation helper for everything which is not related queues?

Andrew

author maintainer
#3 lore raw

Re: [PATCH net-next 2/2] net: initialize netdev->lock on dummy devices

Quoted 10 lines · On Sat, 11 Jan 2025 19:58:40 +0100 Andrew Lunn wrote:
Quoted 6 lines · Jakub Kicinski

Make sure netdev->lock is always valid, even on dummy netdevs.

Apparently it's legal to call mutex_destroy() on an uninitialized mutex (and we do that in free_netdev()), but it doesn't seem right. Plus we'll soon want to take netdev->lock on more paths which dummy netdevs may reach.

I assume here that dummy does not call alloc_netdev_mqs() or one of it wrappers?

Yes, we have both dummies which go thru alloc and static ones.

Quoted 5 lines

That is how the lock seems to get initialised for real MAC drivers. Are there other bits of initialisation in that function which dummy is missing? Should we really be refactoring alloc_netdev_mqs() to expose an initialisation helper for everything which is not related queues?

You make a good point. Let me do the opposite, we only have two callers of init_dummy_netdev(). Instead of unexporting it let me delete it completely and make the two callers allocate the netdevs with alloc_netdev_mqs().

Signature · 1 line
pw-bot: cr
#4 lore raw
In reply to Jakub Kicinski
Quoted 21 lines · Jakub Kicinski

There are no in-tree module callers of init_dummy_netdev(), AFAICT.

---
 net/core/dev.c | 1 -
 1 file changed, 1 deletion(-)
net/core/dev.c +0 -2
index 1a90ed8cc6cc..23e7f6a3925b 100644
@@ -10782,7 +10782,6 @@ void init_dummy_netdev(struct net_device *dev)
        memset(dev, 0, sizeof(struct net_device));
        init_dummy_netdev_core(dev);
 }
-EXPORT_SYMBOL_GPL(init_dummy_netdev);
 
 /**
  *     register_netdev - register a network device
--
Quoted 3 lines

2.47.1

I can see that "net/xfrm/xfrm_input.c" and "net/mptcp/protocol.c" are invoking init_dummy_netdev() in the init routines.

Signature · 2 lines
Regards,
Kalesh AP
#5 lore raw

My bad, missed the V2 of the series. Please ignore my comment.

Quoted 32 lines · Kalesh Anakkur Purayil
Quoted 21 lines · Jakub Kicinski

There are no in-tree module callers of init_dummy_netdev(), AFAICT.

---
 net/core/dev.c | 1 -
 1 file changed, 1 deletion(-)
net/core/dev.c +0 -2
index 1a90ed8cc6cc..23e7f6a3925b 100644
@@ -10782,7 +10782,6 @@ void init_dummy_netdev(struct net_device *dev)
        memset(dev, 0, sizeof(struct net_device));
        init_dummy_netdev_core(dev);
 }
-EXPORT_SYMBOL_GPL(init_dummy_netdev);
 
 /**
  *     register_netdev - register a network device
--
Quoted 3 lines

2.47.1

I can see that "net/xfrm/xfrm_input.c" and "net/mptcp/protocol.c" are invoking init_dummy_netdev() in the init routines.

--
Regards,
Kalesh AP

Signature · 2 lines
Regards,
Kalesh AP
#6 lore raw
In reply to Kalesh Anakkur Purayil
Quoted 19 lines · Kalesh Anakkur Purayil
Quoted 18 lines · Jakub Kicinski

There are no in-tree module callers of init_dummy_netdev(), AFAICT.

---
 net/core/dev.c | 1 -
 1 file changed, 1 deletion(-)
net/core/dev.c +0 -1
index 1a90ed8cc6cc..23e7f6a3925b 100644
@@ -10782,7 +10782,6 @@ void init_dummy_netdev(struct net_device *dev)
        memset(dev, 0, sizeof(struct net_device));
        init_dummy_netdev_core(dev);
 }
-EXPORT_SYMBOL_GPL(init_dummy_netdev);
 
Quoted 8 lines
Quoted 6 lines
net/core/dev.c +0 -1
 /**
  *     register_netdev - register a network device
--

2.47.1

I can see that "net/xfrm/xfrm_input.c" and "net/mptcp/protocol.c" are invoking init_dummy_netdev() in the init routines.

I thought that initially. And then i checked that they can only be built in. You only need exports for modules.

Andrew

#7 lore raw
Quoted 30 lines · Andrew Lunn
Quoted 19 lines · Kalesh Anakkur Purayil
Quoted 18 lines · Jakub Kicinski

There are no in-tree module callers of init_dummy_netdev(), AFAICT.

---
 net/core/dev.c | 1 -
 1 file changed, 1 deletion(-)
net/core/dev.c +0 -1
index 1a90ed8cc6cc..23e7f6a3925b 100644
@@ -10782,7 +10782,6 @@ void init_dummy_netdev(struct net_device *dev)
        memset(dev, 0, sizeof(struct net_device));
        init_dummy_netdev_core(dev);
 }
-EXPORT_SYMBOL_GPL(init_dummy_netdev);
 
Quoted 8 lines
Quoted 6 lines
net/core/dev.c +0 -1
 /**
  *     register_netdev - register a network device
--

2.47.1

I can see that "net/xfrm/xfrm_input.c" and "net/mptcp/protocol.c" are invoking init_dummy_netdev() in the init routines.

Quoted 2 lines

I thought that initially. And then i checked that they can only be built in. You only need exports for modules.

Got it, thank you Andrew for the clarification.

Quoted 2 lines

Andrew

Signature · 2 lines
Regards,
Kalesh AP