Skip to content

Commit 2c13a91

Browse files
liuhangbingregkh
authored andcommitted
bridge: check iface upper dev when setting master via ioctl
[ Upstream commit e8238fc ] When we set a bond slave's master to bridge via ioctl, we only check the IFF_BRIDGE_PORT flag. Although we will find the slave's real master at netdev_master_upper_dev_link() later, it already does some settings and allocates some resources. It would be better to return as early as possible. v1 -> v2: use netdev_master_upper_dev_get() instead of netdev_has_any_upper_dev() to check if we have a master, because not all upper devs are masters, e.g. vlan device. Reported-by: [email protected] Signed-off-by: Hangbin Liu <[email protected]> Acked-by: Nikolay Aleksandrov <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ece94a7 commit 2c13a91

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/bridge/br_if.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,8 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
503503
if (dev->netdev_ops->ndo_start_xmit == br_dev_xmit)
504504
return -ELOOP;
505505

506-
/* Device is already being bridged */
507-
if (br_port_exists(dev))
506+
/* Device has master upper dev */
507+
if (netdev_master_upper_dev_get(dev))
508508
return -EBUSY;
509509

510510
/* No bridging devices that dislike that (e.g. wireless) */

0 commit comments

Comments
 (0)