nmcli: connection: don't overwrite port-type if explicitly set

When processing the "type" property we deduce the port-type in some
cases and set it. If the user has chosen a port-type we must not
overwrite it. In any case, we should raise an error when validating the
connection.

Fixes: c5324ed285 ('nmcli: streamline connection addition')
This commit is contained in:
Íñigo Huguet
2025-03-14 08:18:46 +01:00
committed by Íñigo Huguet
parent bb850fda0e
commit 6a133d10a1

View File

@@ -4616,8 +4616,11 @@ set_connection_type(NmCli *nmc,
gboolean allow_reset,
GError **error)
{
GError *local = NULL;
const char *port_type = NULL;
NMSettingConnection *s_con = nm_connection_get_setting_connection(con);
GError *local = NULL;
const char *port_type = NULL;
nm_assert(s_con);
value = check_valid_name_toplevel(value, &port_type, &local);
if (!value) {
@@ -4632,7 +4635,7 @@ set_connection_type(NmCli *nmc,
return FALSE;
}
if (port_type) {
if (!nm_setting_connection_get_port_type(s_con) && port_type) {
if (!set_property(nmc->client,
con,
NM_SETTING_CONNECTION_SETTING_NAME,