From d10202dee84756acff0be7144bbf0dd3f415f57a Mon Sep 17 00:00:00 2001 From: Gris Ge Date: Tue, 30 Aug 2022 22:54:44 +0800 Subject: [PATCH] nm: Fix moving bridge port to bond When moving bridge port with VLAN filtering setting to bond, we got failure: A connection with a 'bridge-port' setting must have the slave-type set to 'bridge'. Instead it is 'bond' The root cause is we forgot to remove `NmSettingBridgePort` when detaching port away from bridge. The fix is remove `NmSettingBridgePort` and `NmSettingOvsBridgeInterface` if not bridge port or OVS interface anymore. Integration test cases for linux bridge and OVS bridge are included. Signed-off-by: Gris Ge (cherry picked from commit d2c40c3aade1d7764b84f0aafe8d3d907bb1c4a6) --- rust/src/lib/nm/connection.rs | 8 ++++++++ tests/integration/linux_bridge_test.py | 15 ++++++++++++++- tests/integration/ovs_test.py | 20 +++++++++++++++++++- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/rust/src/lib/nm/connection.rs b/rust/src/lib/nm/connection.rs index 7fbf2631..91bd9077 100644 --- a/rust/src/lib/nm/connection.rs +++ b/rust/src/lib/nm/connection.rs @@ -279,6 +279,14 @@ pub(crate) fn iface_to_nm_connections( _ => (), }; + if nm_conn.controller_type() != Some(NM_SETTING_BRIDGE_SETTING_NAME) { + nm_conn.bridge_port = None; + } + + if nm_conn.controller_type() != Some(NM_SETTING_OVS_PORT_SETTING_NAME) { + nm_conn.ovs_iface = None; + } + if let Some(Interface::LinuxBridge(br_iface)) = ctrl_iface { gen_nm_br_port_setting(br_iface, &mut nm_conn); } -- 2.38.1