Thread (12 messages) 12 messages, 5 authors, 2008-11-26

Re: [PATCH] netdev: generate kobject uevent on network events.

From: Stephen Hemminger <hidden>
Date: 2008-11-24 20:06:48

On Mon, 24 Nov 2008 20:55:02 +0100
"Kay Sievers" [off-list ref] wrote:
On Mon, Nov 24, 2008 at 20:45, Stephen Hemminger [off-list ref] wrote:
quoted
It is easier for some applications to deal with text based interfaces
like uevent, rather than using netlink to listen for events.

Note, this does not deal with network namespaces but that is a generic
problem that already exists with kobjects (see rename events).

Signed-off-by: Stephen Hemminger <redacted>

---
 net/core/Makefile |    1
 net/core/uevent.c |   61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+)
--- a/net/core/Makefile 2008-11-24 08:40:10.000000000 -0800
+++ b/net/core/Makefile 2008-11-24 08:51:01.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-24 09:06:50.000000000 -0800
@@ -0,0 +1,60 @@
+/*
+ * 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>
+
+/*
+ * Generate uevent in response to nework device changes.
+ * NB: KOBJ_MOVE is already genereated by kobject_rename
+ */
+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;
Did you do anything else to prevent the duplicated add/remove events?
The core does send these already. I replied with a "udevadm monitor"
output to your earlier mail. Don't you see the duplicates on your box?

Thanks,
Kay
okay, then i'll just take it out of here.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help