[PATCH net-next] net: uevent: also pass network device driver

From: Til Kaiser
Date: Fri Nov 15 2024 - 13:42:04 EST


Currently, for uevent, the interface name and
index are passed via shell variables.

This commit also passes the network device
driver as a shell variable to uevent.

Signed-off-by: Til Kaiser <mail@xxxxxxxx>
---
net/core/net-sysfs.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 05cf5347f25e..67aad5ca82f8 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -2000,6 +2000,7 @@ EXPORT_SYMBOL_GPL(net_ns_type_operations);
static int netdev_uevent(const struct device *d, struct kobj_uevent_env *env)
{
const struct net_device *dev = to_net_dev(d);
+ const char *driver = netdev_drivername(dev);
int retval;

/* pass interface to uevent. */
@@ -2012,6 +2013,12 @@ static int netdev_uevent(const struct device *d, struct kobj_uevent_env *env)
* and is what RtNetlink uses natively.
*/
retval = add_uevent_var(env, "IFINDEX=%d", dev->ifindex);
+ if (retval)
+ goto exit;
+
+ if (driver[0])
+ /* pass driver to uevent. */
+ retval = add_uevent_var(env, "DRIVER=%s", driver);

exit:
return retval;
--
2.47.0