GNOME Bugzilla – Bug 744711
[RFE] in-memory connections should be handled by a new setting plugin "mem", not duplicating functionality in keyfile, ifcfg-rh
Last modified: 2019-07-17 11:22:43 UTC
Currently both ifcfg-rh and keyfile plugin support in-memory-only connections. this duplicates functionality and makes the code more complicated. It would be better to have a new setting plug "mem" that is (like keyfile) always present. And NMSettings would have special knowledge about mem-connections: - add_connection(save_to_disk=false), would directly store the connection inside "mem" -- which always succeeds. - persisting an mem-connection would remove it from mem plugin, and call add_connection() on one of the other setting plugins. this also fixes the following unexpected behavior: - add in-memory connection that is writable by ifcfg-rh - modify it, so that it is no longer supported by ifcfg-rh - persistate
So the problem to solve here, and the reason it wasn't done this way originally, is that every NMConnection is an instance of a specific plugin's NMSettingConnection subclass. So if the user wants to persist a 'mem' connection, that NMMemConnection would have to somehow be copied to an NMKeyfileConnection so that it could be saved. But then, any device using that connection would still have a reference to the old NMMemConnection and not the new NMKeyfileConnection. Also when the 'mem' connection was removed from the plugin (since we cannot have two connections with the same UUID) it will trigger a disconnect of the Device because the active connection has been removed. I think it's simpler to just live with some of the code duplication, than try to work around the remove-connection-deactivates and to try to update all the existing references to the 'mem' connection. But maybe you can come up with some ideas to work around all this...
(In reply to Dan Williams from comment #1) > But maybe you can come up with some ideas to work around all this... I think the solution is not to use inheritance, but composition. We shouldn't have NMKeyfileConnection, NMIfnetConnection, etc. Instead there should only be NMSettingsConnection, that has a reference to the backend -- "NMSettingsBackend".
this got now fixed by commit [1]. See also the merge request [2]. As this is a large rework, expect some fall out and there will be follow-up fixes necessary... [1] https://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=d35d3c468a304c3e0e78b4b068d105b1d753876c [2] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/189