Revert "bridge: Use hlist_for_each_entry_rcu() in br_multicast_add_router()"
[safe/jmp/linux-2.6] / net / bridge / br_sysfs_if.c
index 2da2292..0b99164 100644 (file)
@@ -29,8 +29,7 @@ struct brport_attribute {
 #define BRPORT_ATTR(_name,_mode,_show,_store)                  \
 struct brport_attribute brport_attr_##_name = {                \
        .attr = {.name = __stringify(_name),                    \
-                .mode = _mode,                                 \
-                .owner = THIS_MODULE, },                       \
+                .mode = _mode },                               \
        .show   = _show,                                        \
        .store  = _store,                                       \
 };
@@ -144,6 +143,37 @@ static ssize_t store_flush(struct net_bridge_port *p, unsigned long v)
 }
 static BRPORT_ATTR(flush, S_IWUSR, NULL, store_flush);
 
+static ssize_t show_hairpin_mode(struct net_bridge_port *p, char *buf)
+{
+       int hairpin_mode = (p->flags & BR_HAIRPIN_MODE) ? 1 : 0;
+       return sprintf(buf, "%d\n", hairpin_mode);
+}
+static ssize_t store_hairpin_mode(struct net_bridge_port *p, unsigned long v)
+{
+       if (v)
+               p->flags |= BR_HAIRPIN_MODE;
+       else
+               p->flags &= ~BR_HAIRPIN_MODE;
+       return 0;
+}
+static BRPORT_ATTR(hairpin_mode, S_IRUGO | S_IWUSR,
+                  show_hairpin_mode, store_hairpin_mode);
+
+#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
+static ssize_t show_multicast_router(struct net_bridge_port *p, char *buf)
+{
+       return sprintf(buf, "%d\n", p->multicast_router);
+}
+
+static ssize_t store_multicast_router(struct net_bridge_port *p,
+                                     unsigned long v)
+{
+       return br_multicast_set_port_router(p, v);
+}
+static BRPORT_ATTR(multicast_router, S_IRUGO | S_IWUSR, show_multicast_router,
+                  store_multicast_router);
+#endif
+
 static struct brport_attribute *brport_attrs[] = {
        &brport_attr_path_cost,
        &brport_attr_priority,
@@ -160,6 +190,10 @@ static struct brport_attribute *brport_attrs[] = {
        &brport_attr_forward_delay_timer,
        &brport_attr_hold_timer,
        &brport_attr_flush,
+       &brport_attr_hairpin_mode,
+#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
+       &brport_attr_multicast_router,
+#endif
        NULL
 };
 
@@ -190,7 +224,8 @@ static ssize_t brport_store(struct kobject * kobj,
 
        val = simple_strtoul(buf, &endp, 0);
        if (endp != buf) {
-               rtnl_lock();
+               if (!rtnl_trylock())
+                       return restart_syscall();
                if (p->dev && p->br && brport_attr->store) {
                        spin_lock_bh(&p->br->lock);
                        ret = brport_attr->store(p, val);
@@ -203,7 +238,7 @@ static ssize_t brport_store(struct kobject * kobj,
        return ret;
 }
 
-struct sysfs_ops brport_sysfs_ops = {
+const struct sysfs_ops brport_sysfs_ops = {
        .show = brport_show,
        .store = brport_store,
 };
@@ -230,7 +265,7 @@ int br_sysfs_addif(struct net_bridge_port *p)
                        goto out2;
        }
 
-       err= sysfs_create_link(&br->ifobj, &p->kobj, p->dev->name);
+       err = sysfs_create_link(br->ifobj, &p->kobj, p->dev->name);
 out2:
        return err;
 }