lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 21 Nov 2008 13:46:59 -0800
From:	Stephen Hemminger <shemminger@...tta.com>
To:	netdev@...r.kernel.org
Subject: [RFC] network devices generating uevents?

Perhaps the following would make it easier for applications to
track network device events without having to use netlink.
Compile tested only so far. The implementation is almost trivial...

--- a/net/core/Makefile	2008-11-21 12:25:31.000000000 -0800
+++ b/net/core/Makefile	2008-11-21 13:32:30.000000000 -0800
@@ -17,3 +17,4 @@ obj-$(CONFIG_NET_PKTGEN) += pktgen.o
 obj-$(CONFIG_NETPOLL) += netpoll.o
 obj-$(CONFIG_NET_DMA) += user_dma.o
 obj-$(CONFIG_FIB_RULES) += fib_rules.o
+obj-$(CONFIG_HOTPLUG) += uevent.o
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ b/net/core/uevent.c	2008-11-21 13:42:13.000000000 -0800
@@ -0,0 +1,45 @@
+/*
+ * Linux network device event notification
+ *
+ * Author:
+ *	Stephen Hemminger <shemminger@...tta.com>
+ */
+
+#include <linux/kernel.h>
+#include <linux/netdevice.h>
+#include <linux/kobject.h>
+#include <linux/notifier.h>
+
+static int netdev_event(struct notifier_block *this, unsigned long event, void *ptr)
+{
+	struct net_device *netdev = ptr;
+
+	switch (event) {
+	case NETDEV_UNREGISTER:
+		kobject_uevent(&netdev->dev.kobj, KOBJ_REMOVE);
+		break;
+	case NETDEV_REGISTER:
+		kobject_uevent(&netdev->dev.kobj, KOBJ_ADD);
+		break;
+	case NETDEV_UP:
+		kobject_uevent(&netdev->dev.kobj, KOBJ_ONLINE);
+		break;
+	case NETDEV_DOWN:
+		kobject_uevent(&netdev->dev.kobj, KOBJ_OFFLINE);
+		break;
+	case NETDEV_CHANGE:
+		kobject_uevent(&netdev->dev.kobj, KOBJ_CHANGE);
+		break;
+	}
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block netdev_uevent_notifier = {
+	.notifier_call	= netdev_event,
+};
+
+static int __init netdev_uevent_init(void)
+{
+	return register_netdevice_notifier(&netdev_uevent_notifier);
+}
+device_initcall(netdev_uevent_init);
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ