public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC] network devices generating uevents?
@ 2008-11-21 21:46 Stephen Hemminger
  2008-11-22  1:24 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2008-11-21 21:46 UTC (permalink / raw)
  To: netdev

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@vyatta.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);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC] network devices generating uevents?
  2008-11-21 21:46 [RFC] network devices generating uevents? Stephen Hemminger
@ 2008-11-22  1:24 ` David Miller
  2008-11-22  7:35   ` Jeff Kirsher
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2008-11-22  1:24 UTC (permalink / raw)
  To: shemminger; +Cc: netdev

From: Stephen Hemminger <shemminger@vyatta.com>
Date: Fri, 21 Nov 2008 13:46:59 -0800

> 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...

I'm fine with this, what do others think?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC] network devices generating uevents?
  2008-11-22  1:24 ` David Miller
@ 2008-11-22  7:35   ` Jeff Kirsher
  0 siblings, 0 replies; 3+ messages in thread
From: Jeff Kirsher @ 2008-11-22  7:35 UTC (permalink / raw)
  To: David Miller; +Cc: shemminger, netdev

On Fri, Nov 21, 2008 at 5:24 PM, David Miller <davem@davemloft.net> wrote:
> From: Stephen Hemminger <shemminger@vyatta.com>
> Date: Fri, 21 Nov 2008 13:46:59 -0800
>
>> 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...
>
> I'm fine with this, what do others think?
> --

Looks fine to me, thanks to Stephen for taking my suggestion and
running with it.

-- 
Cheers,
Jeff

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-11-22  7:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-21 21:46 [RFC] network devices generating uevents? Stephen Hemminger
2008-11-22  1:24 ` David Miller
2008-11-22  7:35   ` Jeff Kirsher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox