Skip to content

Commit

Permalink
Merge branch 'net-Fix-bridge-enslavement-failure'
Browse files Browse the repository at this point in the history
Ido Schimmel says:

====================
net: Fix bridge enslavement failure

Patch #1 fixes an issue in which an upper netdev cannot be enslaved to a
bridge when it has multiple netdevs with different parent identifiers
beneath it.

Patch #2 adds a test case using two netdevsim instances.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
davem330 committed Sep 10, 2020
2 parents 9d3b2d3 + 6374a56 commit cdaa7a7
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -8647,7 +8647,7 @@ int dev_get_port_parent_id(struct net_device *dev,
if (!first.id_len)
first = *ppid;
else if (memcmp(&first, ppid, sizeof(*ppid)))
return -ENODATA;
return -EOPNOTSUPP;
}

return err;
Expand Down
47 changes: 47 additions & 0 deletions tools/testing/selftests/net/rtnetlink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,51 @@ kci_test_neigh_get()
echo "PASS: neigh get"
}

kci_test_bridge_parent_id()
{
local ret=0
sysfsnet=/sys/bus/netdevsim/devices/netdevsim
probed=false

if [ ! -w /sys/bus/netdevsim/new_device ] ; then
modprobe -q netdevsim
check_err $?
if [ $ret -ne 0 ]; then
echo "SKIP: bridge_parent_id can't load netdevsim"
return $ksft_skip
fi
probed=true
fi

echo "10 1" > /sys/bus/netdevsim/new_device
while [ ! -d ${sysfsnet}10 ] ; do :; done
echo "20 1" > /sys/bus/netdevsim/new_device
while [ ! -d ${sysfsnet}20 ] ; do :; done
udevadm settle
dev10=`ls ${sysfsnet}10/net/`
dev20=`ls ${sysfsnet}20/net/`

ip link add name test-bond0 type bond mode 802.3ad
ip link set dev $dev10 master test-bond0
ip link set dev $dev20 master test-bond0
ip link add name test-br0 type bridge
ip link set dev test-bond0 master test-br0
check_err $?

# clean up any leftovers
ip link del dev test-br0
ip link del dev test-bond0
echo 20 > /sys/bus/netdevsim/del_device
echo 10 > /sys/bus/netdevsim/del_device
$probed && rmmod netdevsim

if [ $ret -ne 0 ]; then
echo "FAIL: bridge_parent_id"
return 1
fi
echo "PASS: bridge_parent_id"
}

kci_test_rtnl()
{
local ret=0
Expand Down Expand Up @@ -1224,6 +1269,8 @@ kci_test_rtnl()
check_err $?
kci_test_neigh_get
check_err $?
kci_test_bridge_parent_id
check_err $?

kci_del_dummy
return $ret
Expand Down

0 comments on commit cdaa7a7

Please sign in to comment.