Skip to content

Commit

Permalink
bridge: switch order of rx_handler reg and upper dev link
Browse files Browse the repository at this point in the history
The thing is that netdev_master_upper_dev_link calls
call_netdevice_notifiers(NETDEV_CHANGEUPPER, dev). That generates rtnl
link message and during that, rtnl_link_ops->fill_slave_info is called.
But with current ordering, rx_handler and IFF_BRIDGE_PORT are not set
yet so there would have to be check for that in fill_slave_info callback.

Resolve this by reordering to similar what bonding and team does to
avoid the check.

Also add removal of IFF_BRIDGE_PORT flag into error path.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jiri Pirko authored and David S. Miller committed Sep 9, 2014
1 parent 49a6015 commit 0f49579
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions net/bridge/br_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,12 @@ static void del_nbp(struct net_bridge_port *p)
br_fdb_delete_by_port(br, p, 1);
nbp_update_port_count(br);

netdev_upper_dev_unlink(dev, br->dev);

dev->priv_flags &= ~IFF_BRIDGE_PORT;

netdev_rx_handler_unregister(dev);

netdev_upper_dev_unlink(dev, br->dev);

br_multicast_del_port(p);

kobject_uevent(&p->kobj, KOBJ_REMOVE);
Expand Down Expand Up @@ -476,16 +476,16 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
if (err)
goto err3;

err = netdev_master_upper_dev_link(dev, br->dev);
err = netdev_rx_handler_register(dev, br_handle_frame, p);
if (err)
goto err4;

err = netdev_rx_handler_register(dev, br_handle_frame, p);
dev->priv_flags |= IFF_BRIDGE_PORT;

err = netdev_master_upper_dev_link(dev, br->dev);
if (err)
goto err5;

dev->priv_flags |= IFF_BRIDGE_PORT;

dev_disable_lro(dev);

list_add_rcu(&p->list, &br->port_list);
Expand Down Expand Up @@ -520,7 +520,8 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
return 0;

err5:
netdev_upper_dev_unlink(dev, br->dev);
dev->priv_flags &= ~IFF_BRIDGE_PORT;
netdev_rx_handler_unregister(dev);
err4:
br_netpoll_disable(p);
err3:
Expand Down

0 comments on commit 0f49579

Please sign in to comment.