Revert crypto: prng - Deterministic CPRNG
[safe/jmp/linux-2.6] / net / bridge / br_sysfs_br.c
index ce10464..27d6a51 100644 (file)
@@ -147,16 +147,27 @@ static ssize_t show_stp_state(struct device *d,
        return sprintf(buf, "%d\n", br->stp_enabled);
 }
 
-static void set_stp_state(struct net_bridge *br, unsigned long val)
-{
-       br->stp_enabled = val;
-}
 
 static ssize_t store_stp_state(struct device *d,
                               struct device_attribute *attr, const char *buf,
                               size_t len)
 {
-       return store_bridge_parm(d, buf, len, set_stp_state);
+       struct net_bridge *br = to_bridge(d);
+       char *endp;
+       unsigned long val;
+
+       if (!capable(CAP_NET_ADMIN))
+               return -EPERM;
+
+       val = simple_strtoul(buf, &endp, 0);
+       if (endp == buf)
+               return -EINVAL;
+
+       rtnl_lock();
+       br_stp_set_enabled(br, val);
+       rtnl_unlock();
+
+       return len;
 }
 static DEVICE_ATTR(stp_state, S_IRUGO | S_IWUSR, show_stp_state,
                   store_stp_state);
@@ -309,6 +320,19 @@ static ssize_t store_group_addr(struct device *d,
 static DEVICE_ATTR(group_addr, S_IRUGO | S_IWUSR,
                   show_group_addr, store_group_addr);
 
+static ssize_t store_flush(struct device *d,
+                          struct device_attribute *attr,
+                          const char *buf, size_t len)
+{
+       struct net_bridge *br = to_bridge(d);
+
+       if (!capable(CAP_NET_ADMIN))
+               return -EPERM;
+
+       br_fdb_flush(br);
+       return len;
+}
+static DEVICE_ATTR(flush, S_IWUSR, NULL, store_flush);
 
 static struct attribute *bridge_attrs[] = {
        &dev_attr_forward_delay.attr,
@@ -328,6 +352,7 @@ static struct attribute *bridge_attrs[] = {
        &dev_attr_topology_change_timer.attr,
        &dev_attr_gc_timer.attr,
        &dev_attr_group_addr.attr,
+       &dev_attr_flush.attr,
        NULL
 };
 
@@ -342,8 +367,9 @@ static struct attribute_group bridge_group = {
  *
  * Returns the number of bytes read.
  */
-static ssize_t brforward_read(struct kobject *kobj, char *buf,
-                          loff_t off, size_t count)
+static ssize_t brforward_read(struct kobject *kobj,
+                             struct bin_attribute *bin_attr,
+                             char *buf, loff_t off, size_t count)
 {
        struct device *dev = to_dev(kobj);
        struct net_bridge *br = to_bridge(dev);
@@ -353,20 +379,19 @@ static ssize_t brforward_read(struct kobject *kobj, char *buf,
        if (off % sizeof(struct __fdb_entry) != 0)
                return -EINVAL;
 
-       n =  br_fdb_fillbuf(br, buf, 
+       n =  br_fdb_fillbuf(br, buf,
                            count / sizeof(struct __fdb_entry),
                            off / sizeof(struct __fdb_entry));
 
        if (n > 0)
                n *= sizeof(struct __fdb_entry);
-       
+
        return n;
 }
 
 static struct bin_attribute bridge_forward = {
        .attr = { .name = SYSFS_BRIDGE_FDB,
-                 .mode = S_IRUGO, 
-                 .owner = THIS_MODULE, },
+                 .mode = S_IRUGO, },
        .read = brforward_read,
 };
 
@@ -390,27 +415,21 @@ int br_sysfs_addbr(struct net_device *dev)
        err = sysfs_create_group(brobj, &bridge_group);
        if (err) {
                pr_info("%s: can't create group %s/%s\n",
-                       __FUNCTION__, dev->name, bridge_group.name);
+                       __func__, dev->name, bridge_group.name);
                goto out1;
        }
 
        err = sysfs_create_bin_file(brobj, &bridge_forward);
        if (err) {
                pr_info("%s: can't create attribute file %s/%s\n",
-                       __FUNCTION__, dev->name, bridge_forward.attr.name);
+                       __func__, dev->name, bridge_forward.attr.name);
                goto out2;
        }
 
-       
-       kobject_set_name(&br->ifobj, SYSFS_BRIDGE_PORT_SUBDIR);
-       br->ifobj.ktype = NULL;
-       br->ifobj.kset = NULL;
-       br->ifobj.parent = brobj;
-
-       err = kobject_register(&br->ifobj);
-       if (err) {
+       br->ifobj = kobject_create_and_add(SYSFS_BRIDGE_PORT_SUBDIR, brobj);
+       if (!br->ifobj) {
                pr_info("%s: can't add kobject (directory) %s/%s\n",
-                       __FUNCTION__, dev->name, br->ifobj.name);
+                       __func__, dev->name, SYSFS_BRIDGE_PORT_SUBDIR);
                goto out3;
        }
        return 0;
@@ -428,7 +447,7 @@ void br_sysfs_delbr(struct net_device *dev)
        struct kobject *kobj = &dev->dev.kobj;
        struct net_bridge *br = netdev_priv(dev);
 
-       kobject_unregister(&br->ifobj);
+       kobject_put(br->ifobj);
        sysfs_remove_bin_file(kobj, &bridge_forward);
        sysfs_remove_group(kobj, &bridge_group);
 }