diff options
author | Jan Vaclav <jvaclav@redhat.com> | 2023-07-19 12:34:59 +0200 |
---|---|---|
committer | Fernando Fernandez Mancera <ffmancera@riseup.net> | 2023-07-25 14:18:22 +0200 |
commit | 16f3e6430780464066db1abad182317fa32c6e2b (patch) | |
tree | 03d7c6d9cc0a380d4294619efe51ace482996e15 | |
parent | e8a2306afbcd3e328f62004af92cd21b2477f0ac (diff) |
nmcli: replace occurrences of master/slave with controller/port in internal code
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1334
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1697
-rw-r--r-- | src/nmcli/connections.c | 311 | ||||
-rw-r--r-- | src/nmcli/devices.c | 52 | ||||
-rw-r--r-- | src/nmcli/general.c | 4 | ||||
-rw-r--r-- | src/nmcli/settings.c | 4 | ||||
-rw-r--r-- | src/nmcli/utils.h | 4 |
5 files changed, 186 insertions, 189 deletions
diff --git a/src/nmcli/connections.c b/src/nmcli/connections.c index 5a8ed2a8d9..d6413c91f5 100644 --- a/src/nmcli/connections.c +++ b/src/nmcli/connections.c @@ -776,7 +776,7 @@ _metagen_con_show_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) if (ac) return nm_object_get_path(NM_OBJECT(ac)); return NULL; - case NMC_GENERIC_INFO_TYPE_CON_SHOW_SLAVE: + case NMC_GENERIC_INFO_TYPE_CON_SHOW_PORT: if (!s_con) return NULL; return nm_setting_connection_get_slave_type(s_con); @@ -807,7 +807,7 @@ const NmcMetaGenericInfo *const metagen_con_show[_NMC_GENERIC_INFO_TYPE_CON_SHOW _METAGEN_CON_SHOW(NMC_GENERIC_INFO_TYPE_CON_SHOW_DEVICE, "DEVICE"), _METAGEN_CON_SHOW(NMC_GENERIC_INFO_TYPE_CON_SHOW_STATE, "STATE"), _METAGEN_CON_SHOW(NMC_GENERIC_INFO_TYPE_CON_SHOW_ACTIVE_PATH, "ACTIVE-PATH"), - _METAGEN_CON_SHOW(NMC_GENERIC_INFO_TYPE_CON_SHOW_SLAVE, "SLAVE"), + _METAGEN_CON_SHOW(NMC_GENERIC_INFO_TYPE_CON_SHOW_PORT, "SLAVE"), _METAGEN_CON_SHOW(NMC_GENERIC_INFO_TYPE_CON_SHOW_FILENAME, "FILENAME"), }; #define NMC_FIELDS_CON_SHOW_COMMON "NAME,UUID,TYPE,DEVICE" @@ -893,8 +893,8 @@ _metagen_con_active_general_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS) /* this is really ugly, because the zone is not a property of the active-connection, * but the settings-connection profile. There is no guarantee, that they agree. */ return s_con ? nm_setting_connection_get_zone(s_con) : NULL; - case NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_MASTER_PATH: - dev = nm_active_connection_get_master(ac); + case NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_CONTROLLER_PATH: + dev = nm_active_connection_get_controller(ac); return dev ? nm_object_get_path(NM_OBJECT(dev)) : NULL; default: break; @@ -922,7 +922,7 @@ const NmcMetaGenericInfo "DBUS-PATH"), _METAGEN_CON_ACTIVE_GENERAL(NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_CON_PATH, "CON-PATH"), _METAGEN_CON_ACTIVE_GENERAL(NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_ZONE, "ZONE"), - _METAGEN_CON_ACTIVE_GENERAL(NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_MASTER_PATH, + _METAGEN_CON_ACTIVE_GENERAL(NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_CONTROLLER_PATH, "MASTER-PATH"), }; @@ -3495,19 +3495,19 @@ do_connection_down(const NMCCommand *cmd, NmCli *nmc, int argc, const char *cons /*****************************************************************************/ /* - * Return the most appropriate name for the connection of a type 'name' possibly with given 'slave_type' + * Return the most appropriate name for the connection of a type 'name' possibly with given 'port_type' * if exists, else return the 'name'. The returned string must not be freed. */ static const char * -get_name_alias_toplevel(const char *name, const char *slave_type) +get_name_alias_toplevel(const char *name, const char *port_type) { const NMMetaSettingInfoEditor *setting_info; - if (slave_type) { - const char *slave_name; + if (port_type) { + const char *port_name; - if (nm_meta_setting_info_valid_parts_for_slave_type(slave_type, &slave_name)) - return slave_name ?: name; + if (nm_meta_setting_info_valid_parts_for_slave_type(port_type, &port_name)) + return port_name ?: name; return name; } @@ -3526,7 +3526,7 @@ get_name_alias_toplevel(const char *name, const char *slave_type) */ static char * get_valid_options_string(const NMMetaSettingValidPartItem *const *array, - const NMMetaSettingValidPartItem *const *array_slv) + const NMMetaSettingValidPartItem *const *array_port) { const NMMetaSettingValidPartItem *const *iter = array; GString *str; @@ -3534,7 +3534,7 @@ get_valid_options_string(const NMMetaSettingValidPartItem *const *array, str = g_string_sized_new(150); - for (i = 0; i < 2; i++, iter = array_slv) { + for (i = 0; i < 2; i++, iter = array_port) { for (; iter && *iter; iter++) { const NMMetaSettingInfoEditor *setting_info = (*iter)->setting_info; @@ -3614,7 +3614,7 @@ _construct_property_name(const char *setting_name, /* get_valid_properties_string: * @array: base properties for the current connection type - * @array_slv: slave properties (or ipv4/ipv6 ones) for the current connection type + * @array_port: port properties (or ipv4/ipv6 ones) for the current connection type * @modifier: to prepend to each element of the returned list * @prefix: only properties matching the prefix will be returned * @postfix: required prefix on the property args; if a empty string is passed, is @@ -3628,7 +3628,7 @@ _construct_property_name(const char *setting_name, */ static char * get_valid_properties_string(const NMMetaSettingValidPartItem *const *array, - const NMMetaSettingValidPartItem *const *array_slv, + const NMMetaSettingValidPartItem *const *array_port, NMMetaAccessorModifier modifier, const char *prefix, const char *postfix) @@ -3643,7 +3643,7 @@ get_valid_properties_string(const NMMetaSettingValidPartItem *const *array, str = g_string_sized_new(1024); - for (i = 0; i < 2; i++, iter = array_slv) { + for (i = 0; i < 2; i++, iter = array_port) { for (; !full_match && iter && *iter; iter++) { const NMMetaSettingInfoEditor *setting_info = (*iter)->setting_info; @@ -3696,7 +3696,7 @@ get_valid_properties_string(const NMMetaSettingValidPartItem *const *array, /* * Check if 'val' is valid string in either array->name or array->alias for - * both array parameters (array & array_slv). + * both array parameters (array & array_port). * It accepts shorter string provided they are not ambiguous. * 'val' == NULL doesn't hurt. * @@ -3706,7 +3706,7 @@ get_valid_properties_string(const NMMetaSettingValidPartItem *const *array, static const char * check_valid_name(const char *val, const NMMetaSettingValidPartItem *const *array, - const NMMetaSettingValidPartItem *const *array_slv, + const NMMetaSettingValidPartItem *const *array_port, GError **error) { const NMMetaSettingValidPartItem *const *iter; @@ -3720,7 +3720,7 @@ check_valid_name(const char *val, /* Create a temporary array that can be used in nmc_string_is_valid() */ tmp_arr = g_ptr_array_sized_new(32); iter = array; - for (i = 0; i < 2; i++, iter = array_slv) { + for (i = 0; i < 2; i++, iter = array_port) { for (; iter && *iter; iter++) { const NMMetaSettingInfoEditor *setting_info = (*iter)->setting_info; @@ -3740,7 +3740,7 @@ check_valid_name(const char *val, /* We want to handle aliases, so construct own error message */ gs_free char *err_str = NULL; - err_str = get_valid_options_string(array, array_slv); + err_str = get_valid_options_string(array, array_port); g_set_error(error, 1, 0, _("'%s' not among [%s]"), val, err_str); g_clear_error(&tmp_err); } @@ -3749,7 +3749,7 @@ check_valid_name(const char *val, /* Return a pointer to the found string in passed 'array' */ iter = array; - for (i = 0; i < 2; i++, iter = array_slv) { + for (i = 0; i < 2; i++, iter = array_port) { for (; iter && *iter; iter++) { const NMMetaSettingInfoEditor *setting_info = (*iter)->setting_info; @@ -3766,7 +3766,7 @@ check_valid_name(const char *val, } static const char * -check_valid_name_toplevel(const char *val, const char **slave_type, GError **error) +check_valid_name_toplevel(const char *val, const char **port_type, GError **error) { gs_unref_ptrarray GPtrArray *tmp_arr = NULL; const NMMetaSettingInfoEditor *setting_info; @@ -3774,7 +3774,7 @@ check_valid_name_toplevel(const char *val, const char **slave_type, GError **err const char *str; int i; - NM_SET_OUT(slave_type, NULL); + NM_SET_OUT(port_type, NULL); /* Create a temporary array that can be used in nmc_string_is_valid() */ tmp_arr = g_ptr_array_sized_new(32); @@ -3805,13 +3805,13 @@ check_valid_name_toplevel(const char *val, const char **slave_type, GError **err } if (nm_streq(str, "bond-slave")) { - NM_SET_OUT(slave_type, NM_SETTING_BOND_SETTING_NAME); + NM_SET_OUT(port_type, NM_SETTING_BOND_SETTING_NAME); return NM_SETTING_WIRED_SETTING_NAME; } else if (nm_streq(str, "bridge-slave")) { - NM_SET_OUT(slave_type, NM_SETTING_BRIDGE_SETTING_NAME); + NM_SET_OUT(port_type, NM_SETTING_BRIDGE_SETTING_NAME); return NM_SETTING_WIRED_SETTING_NAME; } else if (nm_streq(str, "team-slave")) { - NM_SET_OUT(slave_type, NM_SETTING_TEAM_SETTING_NAME); + NM_SET_OUT(port_type, NM_SETTING_TEAM_SETTING_NAME); return NM_SETTING_WIRED_SETTING_NAME; } @@ -3859,45 +3859,45 @@ is_setting_mandatory(NMConnection *connection, NMSetting *setting) /*****************************************************************************/ static const char * -_strip_master_prefix(const char *master, const char *(**func)(NMConnection *) ) +_strip_controller_prefix(const char *controller, const char *(**func)(NMConnection *) ) { - if (!master) + if (!controller) return NULL; - if (g_str_has_prefix(master, "ifname/")) { - master = master + strlen("ifname/"); + if (g_str_has_prefix(controller, "ifname/")) { + controller = controller + strlen("ifname/"); if (func) *func = nm_connection_get_interface_name; - } else if (g_str_has_prefix(master, "uuid/")) { - master = master + strlen("uuid/"); + } else if (g_str_has_prefix(controller, "uuid/")) { + controller = controller + strlen("uuid/"); if (func) *func = nm_connection_get_uuid; - } else if (g_str_has_prefix(master, "id/")) { - master = master + strlen("id/"); + } else if (g_str_has_prefix(controller, "id/")) { + controller = controller + strlen("id/"); if (func) *func = nm_connection_get_id; } - return master; + return controller; } -/* normalized_master_for_slave: +/* normalized_controller_for_port: * @connections: list af all connections - * @master: UUID, ifname or ID of the master connection + * @controller: UUID, ifname or ID of the controller connection * @type: virtual connection type (bond, team, bridge, ...) or %NULL * @out_type: type of the connection that matched * - * Check whether master is a valid interface name, UUID or ID of some connection, + * Check whether controller is a valid interface name, UUID or ID of some connection, * possibly of a specified @type. * First UUID and ifname are checked. If they don't match, ID is checked * and replaced by UUID on a match. * - * Returns: identifier of master connection if found, %NULL otherwise + * Returns: identifier of controller connection if found, %NULL otherwise */ static const char * -normalized_master_for_slave(const GPtrArray *connections, - const char *master, - const char *type, - const char **out_type) +normalized_controller_for_port(const GPtrArray *connections, + const char *controller, + const char *type, + const char **out_type) { NMConnection *connection; NMSettingConnection *s_con; @@ -3905,13 +3905,13 @@ normalized_master_for_slave(const GPtrArray *connections, guint i; const char *found_by_id = NULL; const char *out_type_by_id = NULL; - const char *out_master = NULL; + const char *out_controller = NULL; const char *(*func)(NMConnection *) = NULL; - if (!master) + if (!controller) return NULL; - master = _strip_master_prefix(master, &func); + controller = _strip_controller_prefix(controller, &func); for (i = 0; i < connections->len; i++) { connection = NM_CONNECTION(connections->pdata[i]); s_con = nm_connection_get_setting_connection(connection); @@ -3921,46 +3921,46 @@ normalized_master_for_slave(const GPtrArray *connections, continue; if (func) { /* There was a prefix; only compare to that type. */ - if (nm_streq0(master, func(connection))) { + if (nm_streq0(controller, func(connection))) { if (out_type) *out_type = con_type; if (func == nm_connection_get_id) - out_master = nm_connection_get_uuid(connection); + out_controller = nm_connection_get_uuid(connection); else - out_master = master; + out_controller = controller; break; } } else { id = nm_connection_get_id(connection); uuid = nm_connection_get_uuid(connection); ifname = nm_connection_get_interface_name(connection); - if (NM_IN_STRSET(master, uuid, ifname)) { - out_master = master; + if (NM_IN_STRSET(controller, uuid, ifname)) { + out_controller = controller; if (out_type) *out_type = con_type; break; } - if (!found_by_id && nm_streq0(master, id)) { + if (!found_by_id && nm_streq0(controller, id)) { out_type_by_id = con_type; found_by_id = uuid; } } } - if (!out_master) { - out_master = found_by_id; + if (!out_controller) { + out_controller = found_by_id; if (out_type) *out_type = out_type_by_id; } - if (!out_master) { - nmc_print(_("Warning: master='%s' doesn't refer to any existing profile.\n"), master); - out_master = master; + if (!out_controller) { + nmc_print(_("Warning: master='%s' doesn't refer to any existing profile.\n"), controller); + out_controller = controller; if (out_type) *out_type = type; } - return out_master; + return out_controller; } #define WORD_YES "yes" @@ -3987,13 +3987,12 @@ prompt_yes_no(gboolean default_yes, char *delim) static NMSetting * is_setting_valid(NMConnection *connection, const NMMetaSettingValidPartItem *const *valid_settings_main, - const NMMetaSettingValidPartItem *const *valid_settings_slave, + const NMMetaSettingValidPartItem *const *valid_settings_port, const char *setting) { const char *setting_name; - if (!(setting_name = - check_valid_name(setting, valid_settings_main, valid_settings_slave, NULL))) + if (!(setting_name = check_valid_name(setting, valid_settings_main, valid_settings_port, NULL))) return NULL; return nm_connection_get_setting_by_name(connection, setting_name); } @@ -4010,7 +4009,7 @@ is_property_valid(NMSetting *setting, const char *property, GError **error) } static char * -unique_master_iface_ifname(const GPtrArray *connections, const char *try_name) +unique_controller_iface_ifname(const GPtrArray *connections, const char *try_name) { char *new_name; guint num = 0; @@ -4058,7 +4057,7 @@ set_default_interface_name(NmCli *nmc, NMSettingConnection *s_con) gs_free char *ifname = NULL; connections = nmc_get_connections(nmc); - ifname = unique_master_iface_ifname(connections, default_name); + ifname = unique_controller_iface_ifname(connections, default_name); g_object_set(s_con, NM_SETTING_CONNECTION_INTERFACE_NAME, ifname, NULL); } } @@ -4411,26 +4410,26 @@ set_option(NmCli *nmc, /* * Return relevant NameItem[] tables for given connection (based on connection type - * and slave type. + * and port type). */ static gboolean con_settings(NMConnection *connection, const NMMetaSettingValidPartItem *const **type_settings, - const NMMetaSettingValidPartItem *const **slv_settings, + const NMMetaSettingValidPartItem *const **port_settings, GError **error) { const char *con_type; NMSettingConnection *s_con; g_return_val_if_fail(type_settings, FALSE); - g_return_val_if_fail(slv_settings, FALSE); + g_return_val_if_fail(port_settings, FALSE); s_con = nm_connection_get_setting_connection(connection); g_return_val_if_fail(s_con, FALSE); - con_type = nm_setting_connection_get_slave_type(s_con); - *slv_settings = nm_meta_setting_info_valid_parts_for_slave_type(con_type, NULL); - if (!*slv_settings) { + con_type = nm_setting_connection_get_slave_type(s_con); + *port_settings = nm_meta_setting_info_valid_parts_for_slave_type(con_type, NULL); + if (!*port_settings) { g_set_error(error, NMCLI_ERROR, NMC_RESULT_ERROR_USER_INPUT, @@ -4522,7 +4521,7 @@ static gboolean enable_type_settings_and_options(NmCli *nmc, NMConnection *con, GError **error) { const NMMetaSettingValidPartItem *const *type_settings; - const NMMetaSettingValidPartItem *const *slv_settings; + const NMMetaSettingValidPartItem *const *port_settings; NMSettingConnection *s_con; s_con = nm_connection_get_setting_connection(con); @@ -4548,10 +4547,10 @@ enable_type_settings_and_options(NmCli *nmc, NMConnection *con, GError **error) NULL); } - if (!con_settings(con, &type_settings, &slv_settings, error)) + if (!con_settings(con, &type_settings, &port_settings, error)) return FALSE; - ensure_settings(con, slv_settings); + ensure_settings(con, port_settings); ensure_settings(con, type_settings); /* For some software connection types we generate the interface name for the user. */ @@ -4568,10 +4567,10 @@ set_connection_type(NmCli *nmc, gboolean allow_reset, GError **error) { - GError *local = NULL; - const char *slave_type = NULL; + GError *local = NULL; + const char *port_type = NULL; - value = check_valid_name_toplevel(value, &slave_type, &local); + value = check_valid_name_toplevel(value, &port_type, &local); if (!value) { if (!allow_reset) return TRUE; @@ -4584,12 +4583,12 @@ set_connection_type(NmCli *nmc, return FALSE; } - if (slave_type) { + if (port_type) { if (!set_property(nmc->client, con, NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_SLAVE_TYPE, - slave_type, + port_type, NM_META_ACCESSOR_MODIFIER_SET, error)) { return FALSE; @@ -4634,16 +4633,16 @@ set_connection_iface(NmCli *nmc, } static gboolean -set_connection_master(NmCli *nmc, - NMConnection *con, - const OptionInfo *option, - const char *value, - gboolean allow_reset, - GError **error) +set_connection_controller(NmCli *nmc, + NMConnection *con, + const OptionInfo *option, + const char *value, + gboolean allow_reset, + GError **error) { const GPtrArray *connections; NMSettingConnection *s_con; - const char *slave_type; + const char *port_type; s_con = nm_connection_get_setting_connection(con); g_return_val_if_fail(s_con, FALSE); @@ -4658,15 +4657,15 @@ set_connection_master(NmCli *nmc, return FALSE; } - slave_type = nm_setting_connection_get_slave_type(s_con); + port_type = nm_setting_connection_get_slave_type(s_con); connections = nmc_get_connections(nmc); - value = normalized_master_for_slave(connections, value, slave_type, &slave_type); + value = normalized_controller_for_port(connections, value, port_type, &port_type); if (!set_property(nmc->client, con, NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_SLAVE_TYPE, - slave_type, + port_type, NM_META_ACCESSOR_MODIFIER_SET, error)) { return FALSE; @@ -4893,7 +4892,7 @@ _meta_abstract_get_option_info(const NMMetaAbstractInfo *abstract_info) OPTION_INFO(CONNECTION, NM_SETTING_CONNECTION_MASTER, "master", - set_connection_master, + set_connection_controller, NULL), OPTION_INFO(BLUETOOTH, NM_SETTING_BLUETOOTH_TYPE, @@ -4976,21 +4975,21 @@ complete_property_name(NmCli *nmc, { NMSettingConnection *s_con; const NMMetaSettingValidPartItem *const *valid_settings_main; - const NMMetaSettingValidPartItem *const *valid_settings_slave; + const NMMetaSettingValidPartItem *const *valid_settings_port; const char *connection_type = NULL; - const char *slave_type = NULL; + const char *port_type = NULL; gs_free char *word_list = NULL; NMMetaSettingType s; connection_type = nm_connection_get_connection_type(connection); s_con = nm_connection_get_setting_connection(connection); if (s_con) - slave_type = nm_setting_connection_get_slave_type(s_con); - valid_settings_main = get_valid_settings_array(connection_type); - valid_settings_slave = nm_meta_setting_info_valid_parts_for_slave_type(slave_type, NULL); + port_type = nm_setting_connection_get_slave_type(s_con); + valid_settings_main = get_valid_settings_array(connection_type); + valid_settings_port = nm_meta_setting_info_valid_parts_for_slave_type(port_type, NULL); word_list = get_valid_properties_string(valid_settings_main, - valid_settings_slave, + valid_settings_port, modifier, prefix, postfix); @@ -5184,13 +5183,13 @@ nmc_process_connection_properties(NmCli *nmc, gboolean allow_setting_removal, GError **error) { - /* First check if we have a slave-type, as this would mean we will not - * have ip properties but possibly others, slave-type specific. + /* First check if we have a port-type, as this would mean we will not + * have ip properties but possibly others, port-type specific. */ /* Go through arguments and set properties */ do { const NMMetaSettingValidPartItem *const *type_settings; - const NMMetaSettingValidPartItem *const *slv_settings; + const NMMetaSettingValidPartItem *const *port_settings; NMMetaAccessorModifier modifier; const char *option_orig; const char *option; @@ -5201,10 +5200,10 @@ nmc_process_connection_properties(NmCli *nmc, const char *chosen_option = NULL; NMMetaSettingType s; - if (!con_settings(connection, &type_settings, &slv_settings, error)) + if (!con_settings(connection, &type_settings, &port_settings, error)) return FALSE; - ensure_settings(connection, slv_settings); + ensure_settings(connection, port_settings); ensure_settings(connection, type_settings); if (*argc <= 0) { @@ -5261,9 +5260,9 @@ nmc_process_connection_properties(NmCli *nmc, (*argc)--; (*argv)++; - ss = is_setting_valid(connection, type_settings, slv_settings, setting_name); + ss = is_setting_valid(connection, type_settings, port_settings, setting_name); if (!ss) { - if (!check_valid_name(setting_name, type_settings, slv_settings, NULL)) { + if (!check_valid_name(setting_name, type_settings, port_settings, NULL)) { g_set_error(error, NMCLI_ERROR, NMC_RESULT_ERROR_USER_INPUT, @@ -5293,7 +5292,7 @@ nmc_process_connection_properties(NmCli *nmc, complete_property_name(nmc, connection, modifier, option_sett, option_prop); option_sett_expanded = - check_valid_name(option_sett, type_settings, slv_settings, &local); + check_valid_name(option_sett, type_settings, port_settings, &local); if (!option_sett_expanded) { g_set_error(error, NMCLI_ERROR, @@ -5334,7 +5333,7 @@ nmc_process_connection_properties(NmCli *nmc, if (!check_valid_name(nm_meta_setting_infos[s].setting_name, type_settings, - slv_settings, + port_settings, NULL)) continue; @@ -5926,8 +5925,8 @@ read_properties: if (nmc->ask) questionnaire_mandatory(nmc, connection); - /* Traditionally, we didn't ask for these options for ethernet slaves. They don't - * make much sense, since these are likely to be set by the master anyway. */ + /* Traditionally, we didn't ask for these options for ethernet ports. They don't + * make much sense, since these are likely to be set by the controller anyway. */ if (nm_setting_connection_get_slave_type(s_con)) { disable_options(NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_MTU); disable_options(NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_MAC_ADDRESS); @@ -5937,9 +5936,9 @@ read_properties: /* Connection id is special in that it's required but we don't insist * on getting it from the user -- we just make up something sensible. */ if (!nm_setting_connection_get_id(s_con)) { - const char *ifname = nm_setting_connection_get_interface_name(s_con); - const char *type = nm_setting_connection_get_connection_type(s_con); - const char *slave_type = nm_setting_connection_get_slave_type(s_con); + const char *ifname = nm_setting_connection_get_interface_name(s_con); + const char *type = nm_setting_connection_get_connection_type(s_con); + const char *port_type = nm_setting_connection_get_slave_type(s_con); /* If only bother when there's a type, which is not guaranteed at this point. * Otherwise, the validation will fail anyway. */ @@ -5950,8 +5949,8 @@ read_properties: connections = nmc_get_connections(nmc); try_name = - ifname ? g_strdup_printf("%s-%s", get_name_alias_toplevel(type, slave_type), ifname) - : g_strdup(get_name_alias_toplevel(type, slave_type)); + ifname ? g_strdup_printf("%s-%s", get_name_alias_toplevel(type, port_type), ifname) + : g_strdup(get_name_alias_toplevel(type, port_type)); default_name = nmc_unique_connection_name(connections, try_name); g_object_set(s_con, NM_SETTING_CONNECTION_ID, default_name, NULL); } @@ -6175,7 +6174,7 @@ gen_connection_types(const char *text) static char * gen_setting_names(const char *text, int state) { - static int list_idx, len, is_slv; + static int list_idx, len, is_port; const char *s_name, *a_name; const NMMetaSettingValidPartItem *const *valid_settings_arr; NMSettingConnection *s_con; @@ -6184,10 +6183,10 @@ gen_setting_names(const char *text, int state) if (!state) { list_idx = 0; len = strlen(text); - is_slv = 0; + is_port = 0; } - if (!is_slv) { + if (!is_port) { valid_settings_arr = get_valid_settings_array(nmc_tab_completion.con_type); if (list_idx >= NM_PTRARRAY_LEN(valid_settings_arr)) return NULL; @@ -6208,10 +6207,10 @@ gen_setting_names(const char *text, int state) /* Let's give a try to parameters related to slave type */ list_idx = 0; - is_slv = 1; + is_port = 1; } - /* is_slv */ + /* is_port */ s_con = nm_connection_get_setting_connection(nmc_tab_completion.connection); if (s_con) s_type = nm_setting_connection_get_slave_type(s_con); @@ -6247,9 +6246,9 @@ gen_property_names(const char *text, int state) const char *setting_name; char **strv = NULL; const NMMetaSettingValidPartItem *const *valid_settings_main; - const NMMetaSettingValidPartItem *const *valid_settings_slave; + const NMMetaSettingValidPartItem *const *valid_settings_port; const char *p1; - const char *slv_type; + const char *port_type; /* Try to get the setting from 'line' - setting_name.property */ p1 = strchr(line, '.'); @@ -6261,20 +6260,20 @@ gen_property_names(const char *text, int state) valid_settings_main = get_valid_settings_array(nmc_tab_completion.con_type); - /* Support autocompletion of slave-connection parameters - * guessing the slave type from the setting name already + /* Support autocompletion of port-connection parameters + * guessing the port type from the setting name already * typed (or autocompleted) */ if (nm_streq0(strv[0], NM_SETTING_TEAM_PORT_SETTING_NAME)) - slv_type = NM_SETTING_TEAM_SETTING_NAME; + port_type = NM_SETTING_TEAM_SETTING_NAME; else if (nm_streq0(strv[0], NM_SETTING_BRIDGE_PORT_SETTING_NAME)) - slv_type = NM_SETTING_BRIDGE_SETTING_NAME; + port_type = NM_SETTING_BRIDGE_SETTING_NAME; else if (nm_streq0(strv[0], NM_SETTING_BOND_PORT_SETTING_NAME)) - slv_type = NM_SETTING_BOND_SETTING_NAME; + port_type = NM_SETTING_BOND_SETTING_NAME; else - slv_type = NULL; - valid_settings_slave = nm_meta_setting_info_valid_parts_for_slave_type(slv_type, NULL); + port_type = NULL; + valid_settings_port = nm_meta_setting_info_valid_parts_for_slave_type(port_type, NULL); - setting_name = check_valid_name(strv[0], valid_settings_main, valid_settings_slave, NULL); + setting_name = check_valid_name(strv[0], valid_settings_main, valid_settings_port, NULL); if (setting_name) { setting = nm_meta_setting_info_editor_new_setting( nm_meta_setting_info_editor_find_by_name(setting_name, FALSE), @@ -6566,7 +6565,7 @@ get_setting_and_property(const char *prompt, char **property_out) { const NMMetaSettingValidPartItem *const *valid_settings_main; - const NMMetaSettingValidPartItem *const *valid_settings_slave; + const NMMetaSettingValidPartItem *const *valid_settings_port; gs_unref_object NMSetting *setting = NULL; gs_free char *property = NULL; NMSettingConnection *s_con; @@ -6583,10 +6582,10 @@ get_setting_and_property(const char *prompt, if (s_con) s_type = nm_setting_connection_get_slave_type(s_con); - valid_settings_main = get_valid_settings_array(nmc_tab_completion.con_type); - valid_settings_slave = nm_meta_setting_info_valid_parts_for_slave_type(s_type, NULL); + valid_settings_main = get_valid_settings_array(nmc_tab_completion.con_type); + valid_settings_port = nm_meta_setting_info_valid_parts_for_slave_type(s_type, NULL); - setting_name = check_valid_name(sett, valid_settings_main, valid_settings_slave, NULL); + setting_name = check_valid_name(sett, valid_settings_main, valid_settings_port, NULL); setting = nm_meta_setting_info_editor_new_setting( nm_meta_setting_info_editor_find_by_name(setting_name, FALSE), NM_META_ACCESSOR_SETTING_INIT_TYPE_DEFAULT); @@ -7763,13 +7762,13 @@ split_editor_main_cmd_args(const char *str, char **setting, char **property, cha static NMSetting * create_setting_by_name(const char *name, const NMMetaSettingValidPartItem *const *valid_settings_main, - const NMMetaSettingValidPartItem *const *valid_settings_slave) + const NMMetaSettingValidPartItem *const *valid_settings_port) { const char *setting_name; NMSetting *setting = NULL; /* Get a valid setting name */ - setting_name = check_valid_name(name, valid_settings_main, valid_settings_slave, NULL); + setting_name = check_valid_name(name, valid_settings_main, valid_settings_port, NULL); if (setting_name) { setting = nm_meta_setting_info_editor_new_setting( @@ -7783,7 +7782,7 @@ static const char * ask_check_setting(const NmcConfig *nmc_config, const char *arg, const NMMetaSettingValidPartItem *const *valid_settings_main, - const NMMetaSettingValidPartItem *const *valid_settings_slave, + const NMMetaSettingValidPartItem *const *valid_settings_port, const char *valid_settings_str) { gs_free char *setting_name_user = NULL; @@ -7800,7 +7799,7 @@ ask_check_setting(const NmcConfig *nmc_config, if (!(setting_name = check_valid_name(setting_name_user, valid_settings_main, - valid_settings_slave, + valid_settings_port, &err))) { nmc_print(_("Error: invalid setting name; %s\n"), err->message); g_clear_error(&err); @@ -7943,7 +7942,7 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty NmcEditorMainCmd cmd; gboolean cmd_loop = TRUE; const NMMetaSettingValidPartItem *const *valid_settings_main; - const NMMetaSettingValidPartItem *const *valid_settings_slave; + const NMMetaSettingValidPartItem *const *valid_settings_port; gs_free char *valid_settings_str = NULL; const char *s_type = NULL; gboolean temp_changes; @@ -7954,10 +7953,10 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty if (s_con) s_type = nm_setting_connection_get_slave_type(s_con); - valid_settings_main = get_valid_settings_array(connection_type); - valid_settings_slave = nm_meta_setting_info_valid_parts_for_slave_type(s_type, NULL); + valid_settings_main = get_valid_settings_array(connection_type); + valid_settings_port = nm_meta_setting_info_valid_parts_for_slave_type(s_type, NULL); - valid_settings_str = get_valid_options_string(valid_settings_main, valid_settings_slave); + valid_settings_str = get_valid_options_string(valid_settings_main, valid_settings_port); nmc_print(_("You may edit the following settings: %s\n"), valid_settings_str); menu_ctx.main_prompt = nmc_colorize(&nmc->nmc_config, NM_META_COLOR_PROMPT, BASE_PROMPT); @@ -8057,12 +8056,12 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty /* setting provided as "setting.property" */ ss = is_setting_valid(connection, valid_settings_main, - valid_settings_slave, + valid_settings_port, cmd_arg_s); if (!ss) { ss_created = create_setting_by_name(cmd_arg_s, valid_settings_main, - valid_settings_slave); + valid_settings_port); ss = ss_created; if (!ss) { nmc_print(_("Error: invalid setting argument '%s'; valid are [%s]\n"), @@ -8134,7 +8133,7 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty setting_name = ask_check_setting(&nmc->nmc_config, user_arg, valid_settings_main, - valid_settings_slave, + valid_settings_port, valid_settings_str); if (!setting_name) break; @@ -8235,12 +8234,12 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty if (user_s) { ss = is_setting_valid(connection, valid_settings_main, - valid_settings_slave, + valid_settings_port, user_s); if (!ss) { if (check_valid_name(user_s, valid_settings_main, - valid_settings_slave, + valid_settings_port, NULL)) { nmc_print(_("Setting '%s' is not present in the connection.\n"), user_s); @@ -8289,7 +8288,7 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty /* If the string is not a property, try it as a setting */ s_tmp = is_setting_valid(connection, valid_settings_main, - valid_settings_slave, + valid_settings_port, cmd_arg_p); if (s_tmp) { gs_free_error GError *local = NULL; @@ -8346,12 +8345,12 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty if (user_s) { ss = is_setting_valid(connection, valid_settings_main, - valid_settings_slave, + valid_settings_port, user_s); if (!ss) { ss = create_setting_by_name(user_s, valid_settings_main, - valid_settings_slave); + valid_settings_port); if (!ss) { nmc_print(_("Error: invalid setting argument '%s'; valid are [%s]\n"), user_s, @@ -8385,7 +8384,7 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty s_tmp = is_setting_valid(connection, valid_settings_main, - valid_settings_slave, + valid_settings_port, cmd_arg_p); if (s_tmp) print_setting_description(s_tmp); @@ -8417,7 +8416,7 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty s_name = check_valid_name(user_s, valid_settings_main, - valid_settings_slave, + valid_settings_port, NULL); if (!s_name) { nmc_print(_("Error: unknown setting: '%s'\n"), user_s); @@ -8451,7 +8450,7 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty NMSetting *s_tmp; s_tmp = is_setting_valid(connection, valid_settings_main, - valid_settings_slave, + valid_settings_port, cmd_arg_p); if (s_tmp) { /* Print the whole setting */ @@ -8800,7 +8799,7 @@ get_ethernet_device_name(NmCli *nmc) } static void -editor_init_new_connection(NmCli *nmc, NMConnection *connection, const char *slave_type) +editor_init_new_connection(NmCli *nmc, NMConnection *connection, const char *port_type) { NMSetting *setting, *base_setting; NMSettingConnection *s_con; @@ -8815,10 +8814,10 @@ editor_init_new_connection(NmCli *nmc, NMConnection *connection, const char *sla nmc_setting_connection_connect_handlers(s_con, connection); - if (slave_type) { + if (port_type) { const char *dev_ifname = get_ethernet_device_name(nmc); - /* For bond/team/bridge slaves add 'wired' setting */ + /* For bond/team/bridge ports add 'wired' setting */ setting = nm_setting_wired_new(); nm_connection_add_setting(connection, setting); @@ -8828,7 +8827,7 @@ editor_init_new_connection(NmCli *nmc, NMConnection *connection, const char *sla NM_SETTING_CONNECTION_MASTER, dev_ifname ?: "eth0", NM_SETTING_CONNECTION_SLAVE_TYPE, - slave_type, + port_type, NULL); } else { const NMMetaSettingInfoEditor *setting_info; @@ -9026,7 +9025,7 @@ do_connection_edit(const NMCCommand *cmd, NmCli *nmc, int argc, const char *cons editor_init_existing_connection(connection); } else { - const char *slave_type = NULL; + const char *port_type = NULL; gs_free char *uuid = NULL; gs_free char *default_name = NULL; gs_free char *tmp_str = NULL; @@ -9038,7 +9037,7 @@ do_connection_edit(const NMCCommand *cmd, NmCli *nmc, int argc, const char *cons return; } - connection_type = check_valid_name_toplevel(type, &slave_type, &err1); + connection_type = check_valid_name_toplevel(type, &port_type, &err1); tmp_str = get_valid_options_string_toplevel(); while (!connection_type) { @@ -9052,7 +9051,7 @@ do_connection_edit(const NMCCommand *cmd, NmCli *nmc, int argc, const char *cons type_ask = nmc_readline(&nmc->nmc_config, EDITOR_PROMPT_CON_TYPE); type = type_ask = nm_strstrip(type_ask); - connection_type = check_valid_name_toplevel(type_ask, &slave_type, &err1); + connection_type = check_valid_name_toplevel(type_ask, &port_type, &err1); } nm_clear_g_free(&tmp_str); @@ -9079,7 +9078,7 @@ do_connection_edit(const NMCCommand *cmd, NmCli *nmc, int argc, const char *cons nm_connection_add_setting(connection, NM_SETTING(s_con)); /* Initialize the new connection so that it is valid from the start */ - editor_init_new_connection(nmc, connection, slave_type); + editor_init_new_connection(nmc, connection, port_type); } /* nmcli runs the editor */ diff --git a/src/nmcli/devices.c b/src/nmcli/devices.c index 7b9eeb56ff..a56f0f819b 100644 --- a/src/nmcli/devices.c +++ b/src/nmcli/devices.c @@ -1470,32 +1470,30 @@ print_bond_bridge_info(NMDevice *device, const char *group_prefix, const char *one_field) { - const GPtrArray *slaves = NULL; - GString *slaves_str; + const GPtrArray *ports = NULL; + GString *ports_str; int idx; const NMMetaAbstractInfo *const *tmpl; NmcOutputField *arr; NMC_OUTPUT_DATA_DEFINE_SCOPED(out); - if (NM_IS_DEVICE_BOND(device)) - slaves = nm_device_bond_get_slaves(NM_DEVICE_BOND(device)); - else if (NM_IS_DEVICE_BRIDGE(device)) - slaves = nm_device_bridge_get_slaves(NM_DEVICE_BRIDGE(device)); + if (NM_IS_DEVICE_BOND(device) || NM_IS_DEVICE_BRIDGE(device)) + ports = nm_device_get_ports(device); else g_return_val_if_reached(FALSE); - slaves_str = g_string_new(NULL); - for (idx = 0; slaves && idx < slaves->len; idx++) { - NMDevice *slave = g_ptr_array_index(slaves, idx); - const char *iface = nm_device_get_iface(slave); + ports_str = g_string_new(NULL); + for (idx = 0; ports && idx < ports->len; idx++) { + NMDevice *port = g_ptr_array_index(ports, idx); + const char *iface = nm_device_get_iface(port); if (iface) { - g_string_append(slaves_str, iface); - g_string_append_c(slaves_str, ' '); + g_string_append(ports_str, iface); + g_string_append_c(ports_str, ' '); } } - if (slaves_str->len > 0) - g_string_truncate(slaves_str, slaves_str->len - 1); /* Chop off last space */ + if (ports_str->len > 0) + g_string_truncate(ports_str, ports_str->len - 1); /* Chop off last space */ tmpl = (const NMMetaAbstractInfo *const *) nmc_fields_dev_show_master_prop; out_indices = parse_output_fields(one_field, tmpl, FALSE, NULL, NULL); @@ -1504,7 +1502,7 @@ print_bond_bridge_info(NMDevice *device, arr = nmc_dup_fields_array(tmpl, NMC_OF_FLAG_SECTION_PREFIX); set_val_strc(arr, 0, group_prefix); /* i.e. BOND, TEAM, BRIDGE */ - set_val_str(arr, 1, g_string_free(slaves_str, FALSE)); + set_val_str(arr, 1, g_string_free(ports_str, FALSE)); g_ptr_array_add(out.output_data, arr); print_data_prepare_width(out.output_data); @@ -1535,30 +1533,30 @@ sanitize_team_config(const char *config) static gboolean print_team_info(NMDevice *device, NmCli *nmc, const char *group_prefix, const char *one_field) { - const GPtrArray *slaves = NULL; - GString *slaves_str; + const GPtrArray *ports = NULL; + GString *ports_str; int idx; const NMMetaAbstractInfo *const *tmpl; NmcOutputField *arr; NMC_OUTPUT_DATA_DEFINE_SCOPED(out); if (NM_IS_DEVICE_TEAM(device)) - slaves = nm_device_team_get_slaves(NM_DEVICE_TEAM(device)); + ports = nm_device_get_ports(device); else g_return_val_if_reached(FALSE); - slaves_str = g_string_new(NULL); - for (idx = 0; slaves && idx < slaves->len; idx++) { - NMDevice *slave = g_ptr_array_index(slaves, idx); - const char *iface = nm_device_get_iface(slave); + ports_str = g_string_new(NULL); + for (idx = 0; ports && idx < ports->len; idx++) { + NMDevice *port = g_ptr_array_index(ports, idx); + const char *iface = nm_device_get_iface(port); if (iface) { - g_string_append(slaves_str, iface); - g_string_append_c(slaves_str, ' '); + g_string_append(ports_str, iface); + g_string_append_c(ports_str, ' '); } } - if (slaves_str->len > 0) - g_string_truncate(slaves_str, slaves_str->len - 1); /* Chop off last space */ + if (ports_str->len > 0) + g_string_truncate(ports_str, ports_str->len - 1); /* Chop off last space */ tmpl = (const NMMetaAbstractInfo *const *) nmc_fields_dev_show_team_prop; out_indices = parse_output_fields(one_field, tmpl, FALSE, NULL, NULL); @@ -1567,7 +1565,7 @@ print_team_info(NMDevice *device, NmCli *nmc, const char *group_prefix, const ch arr = nmc_dup_fields_array(tmpl, NMC_OF_FLAG_SECTION_PREFIX); set_val_strc(arr, 0, group_prefix); /* TEAM */ - set_val_str(arr, 1, g_string_free(slaves_str, FALSE)); + set_val_str(arr, 1, g_string_free(ports_str, FALSE)); set_val_str(arr, 2, sanitize_team_config(nm_device_team_get_config(NM_DEVICE_TEAM(device)))); g_ptr_array_add(out.output_data, arr); diff --git a/src/nmcli/general.c b/src/nmcli/general.c index 26988cd82c..0d8ddc47fe 100644 --- a/src/nmcli/general.c +++ b/src/nmcli/general.c @@ -1415,11 +1415,11 @@ ac_overview(NmCli *nmc, NMActiveConnection *ac) NMIPConfig *ip; nm_auto_str_buf NMStrBuf str = NM_STR_BUF_INIT(NM_UTILS_GET_NEXT_REALLOC_SIZE_104, FALSE); - if (nm_active_connection_get_master(ac)) { + if (nm_active_connection_get_controller(ac)) { g_string_append_printf(outbuf, "%s %s, ", _("master"), - nm_device_get_iface(nm_active_connection_get_master(ac))); + nm_device_get_iface(nm_active_connection_get_controller(ac))); } if (nm_active_connection_get_vpn(ac)) g_string_append_printf(outbuf, "%s, ", _("VPN")); diff --git a/src/nmcli/settings.c b/src/nmcli/settings.c index 4c864d847f..5b818edbf9 100644 --- a/src/nmcli/settings.c +++ b/src/nmcli/settings.c @@ -254,7 +254,7 @@ wireless_band_channel_changed_cb(GObject *object, GParamSpec *pspec, gpointer us } static void -connection_master_changed_cb(GObject *object, GParamSpec *pspec, gpointer user_data) +connection_controller_changed_cb(GObject *object, GParamSpec *pspec, gpointer user_data) { NMSettingConnection *s_con = NM_SETTING_CONNECTION(object); NMConnection *connection = NM_CONNECTION(user_data); @@ -343,7 +343,7 @@ nmc_setting_connection_connect_handlers(NMSettingConnection *setting, NMConnecti g_signal_connect(setting, "notify::" NM_SETTING_CONNECTION_MASTER, - G_CALLBACK(connection_master_changed_cb), + G_CALLBACK(connection_controller_changed_cb), connection); } diff --git a/src/nmcli/utils.h b/src/nmcli/utils.h index 5d9449f54b..6c1fb1db1a 100644 --- a/src/nmcli/utils.h +++ b/src/nmcli/utils.h @@ -134,7 +134,7 @@ typedef enum { NMC_GENERIC_INFO_TYPE_CON_SHOW_DEVICE, NMC_GENERIC_INFO_TYPE_CON_SHOW_STATE, NMC_GENERIC_INFO_TYPE_CON_SHOW_ACTIVE_PATH, - NMC_GENERIC_INFO_TYPE_CON_SHOW_SLAVE, + NMC_GENERIC_INFO_TYPE_CON_SHOW_PORT, NMC_GENERIC_INFO_TYPE_CON_SHOW_FILENAME, _NMC_GENERIC_INFO_TYPE_CON_SHOW_NUM, @@ -150,7 +150,7 @@ typedef enum { NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_DBUS_PATH, NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_CON_PATH, NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_ZONE, - NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_MASTER_PATH, + NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_CONTROLLER_PATH, _NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_NUM, NMC_GENERIC_INFO_TYPE_CON_VPN_TYPE = 0, |