mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 12:28:11 +02:00
nmcli/connections: factor out code run after new connection's type is set
After the connection's type is set, some bookkeeping is necessary for the interactive (--ask) mode: appropriate setting need to be added and options enabled. Currently it happens in an option setter; which runs when the "type" options is present on the command line, or the value is set in a response to interactive mode: $ nmcli --ask c add type team $ nmcli --ask c add Connection type: team But not when the property is set directly: $ nmcli --ask c add connection.type team ** nm:ERROR:src/nmcli/connections.c:5648:connection_get_base_meta_setting_type: assertion failed: (base_setting) Bail out! nm:ERROR:src/nmcli/connections.c:5648:connection_get_base_meta_setting_type: assertion failed: (base_setting) Aborted (core dumped) This doesn't fix the issue -- a followup commit (hopefully) will.
This commit is contained in:
parent
b171dcec0d
commit
e3fa6dfd7f
1 changed files with 33 additions and 21 deletions
|
|
@ -4508,6 +4508,36 @@ gen_func_bond_lacp_rate(const char *text, int state)
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
enable_type_settings_and_options(NMConnection *con, GError **error)
|
||||||
|
{
|
||||||
|
const NMMetaSettingValidPartItem *const *type_settings;
|
||||||
|
const NMMetaSettingValidPartItem *const *slv_settings;
|
||||||
|
NMSettingConnection *s_con;
|
||||||
|
|
||||||
|
s_con = nm_connection_get_setting_connection(con);
|
||||||
|
g_return_val_if_fail(s_con, FALSE);
|
||||||
|
|
||||||
|
if (nm_setting_connection_get_slave_type(s_con))
|
||||||
|
enable_options(NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_MASTER, NULL);
|
||||||
|
|
||||||
|
if (NM_IN_STRSET(nm_setting_connection_get_connection_type(s_con),
|
||||||
|
NM_SETTING_BOND_SETTING_NAME,
|
||||||
|
NM_SETTING_TEAM_SETTING_NAME,
|
||||||
|
NM_SETTING_BRIDGE_SETTING_NAME,
|
||||||
|
NM_SETTING_VLAN_SETTING_NAME)) {
|
||||||
|
disable_options(NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!con_settings(con, &type_settings, &slv_settings, error))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
ensure_settings(con, slv_settings);
|
||||||
|
ensure_settings(con, type_settings);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
set_connection_type(NmCli *nmc,
|
set_connection_type(NmCli *nmc,
|
||||||
NMConnection *con,
|
NMConnection *con,
|
||||||
|
|
@ -4516,8 +4546,6 @@ set_connection_type(NmCli *nmc,
|
||||||
gboolean allow_reset,
|
gboolean allow_reset,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
const NMMetaSettingValidPartItem *const *type_settings;
|
|
||||||
const NMMetaSettingValidPartItem *const *slv_settings;
|
|
||||||
GError *local = NULL;
|
GError *local = NULL;
|
||||||
const char *slave_type = NULL;
|
const char *slave_type = NULL;
|
||||||
|
|
||||||
|
|
@ -4544,16 +4572,6 @@ set_connection_type(NmCli *nmc,
|
||||||
error)) {
|
error)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
enable_options(NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_MASTER, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ifname is mandatory for all connection types except virtual ones (bond, team, bridge, vlan) */
|
|
||||||
if (NM_IN_STRSET(value,
|
|
||||||
NM_SETTING_BOND_SETTING_NAME,
|
|
||||||
NM_SETTING_TEAM_SETTING_NAME,
|
|
||||||
NM_SETTING_BRIDGE_SETTING_NAME,
|
|
||||||
NM_SETTING_VLAN_SETTING_NAME)) {
|
|
||||||
disable_options(NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!set_property(nmc->client,
|
if (!set_property(nmc->client,
|
||||||
|
|
@ -4565,13 +4583,7 @@ set_connection_type(NmCli *nmc,
|
||||||
error))
|
error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!con_settings(con, &type_settings, &slv_settings, error))
|
return enable_type_settings_and_options(con, error);
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
ensure_settings(con, slv_settings);
|
|
||||||
ensure_settings(con, type_settings);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue