Skip to content

Commit 3722a98

Browse files
committed
Merge branch 'rtnetlink-allow-to-enslave-with-one-msg-an-up-interface'
Nicolas Dichtel says: ==================== rtnetlink: allow to enslave with one msg an up interface The first patch fixes a regression, introduced in linux v6.1, by reverting a patch. The second patch adds a test to verify this API. ==================== Link: https://lore.kernel.org/r/20240108094103.2001224-1-nicolas.dichtel@6wind.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 8722014 + a159cbe commit 3722a98

2 files changed

Lines changed: 35 additions & 7 deletions

File tree

net/core/rtnetlink.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2899,20 +2899,20 @@ static int do_setlink(const struct sk_buff *skb,
28992899
call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
29002900
}
29012901

2902-
if (tb[IFLA_MASTER]) {
2903-
err = do_set_master(dev, nla_get_u32(tb[IFLA_MASTER]), extack);
2904-
if (err)
2905-
goto errout;
2906-
status |= DO_SETLINK_MODIFIED;
2907-
}
2908-
29092902
if (ifm->ifi_flags || ifm->ifi_change) {
29102903
err = dev_change_flags(dev, rtnl_dev_combine_flags(dev, ifm),
29112904
extack);
29122905
if (err < 0)
29132906
goto errout;
29142907
}
29152908

2909+
if (tb[IFLA_MASTER]) {
2910+
err = do_set_master(dev, nla_get_u32(tb[IFLA_MASTER]), extack);
2911+
if (err)
2912+
goto errout;
2913+
status |= DO_SETLINK_MODIFIED;
2914+
}
2915+
29162916
if (tb[IFLA_CARRIER]) {
29172917
err = dev_change_carrier(dev, nla_get_u8(tb[IFLA_CARRIER]));
29182918
if (err)

tools/testing/selftests/net/rtnetlink.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ ALL_TESTS="
2828
kci_test_neigh_get
2929
kci_test_bridge_parent_id
3030
kci_test_address_proto
31+
kci_test_enslave_bonding
3132
"
3233

3334
devdummy="test-dummy0"
@@ -1241,6 +1242,33 @@ kci_test_address_proto()
12411242
return $ret
12421243
}
12431244

1245+
kci_test_enslave_bonding()
1246+
{
1247+
local testns="testns"
1248+
local bond="bond123"
1249+
local dummy="dummy123"
1250+
local ret=0
1251+
1252+
run_cmd ip netns add "$testns"
1253+
if [ $ret -ne 0 ]; then
1254+
end_test "SKIP bonding tests: cannot add net namespace $testns"
1255+
return $ksft_skip
1256+
fi
1257+
1258+
run_cmd ip -netns $testns link add dev $bond type bond mode balance-rr
1259+
run_cmd ip -netns $testns link add dev $dummy type dummy
1260+
run_cmd ip -netns $testns link set dev $dummy up
1261+
run_cmd ip -netns $testns link set dev $dummy master $bond down
1262+
if [ $ret -ne 0 ]; then
1263+
end_test "FAIL: initially up interface added to a bond and set down"
1264+
ip netns del "$testns"
1265+
return 1
1266+
fi
1267+
1268+
end_test "PASS: enslave interface in a bond"
1269+
ip netns del "$testns"
1270+
}
1271+
12441272
kci_test_rtnl()
12451273
{
12461274
local current_test

0 commit comments

Comments
 (0)