/*
- * Copyright (c) 2009, 2010 Nicira Networks.
- * Distributed under the terms of the GNU GPL version 2.
+ * Copyright (c) 2007-2012 Nicira, Inc.
*
- * Significant portions of this file may be copied from parts of the Linux
- * kernel, by Linus Torvalds and others.
- */
-
-/*
- * Sysfs attributes of bridge ports for Open vSwitch
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
*
- * This has been shamelessly copied from the kernel sources.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
return -EPERM;
pr_warning("%s: xxx writing port parms not supported yet!\n",
- dp_name(p->dp));
+ ovs_dp_name(p->dp));
return ret;
}
-const struct sysfs_ops brport_sysfs_ops = {
+struct sysfs_ops ovs_brport_sysfs_ops = {
.show = brport_show,
.store = brport_store,
};
* Creates a brport subdirectory with bridge attributes.
* Puts symlink in bridge's brport subdirectory
*/
-int dp_sysfs_add_if(struct vport *p)
+int ovs_dp_sysfs_add_if(struct vport *p)
{
- struct kobject *kobj = vport_get_kobj(p);
struct datapath *dp = p->dp;
+ struct vport *local_port = ovs_vport_rtnl(dp, OVSP_LOCAL);
struct brport_attribute **a;
int err;
/* Create /sys/class/net/<devname>/brport directory. */
- if (!kobj)
+ if (!p->ops->get_kobj)
return -ENOENT;
- err = kobject_add(&p->kobj, kobj, SYSFS_BRIDGE_PORT_ATTR);
+#ifdef CONFIG_NET_NS
+ /* Due to bug in 2.6.32 kernel, sysfs_create_group() could panic
+ * in other namespace than init_net. Following check is to avoid it. */
+
+ if (!p->kobj.sd)
+ return -ENOENT;
+#endif
+
+ err = kobject_add(&p->kobj, p->ops->get_kobj(p),
+ SYSFS_BRIDGE_PORT_ATTR);
if (err)
goto err;
/* Create symlink from /sys/class/net/<devname>/brport/bridge to
* /sys/class/net/<bridgename>. */
- err = sysfs_create_link(&p->kobj,
- vport_get_kobj(rtnl_dereference(dp->ports[OVSP_LOCAL])),
+ err = sysfs_create_link(&p->kobj, local_port->ops->get_kobj(local_port),
SYSFS_BRIDGE_PORT_LINK); /* "bridge" */
if (err)
goto err_del;
/* Create symlink from /sys/class/net/<bridgename>/brif/<devname> to
* /sys/class/net/<devname>/brport. */
- err = sysfs_create_link(&dp->ifobj, &p->kobj, vport_get_name(p));
+ err = sysfs_create_link(&dp->ifobj, &p->kobj, p->ops->get_name(p));
if (err)
goto err_del;
- strcpy(p->linkname, vport_get_name(p));
+ strcpy(p->linkname, p->ops->get_name(p));
kobject_uevent(&p->kobj, KOBJ_ADD);
return err;
}
-int dp_sysfs_del_if(struct vport *p)
+int ovs_dp_sysfs_del_if(struct vport *p)
{
if (p->linkname[0]) {
sysfs_remove_link(&p->dp->ifobj, p->linkname);