2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-29 15:28:56 +00:00

datapath: Prepare to extend lifetime of kobjects.

The following commit will move the initialization of the datapath and
net_bridge_port kobjects earlier and the destruction later, without
changing when those kobjects are attached to sysfs.  To do so, the
initialization of kobjects and attaching to sysfs has to be done as
separate steps.  That's already the case for net_bridge_port kobjects, and
this commit makes it so for datapath kobjects too.

This commit also simplifies some code, since the split API exists both
before and after 2.6.25, but the combined functions changed names.

Also, in dp_sysfs_add_if() call kobject_init() after initializing the
kset member, since kobject_init() expects that.  This makes no actual
difference in this case since the kobj is obtained from kzalloc(), but
it still seems better.
This commit is contained in:
Ben Pfaff
2009-08-05 13:45:13 -07:00
parent 2ba9026e2f
commit 3de35df914
2 changed files with 6 additions and 16 deletions

View File

@@ -487,26 +487,19 @@ int dp_sysfs_add_dp(struct datapath *dp)
}
/* Create /sys/class/net/<devname>/bridge directory. */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
kobject_set_name(&dp->ifobj, SYSFS_BRIDGE_PORT_SUBDIR); /* "bridge" */
dp->ifobj.ktype = NULL;
dp->ifobj.kset = NULL;
dp->ifobj.parent = kobj;
kboject_init(&dp->ifobj);
err = kobject_register(&dp->ifobj);
err = kobject_add(&dp->ifobj);
if (err) {
pr_info("%s: can't add kobject (directory) %s/%s\n",
__FUNCTION__, dp_name(dp), dp->ifobj.name);
goto out2;
}
#else
br->ifobj = kobject_create_and_add(SYSFS_BRIDGE_PORT_SUBDIR, kobj);
if (!br->ifobj) {
pr_info("%s: can't add kobject (directory) %s/%s\n",
__func__, dp_name(dp), SYSFS_BRIDGE_PORT_SUBDIR);
goto out2;
}
#endif
kobject_uevent(&dp->ifobj, KOBJ_ADD);
return 0;
out2:
@@ -519,11 +512,8 @@ int dp_sysfs_del_dp(struct datapath *dp)
{
struct kobject *kobj = to_kobj(dp->ports[ODPP_LOCAL]->dev);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
kobject_unregister(&dp->ifobj);
#else
kobject_put(dp->ifobj);
#endif
kobject_del(&dp->ifobj);
kobject_put(&dp->ifobj);
sysfs_remove_group(kobj, &bridge_group);
return 0;

View File

@@ -290,11 +290,11 @@ int dp_sysfs_add_if(struct net_bridge_port *p)
int err;
/* Create /sys/class/net/<devname>/brport directory. */
kobject_init(&p->kobj);
kobject_set_name(&p->kobj, SYSFS_BRIDGE_PORT_ATTR); /* "brport" */
p->kobj.ktype = &brport_ktype;
p->kobj.kset = NULL;
p->kobj.parent = &(p->dev->class_dev.kobj);
kobject_init(&p->kobj);
err = kobject_add(&p->kobj);
if (err)