]> git.baikalelectronics.ru Git - kernel.git/commitdiff
bridge: switch order of rx_handler reg and upper dev link
authorJiri Pirko <jiri@resnulli.us>
Fri, 5 Sep 2014 13:51:28 +0000 (15:51 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 9 Sep 2014 18:29:54 +0000 (11:29 -0700)
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>
net/bridge/br_if.c

index 078d336a1f379f80d622e4fffa187630593827cf..a9f54a9b6690b181090fd15be8bf8e78c241fac4 100644 (file)
@@ -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);
@@ -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);
@@ -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: