mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 21:38:32 +08:00
bridge: fix hang on removal of bridge via netlink
Need to cleanup bridge device timers and ports when being bridge device is being removed via netlink. This fixes the problem of observed when doing: ip link add br0 type bridge ip link set dev eth1 master br0 ip link set br0 up ip link del br0 which would cause br0 to hang in unregister_netdev because of leftover reference count. Reported-by: Sridhar Samudrala <sri@us.ibm.com> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Acked-by: Sridhar Samudrala <sri@us.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
ae2a458315
commit
1ce5cce895
@ -161,9 +161,10 @@ static void del_nbp(struct net_bridge_port *p)
|
|||||||
call_rcu(&p->rcu, destroy_nbp_rcu);
|
call_rcu(&p->rcu, destroy_nbp_rcu);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* called with RTNL */
|
/* Delete bridge device */
|
||||||
static void del_br(struct net_bridge *br, struct list_head *head)
|
void br_dev_delete(struct net_device *dev, struct list_head *head)
|
||||||
{
|
{
|
||||||
|
struct net_bridge *br = netdev_priv(dev);
|
||||||
struct net_bridge_port *p, *n;
|
struct net_bridge_port *p, *n;
|
||||||
|
|
||||||
list_for_each_entry_safe(p, n, &br->port_list, list) {
|
list_for_each_entry_safe(p, n, &br->port_list, list) {
|
||||||
@ -268,7 +269,7 @@ int br_del_bridge(struct net *net, const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
del_br(netdev_priv(dev), NULL);
|
br_dev_delete(dev, NULL);
|
||||||
|
|
||||||
rtnl_unlock();
|
rtnl_unlock();
|
||||||
return ret;
|
return ret;
|
||||||
@ -449,7 +450,7 @@ void __net_exit br_net_exit(struct net *net)
|
|||||||
rtnl_lock();
|
rtnl_lock();
|
||||||
for_each_netdev(net, dev)
|
for_each_netdev(net, dev)
|
||||||
if (dev->priv_flags & IFF_EBRIDGE)
|
if (dev->priv_flags & IFF_EBRIDGE)
|
||||||
del_br(netdev_priv(dev), &list);
|
br_dev_delete(dev, &list);
|
||||||
|
|
||||||
unregister_netdevice_many(&list);
|
unregister_netdevice_many(&list);
|
||||||
rtnl_unlock();
|
rtnl_unlock();
|
||||||
|
@ -210,6 +210,7 @@ static struct rtnl_link_ops br_link_ops __read_mostly = {
|
|||||||
.priv_size = sizeof(struct net_bridge),
|
.priv_size = sizeof(struct net_bridge),
|
||||||
.setup = br_dev_setup,
|
.setup = br_dev_setup,
|
||||||
.validate = br_validate,
|
.validate = br_validate,
|
||||||
|
.dellink = br_dev_delete,
|
||||||
};
|
};
|
||||||
|
|
||||||
int __init br_netlink_init(void)
|
int __init br_netlink_init(void)
|
||||||
|
@ -294,6 +294,7 @@ static inline int br_is_root_bridge(const struct net_bridge *br)
|
|||||||
|
|
||||||
/* br_device.c */
|
/* br_device.c */
|
||||||
extern void br_dev_setup(struct net_device *dev);
|
extern void br_dev_setup(struct net_device *dev);
|
||||||
|
extern void br_dev_delete(struct net_device *dev, struct list_head *list);
|
||||||
extern netdev_tx_t br_dev_xmit(struct sk_buff *skb,
|
extern netdev_tx_t br_dev_xmit(struct sk_buff *skb,
|
||||||
struct net_device *dev);
|
struct net_device *dev);
|
||||||
#ifdef CONFIG_NET_POLL_CONTROLLER
|
#ifdef CONFIG_NET_POLL_CONTROLLER
|
||||||
|
Loading…
Reference in New Issue
Block a user