[systemd-devel] [RFC][PATCH] net: set default DEVTYPE for all ethernet based devices

Tom Gundersen teg at jklm.no
Sat Jan 4 16:58:54 PST 2014


In systemd's networkd and udevd, we would like to give the administrator a
simple way to filter ethernet devices by their DEVTYPE. In order to avoid
having a special treatment of the case where DEVTYPE=(null), initialize it to
a default value, "ethernet", in the kernel.

Signed-off-by: Tom Gundersen <teg at jklm.no>
Cc: Marcel Holtmann <marcel at holtmann.org>
Cc: Greg KH <gregkh at linuxfoundation.org>
---

Hi Greg and Marcel,

This patch seems to do the right thing for me. Any comments before I send it
off to LKML?

I suppose it may make sense to hide this behind a kernel option in case we are
worried about breaking existing users (but if ConnMan is adapted, I don't know
of any other issues, NetworkManager is not affected at least).

Cheers,

Tom

 net/core/dev.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/core/dev.c b/net/core/dev.c
index ba3b7ea..62881e0 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6215,6 +6215,10 @@ void netdev_freemem(struct net_device *dev)
 		kfree(addr);
 }
 
+static const struct device_type ethernet_type = {
+	.name = "ethernet",
+};
+
 /**
  *	alloc_netdev_mqs - allocate network device
  *	@sizeof_priv:	size of private data to allocate space for
@@ -6305,6 +6309,8 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
 		goto free_all;
 #endif
 
+	SET_NETDEV_DEVTYPE(dev, &ethernet_type);
+
 	strcpy(dev->name, name);
 	dev->group = INIT_NETDEV_GROUP;
 	if (!dev->ethtool_ops)
-- 
1.8.5.2



More information about the systemd-devel mailing list