2.4.27-rc4 bridge fix
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 2.4.27-rc4 bridge fix
The problem was that the br_add_bridge ended up calling register_netdev that did a rtnl_lock. This fixes that, and gets rid of the bridge_list, there is no need to keep a separate device list of just bridges. By not having multiple lists, races are avoided.
net/bridge/br_if.c +27 -43
@@ -23,8 +23,6 @@#include <asm/uaccess.h> #include "br_private.h" -static struct net_bridge *bridge_list; -static int br_initial_port_cost (struct net_device *dev) {if (!strncmp (dev->name,"lec" ,3 ))
@@ -70,22 +68,6 @@ static int __br_del_if(struct net_bridgereturn 0 ; } -static struct net_bridge **__find_br (char *name) -{ -struct net_bridge **b; -struct net_bridge *br; - - b = &bridge_list; -while ((br = *b) !=NULL ) { -if (!strncmp (br->dev.name, name,IFNAMSIZ )) -return b; - - b = &(br->next); - } - -return NULL ; -} -static void del_ifs (struct net_bridge *br) {br_write_lock_bh (BR_NETPROTO_LOCK );
@@ -178,42 +160,48 @@ static struct net_bridge_port *new_nbp(sint br_add_bridge (char *name) {struct net_bridge *br; +struct net_device *dev; +int err;if ((br =new_nb (name)) ==NULL )return -ENOMEM ; -if (__dev_get_by_name (name) !=NULL ) { -kfree (br); -return -EEXIST ; + dev = &br->dev; +if (strchr (dev->name,'%' )) { + err =dev_alloc_name (dev, dev->name); +if (err <0 ) + goto out; } - br->next = bridge_list; - bridge_list = br; + err =register_netdevice (dev); +if (err ==0 ) +br_inc_use_count (); -br_inc_use_count (); -register_netdev (&br->dev); - -return 0 ; + out: +return err; }int br_del_bridge (char *name) { -struct net_bridge **b; +struct net_device *dev;struct net_bridge *br; -if ((b =__find_br (name)) ==NULL ) + dev =__dev_get_by_name (name); +if (!dev)return -ENXIO ; - br = *b; +if (dev->hard_start_xmit != br_dev_xmit) +return -EPERM ; -if (br->dev.flags &IFF_UP ) +if (dev->flags &IFF_UP )return -EBUSY ; -del_ifs (br); + br = dev->priv; +BUG_ON (&br->dev != dev); - *b = br->next; +del_ifs (br); -unregister_netdev (&br->dev); +unregister_netdevice (dev);kfree (br);br_dec_use_count ();
@@ -271,16 +259,12 @@ int br_del_if(struct net_bridge *br, strint br_get_bridge_ifindices (int *indices,int num) { -struct net_bridge *br; -int i; - - br = bridge_list; -for (i=0 ;i<num;i++) { -if (br ==NULL ) -break ; +struct net_device *dev; +int i =0 ; - indices[i] = br->dev.ifindex; - br = br->next; +for (dev = dev_base; i < num && dev !=NULL ; dev = dev->next) { +if (dev->hard_start_xmit == br_dev_xmit) + indices[i++] = dev->ifindex; }return i;
net/bridge/br_ioctl.c +1 -6
@@ -250,14 +250,9 @@ int br_ioctl_deviceless_stub(unsigned loint br_ioctl (struct net_bridge *br,unsigned int cmd,unsigned long arg0,unsigned long arg1,unsigned long arg2) { -int err; -if (!capable (CAP_NET_ADMIN ))return -EPERM ;ASSERT_RTNL (); - err =br_ioctl_deviceless (cmd, arg0, arg1); -if (err == -EOPNOTSUPP ) - err =br_ioctl_device (br, cmd, arg0, arg1, arg2); -return err; +return br_ioctl_device (br, cmd, arg0, arg1, arg2); }
net/bridge/br_private.h +0 -1
@@ -79,7 +79,6 @@ struct net_bridge_portstruct net_bridge { -struct net_bridge *next;rwlock_t lock;struct net_bridge_port *port_list;struct net_device dev;
Quoted 4 lines · On Mon, 2 Aug 2004 13:08:40 -0700 Stephen Hemminger <[email protected]> wrote:
The problem was that the
br_add_bridgeended up callingregister_netdevthat did artnl_lock. This fixes that, and gets rid of thebridge_list, there is no need to keep a separate device list of just bridges. By not having multiple lists, races are avoided.
Marcelo, please apply this.
Thanks.
Quoted 4 lines
The problem was that the
br_add_bridgeended up callingregister_netdevthat did artnl_lock. This fixes that, and gets rid of thebridge_list, there is no need to keep a separate device list of just bridges. By not having multiple lists, races are avoided.
Ok, this time it looks ok, it seems to fix the problem I had reported for rc3 and also the one itroduced by the patch that was applied on rc4 to fix it, so far everything seems to work ok now.
Thanks for fixing this.
Regards...
Signature · 1 line
Manty/BestiaTester -> http://manty.net