summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Mochel <mochel@osdl.org>2003-01-06 01:50:37 -0600
committerPatrick Mochel <mochel@osdl.org>2003-01-06 01:50:37 -0600
commit6ed6b9bf5b5d80581ebfcc3fa2738ee386b78cd1 (patch)
tree8519dd91154bf4dac9367c392a89fcb8840c1750
parent426f67ebf9dab281a43bb5ff07c23713e7eefe95 (diff)
net devices: Get network devices to show up in sysfs.
- declare net_subsys, and register during net_dev_init(). - Add kobject to struct net_device. - initialize name and register in register_netdevice(). - remove in unregister_netdevice(). This allows one to see the registered network devices in the system via: # tree /sys/net/ /sys/net/ `-- eth0
-rw-r--r--include/linux/netdevice.h4
-rw-r--r--net/core/dev.c15
2 files changed, 17 insertions, 2 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 513b89ca7836..888d520fd319 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -28,6 +28,7 @@
#include <linux/if.h>
#include <linux/if_ether.h>
#include <linux/if_packet.h>
+#include <linux/kobject.h>
#include <asm/atomic.h>
#include <asm/cache.h>
@@ -438,6 +439,9 @@ struct net_device
/* this will get initialized at each interface type init routine */
struct divert_blk *divert;
#endif /* CONFIG_NET_DIVERT */
+
+ /* generic object representation */
+ struct kobject kobj;
};
diff --git a/net/core/dev.c b/net/core/dev.c
index 72f606980694..9b5ee08067eb 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -201,6 +201,8 @@ int netdev_fastroute;
int netdev_fastroute_obstacles;
#endif
+static struct subsystem net_subsys;
+
/*******************************************************************************
@@ -2545,7 +2547,10 @@ int register_netdevice(struct net_device *dev)
notifier_call_chain(&netdev_chain, NETDEV_REGISTER, dev);
net_run_sbin_hotplug(dev, "register");
- ret = 0;
+
+ snprintf(dev->kobj.name,KOBJ_NAME_LEN,dev->name);
+ kobj_set_kset_s(dev,net_subsys);
+ ret = kobject_register(&dev->kobj);
out:
return ret;
@@ -2638,7 +2643,7 @@ int unregister_netdevice(struct net_device *dev)
/* Shutdown queueing discipline. */
dev_shutdown(dev);
-
+
net_run_sbin_hotplug(dev, "unregister");
/* Notify protocols, that we are about to destroy
@@ -2671,6 +2676,8 @@ int unregister_netdevice(struct net_device *dev)
goto out;
}
+ kobject_unregister(&dev->kobj);
+
/* Last reference is our one */
if (atomic_read(&dev->refcnt) == 1)
goto out;
@@ -2749,6 +2756,8 @@ extern void ip_auto_config(void);
extern void dv_init(void);
#endif /* CONFIG_NET_DIVERT */
+static decl_subsys(net,NULL);
+
/*
* This is called single threaded during boot, so no need
@@ -2764,6 +2773,8 @@ static int __init net_dev_init(void)
if (dev_proc_init())
goto out;
+ subsystem_register(&net_subsys);
+
#ifdef CONFIG_NET_DIVERT
dv_init();
#endif /* CONFIG_NET_DIVERT */