All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: linux-hotplug@vger.kernel.org
Subject: [RFC] network devices generating uevents?
Date: Sat, 22 Nov 2008 07:41:10 +0000	[thread overview]
Message-ID: <20081121234110.22b47154@extreme> (raw)

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);

             reply	other threads:[~2008-11-22  7:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-22  7:41 Stephen Hemminger [this message]
2008-11-22 14:08 ` [RFC] network devices generating uevents? Kay Sievers
2008-11-22 19:22 ` Karl O. Pinc
2008-11-23  2:13 ` Marcel Holtmann
2008-11-23  6:32 ` Stephen Hemminger
2008-11-23 16:13 ` Kay Sievers
2008-11-24 19:45   ` [PATCH] netdev: generate kobject uevent on network events Stephen Hemminger
2008-11-24 19:55     ` Kay Sievers
2008-11-24 20:06       ` Stephen Hemminger
2008-11-25  8:39         ` David Miller
2008-11-24 20:06     ` Ben Hutchings
2008-11-24 23:03       ` [PATCH] netdev: generate kobject uevent on network state Stephen Hemminger
2008-11-25  3:08         ` [PATCH] netdev: generate kobject uevent on network state transitions Kay Sievers
2008-11-25  3:51         ` Marcel Holtmann
2008-11-25  4:14           ` [PATCH] netdev: generate kobject uevent on network state Stephen Hemminger
2008-11-25  9:09             ` David Miller
2008-11-26  5:24               ` [PATCH] netdev: generate kobject uevent on network state transitions Marcel Holtmann
2008-11-26 12:09                 ` Kay Sievers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081121234110.22b47154@extreme \
    --to=shemminger@vyatta.com \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.