mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-24 21:50:17 +01: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
|
||||
set_connection_type(NmCli *nmc,
|
||||
NMConnection *con,
|
||||
|
|
@ -4516,10 +4546,8 @@ set_connection_type(NmCli *nmc,
|
|||
gboolean allow_reset,
|
||||
GError **error)
|
||||
{
|
||||
const NMMetaSettingValidPartItem *const *type_settings;
|
||||
const NMMetaSettingValidPartItem *const *slv_settings;
|
||||
GError *local = NULL;
|
||||
const char *slave_type = NULL;
|
||||
GError *local = NULL;
|
||||
const char *slave_type = NULL;
|
||||
|
||||
value = check_valid_name_toplevel(value, &slave_type, &local);
|
||||
if (!value) {
|
||||
|
|
@ -4544,16 +4572,6 @@ set_connection_type(NmCli *nmc,
|
|||
error)) {
|
||||
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,
|
||||
|
|
@ -4565,13 +4583,7 @@ set_connection_type(NmCli *nmc,
|
|||
error))
|
||||
return FALSE;
|
||||
|
||||
if (!con_settings(con, &type_settings, &slv_settings, error))
|
||||
return FALSE;
|
||||
|
||||
ensure_settings(con, slv_settings);
|
||||
ensure_settings(con, type_settings);
|
||||
|
||||
return TRUE;
|
||||
return enable_type_settings_and_options(con, error);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue