From ff9c477f3238aeca9b8ca2e0805d419a449ea4d9 Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Tue, 18 Feb 2020 18:30:19 +0100
Subject: [PATCH] ifcfg: fix writer when changing OVS slave to clear previous
settings
We need to reset the OVS_PORT and OVS_PORT_UUID variables.
Otherwise, clearing the slave type doesn't work.
On master this is solved differently, by automatically clearing all
variables that are not explicitly set.
Reproducer:
nmcli con del t-eth1
nmcli con add type ethernet autoconnect no ifname eth1 master port0 con-name t-eth1 slave-type ovs-port
echo "
remove ovs-interface
remove connection.master
remove connection.slave-type
print
save
quit
" | nmcli c edit t-eth1
nmcli con show t-eth1 | grep 'ovs\|slave-type'
Fixes: 1440fe6a8804 ('ifcfg: don't forget master of ovs interfaces')
https://bugzilla.redhat.com/show_bug.cgi?id=1804167
(cherry picked from commit 0c8046574e782ca926d265348d10866f1653aef1)
---
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
index f328cc8f0..90a1a2b8f 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
@@ -1923,6 +1923,8 @@ write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg)
svSetValueStr (ifcfg, "BRIDGE", NULL);
svSetValueStr (ifcfg, "TEAM_MASTER_UUID", NULL);
svSetValueStr (ifcfg, "TEAM_MASTER", NULL);
+ svSetValueStr (ifcfg, "OVS_PORT_UUID", NULL);
+ svSetValueStr (ifcfg, "OVS_PORT", NULL);
master = nm_setting_connection_get_master (s_con);
if (master) {
--
2.24.1