diff mbox series

selftests: rtnetlink: Fix bridge_parent_id failure on interface state

Message ID 20250414172549.1691612-1-alok.a.tiwari@oracle.com (mailing list archive)
State New
Headers show
Series selftests: rtnetlink: Fix bridge_parent_id failure on interface state | expand

Commit Message

ALOK TIWARI April 14, 2025, 5:25 p.m. UTC
The selftest "kci_test_bridge_parent_id" fails with the error:
"Device can not be enslaved while up" when trying to attach interfaces
(`eni10np1`, `eni20np1`) to a bonding device (`test-bond0`) while the
interfaces are in the UP state.

Failure log:
COMMAND: ip link set dev eni10np1 master test-bond0
    Error: Device can not be enslaved while up.
COMMAND: ip link set dev eni20np1 master test-bond0
    Error: Device can not be enslaved while up.
FAIL: bridge_parent_id

This behavior aligns with bonding driver requirements, where a slave
interface must be in the DOWN state before being enslaved. This was
reinforced in upstream commit: 'ec4ffd100ffb ("Revert 'net: rtnetlink:
Enslave device before bringing it up'")'.

This patch updates the test to bring interfaces down explicitly before
adding them to the bonding device:

  ip link set dev <iface> master <bond> down

After applying this fix, the test passes successfully:

Success log:
COMMAND: ip link set dev eni10np1 master test-bond0 down
COMMAND: ip link set dev eni20np1 master test-bond0 down
PASS: bridge_parent_id

Fixes: 9c2a19f71515 ("kselftest: rtnetlink.sh: add verbose flag")
Note: This commit introduced 'run_cmd', which exposed this failure
in the bridge_parent_id test output.
Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
---
 tools/testing/selftests/net/rtnetlink.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Ido Schimmel April 15, 2025, 11:37 a.m. UTC | #1
On Mon, Apr 14, 2025 at 10:25:33AM -0700, Alok Tiwari wrote:
> The selftest "kci_test_bridge_parent_id" fails with the error:
> "Device can not be enslaved while up" when trying to attach interfaces
> (`eni10np1`, `eni20np1`) to a bonding device (`test-bond0`) while the
> interfaces are in the UP state.

Why are they up? The test creates the interfaces and never brings them
up.

It's most likely caused by some interface manager in your user space. I
suggest fixing that instead.

> 
> Failure log:
> COMMAND: ip link set dev eni10np1 master test-bond0
>     Error: Device can not be enslaved while up.
> COMMAND: ip link set dev eni20np1 master test-bond0
>     Error: Device can not be enslaved while up.
> FAIL: bridge_parent_id
> 
> This behavior aligns with bonding driver requirements, where a slave
> interface must be in the DOWN state before being enslaved. This was
> reinforced in upstream commit: 'ec4ffd100ffb ("Revert 'net: rtnetlink:
> Enslave device before bringing it up'")'.
> 
> This patch updates the test to bring interfaces down explicitly before
> adding them to the bonding device:

I don't see why the test needs to bring them down when it never brought
them up to begin with.
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh
index 2e8243a65b50..ddae704c8faa 100755
--- a/tools/testing/selftests/net/rtnetlink.sh
+++ b/tools/testing/selftests/net/rtnetlink.sh
@@ -1103,8 +1103,8 @@  kci_test_bridge_parent_id()
 	dev10=`ls ${sysfsnet}10/net/`
 	dev20=`ls ${sysfsnet}20/net/`
 	run_cmd ip link add name test-bond0 type bond mode 802.3ad
-	run_cmd ip link set dev $dev10 master test-bond0
-	run_cmd ip link set dev $dev20 master test-bond0
+	run_cmd ip link set dev $dev10 master test-bond0 down
+	run_cmd ip link set dev $dev20 master test-bond0 down
 	run_cmd ip link add name test-br0 type bridge
 	run_cmd ip link set dev test-bond0 master test-br0