ofp-util: Work on decoding OF1.1 flow_mods.
[openvswitch] / datapath / dp_sysfs_if.c
index d35821b693d791e78c475692ab620c11764c484c..219a260683902c16265e255b8b5eab41380a8cd2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007-2011 Nicira Networks.
+ * Copyright (c) 2007-2012 Nicira, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of version 2 of the GNU General Public
@@ -191,12 +191,12 @@ static ssize_t brport_store(struct kobject *kobj,
                return -EPERM;
 
        pr_warning("%s: xxx writing port parms not supported yet!\n",
-                  dp_name(p->dp));
+                  ovs_dp_name(p->dp));
 
        return ret;
 }
 
-struct sysfs_ops brport_sysfs_ops = {
+struct sysfs_ops ovs_brport_sysfs_ops = {
        .show = brport_show,
        .store = brport_store,
 };
@@ -206,10 +206,10 @@ struct sysfs_ops brport_sysfs_ops = {
  * 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 datapath *dp = p->dp;
-       struct vport *local_port = rtnl_dereference(dp->ports[OVSP_LOCAL]);
+       struct vport *local_port = ovs_vport_rtnl(dp, OVSP_LOCAL);
        struct brport_attribute **a;
        int err;
 
@@ -217,6 +217,14 @@ int dp_sysfs_add_if(struct vport *p)
        if (!p->ops->get_kobj)
                return -ENOENT;
 
+#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)
@@ -254,7 +262,7 @@ err:
        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);