mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-20 04:40:04 +01:00
release: bump version to 1.25.1-dev after 1.25.0 release
This commit is contained in:
commit
c6e51f61dd
106 changed files with 4704 additions and 2272 deletions
17
NEWS
17
NEWS
|
|
@ -1,3 +1,20 @@
|
|||
=============================================
|
||||
NetworkManager-1.26
|
||||
Overview of changes since NetworkManager-1.24
|
||||
=============================================
|
||||
|
||||
This is a snapshot of NetworkManager 1.26 development series.
|
||||
The API is subject to change and not guaranteed to be compatible
|
||||
with the later release.
|
||||
USE AT YOUR OWN RISK. NOT RECOMMENDED FOR PRODUCTION USE!
|
||||
|
||||
* Add MUD URL property for connection profiles (RFC 8520) and set it
|
||||
for DHCP and DHCPv6 requests.
|
||||
* IPv6 SLAAC: improved the reaction of IPv6 SLAAC to renumbering events:
|
||||
- honor PIO Valid Lifetimes < 2 hours.
|
||||
- cap the Preferred Lifetime of PIOs to the "Router Lifetime" value
|
||||
and the Valid Lifetime of PIOs to 48 * Router Lifetime.
|
||||
|
||||
=============================================
|
||||
NetworkManager-1.24
|
||||
Overview of changes since NetworkManager-1.22
|
||||
|
|
|
|||
|
|
@ -541,6 +541,8 @@ _metagen_con_show_get_fcn (NMC_META_GENERIC_INFO_GET_FCN_ARGS)
|
|||
if (info->info_type == NMC_GENERIC_INFO_TYPE_CON_SHOW_TIMESTAMP)
|
||||
return (*out_to_free = g_strdup_printf ("%" G_GUINT64_FORMAT, timestamp));
|
||||
else {
|
||||
struct tm localtime_result;
|
||||
|
||||
if (!timestamp) {
|
||||
if (get_type == NM_META_ACCESSOR_GET_TYPE_PRETTY)
|
||||
return _("never");
|
||||
|
|
@ -548,7 +550,7 @@ _metagen_con_show_get_fcn (NMC_META_GENERIC_INFO_GET_FCN_ARGS)
|
|||
}
|
||||
timestamp_real = timestamp;
|
||||
s_mut = g_malloc0 (128);
|
||||
strftime (s_mut, 64, "%c", localtime (×tamp_real));
|
||||
strftime (s_mut, 127, "%c", localtime_r (×tamp_real, &localtime_result));
|
||||
return (*out_to_free = s_mut);
|
||||
}
|
||||
}
|
||||
|
|
@ -1449,7 +1451,9 @@ nmc_active_connection_details (NMActiveConnection *acon, NmCli *nmc)
|
|||
gboolean was_output = FALSE;
|
||||
|
||||
if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "common") == 0) {
|
||||
/* pass */
|
||||
} else if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "all") == 0) {
|
||||
/* pass */
|
||||
} else
|
||||
fields_str = nmc->required_fields;
|
||||
|
||||
|
|
@ -2074,6 +2078,7 @@ do_connections_show (const NMCCommand *cmd, NmCli *nmc, int argc, const char *co
|
|||
if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "common") == 0)
|
||||
fields_str = NMC_FIELDS_CON_SHOW_COMMON;
|
||||
else if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "all") == 0) {
|
||||
/* pass */
|
||||
} else
|
||||
fields_str = nmc->required_fields;
|
||||
|
||||
|
|
@ -6280,7 +6285,7 @@ nmcli_editor_tab_completion (const char *text, int start, int end)
|
|||
rl_completion_append_character = '.';
|
||||
} else
|
||||
generator_func = gen_property_names;
|
||||
} else if (num >= 3) {
|
||||
} else {
|
||||
if (num == 3 && should_complete_files (NULL, line))
|
||||
rl_attempted_completion_over = 0;
|
||||
else if (should_complete_vpn_uuids (NULL, line)) {
|
||||
|
|
|
|||
|
|
@ -1436,6 +1436,7 @@ show_device_info (NMDevice *device, NmCli *nmc)
|
|||
if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "common") == 0)
|
||||
fields_str = NMC_FIELDS_DEV_SHOW_SECTIONS_COMMON;
|
||||
else if (g_ascii_strcasecmp (nmc->required_fields, "all") == 0) {
|
||||
/* pass */
|
||||
} else
|
||||
fields_str = nmc->required_fields;
|
||||
|
||||
|
|
@ -1749,6 +1750,7 @@ do_devices_status (const NMCCommand *cmd, NmCli *nmc, int argc, const char *cons
|
|||
if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "common") == 0)
|
||||
fields_str = "DEVICE,TYPE,STATE,CONNECTION";
|
||||
else if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "all") == 0) {
|
||||
/* pass */
|
||||
} else
|
||||
fields_str = nmc->required_fields;
|
||||
|
||||
|
|
@ -3149,6 +3151,7 @@ do_device_wifi_list (const NMCCommand *cmd, NmCli *nmc, int argc, const char *co
|
|||
if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "common") == 0)
|
||||
fields_str = NMC_FIELDS_DEV_WIFI_LIST_COMMON;
|
||||
else if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "all") == 0) {
|
||||
/* pass */
|
||||
} else
|
||||
fields_str = nmc->required_fields;
|
||||
|
||||
|
|
@ -4651,6 +4654,7 @@ do_device_lldp_list (const NMCCommand *cmd, NmCli *nmc, int argc, const char *co
|
|||
if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "common") == 0)
|
||||
fields_str = NMC_FIELDS_DEV_LLDP_LIST_COMMON;
|
||||
else if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "all") == 0) {
|
||||
/* pass */
|
||||
} else
|
||||
fields_str = nmc->required_fields;
|
||||
|
||||
|
|
|
|||
|
|
@ -545,7 +545,9 @@ print_permissions (void *user_data)
|
|||
}
|
||||
|
||||
if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "common") == 0) {
|
||||
/* pass */
|
||||
} else if (g_ascii_strcasecmp (nmc->required_fields, "all") == 0) {
|
||||
/* pass */
|
||||
} else
|
||||
fields_str = nmc->required_fields;
|
||||
|
||||
|
|
@ -694,7 +696,9 @@ show_general_logging (NmCli *nmc)
|
|||
};
|
||||
|
||||
if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "common") == 0) {
|
||||
/* pass */
|
||||
} else if (g_ascii_strcasecmp (nmc->required_fields, "all") == 0) {
|
||||
/* pass */
|
||||
} else
|
||||
fields_str = nmc->required_fields;
|
||||
|
||||
|
|
|
|||
|
|
@ -783,6 +783,17 @@ _coerce_str_emptyunset (NMMetaAccessorGetType get_type,
|
|||
return cstr;
|
||||
}
|
||||
|
||||
#define RETURN_STR_EMPTYUNSET(get_type, is_default, cstr) \
|
||||
G_STMT_START { \
|
||||
char *_str = NULL; \
|
||||
const char *_cstr; \
|
||||
\
|
||||
_cstr = _coerce_str_emptyunset ((get_type), (is_default), (cstr), &_str); \
|
||||
if (_str) \
|
||||
RETURN_STR_TO_FREE (_str); \
|
||||
RETURN_STR_TEMPORARY (_cstr); \
|
||||
} G_STMT_END
|
||||
|
||||
static gboolean
|
||||
_is_default (const NMMetaPropertyInfo *property_info,
|
||||
NMSetting *setting)
|
||||
|
|
@ -836,6 +847,19 @@ _get_fcn_gobject_impl (const NMMetaPropertyInfo *property_info,
|
|||
|| ( gtype_prop == G_TYPE_STRV
|
||||
&& !glib_handles_str_transform));
|
||||
|
||||
if (gtype_prop == G_TYPE_STRING) {
|
||||
nm_assert (glib_handles_str_transform);
|
||||
nm_assert (!handle_emptyunset);
|
||||
if ( property_info->property_typ_data
|
||||
&& property_info->property_typ_data->subtype.gobject_string.handle_emptyunset) {
|
||||
/* This string property can both be empty and NULL. We need to
|
||||
* signal them differently. */
|
||||
cstr = g_value_get_string (&val);
|
||||
nm_assert ((!!is_default) == (cstr == NULL));
|
||||
RETURN_STR_EMPTYUNSET (get_type, is_default, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (glib_handles_str_transform)
|
||||
RETURN_STR_TEMPORARY (g_value_get_string (&val));
|
||||
|
||||
|
|
@ -857,15 +881,9 @@ _get_fcn_gobject_impl (const NMMetaPropertyInfo *property_info,
|
|||
if (strv && strv[0])
|
||||
RETURN_STR_TO_FREE (g_strjoinv (",", (char **) strv));
|
||||
|
||||
/* special hack for handling properties that can be empty and unset
|
||||
* (see multilist.clear_emptyunset_fcn). */
|
||||
if (handle_emptyunset) {
|
||||
char *str = NULL;
|
||||
|
||||
cstr = _coerce_str_emptyunset (get_type, is_default, NULL, &str);
|
||||
if (str)
|
||||
RETURN_STR_TO_FREE (str);
|
||||
RETURN_STR_TEMPORARY (cstr);
|
||||
/* we need to express empty lists from unset lists differently. */
|
||||
RETURN_STR_EMPTYUNSET (get_type, is_default, NULL);
|
||||
}
|
||||
|
||||
return "";
|
||||
|
|
@ -1183,6 +1201,22 @@ _set_fcn_gobject_string (ARGS_SET_FCN)
|
|||
return _gobject_property_reset_default (setting, property_info->property_name);
|
||||
|
||||
if (property_info->property_typ_data) {
|
||||
if (property_info->property_typ_data->subtype.gobject_string.handle_emptyunset) {
|
||||
if ( value
|
||||
&& value[0]
|
||||
&& NM_STRCHAR_ALL (value, ch, ch == ' ')) {
|
||||
/* this string property can both be %NULL and empty. To express that, we coerce
|
||||
* a value of all whitespaces to dropping the first whitespace. That means,
|
||||
* " " gives "", " " gives " ", and so on.
|
||||
*
|
||||
* This way the user can set the string value to "" (meaning NULL) and to
|
||||
* " " (meaning ""), and any other string.
|
||||
*
|
||||
* This is and non-obvious escaping mechanism. But out of all the possible
|
||||
* solutions, it seems the most sensible one. */
|
||||
value++;
|
||||
}
|
||||
}
|
||||
if (property_info->property_typ_data->subtype.gobject_string.validate_fcn) {
|
||||
value = property_info->property_typ_data->subtype.gobject_string.validate_fcn (value, &to_free, error);
|
||||
if (!value)
|
||||
|
|
@ -3396,35 +3430,6 @@ _objlist_set_fcn_ip_config_routing_rules (NMSetting *setting,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gconstpointer
|
||||
_get_fcn_match_interface_name (ARGS_GET_FCN)
|
||||
{
|
||||
NMSettingMatch *s_match = NM_SETTING_MATCH (setting);
|
||||
GString *str = NULL;
|
||||
guint i, num;
|
||||
|
||||
RETURN_UNSUPPORTED_GET_TYPE ();
|
||||
|
||||
num = nm_setting_match_get_num_interface_names (s_match);
|
||||
for (i = 0; i < num; i++) {
|
||||
const char *name;
|
||||
|
||||
name = nm_setting_match_get_interface_name (s_match, i);
|
||||
if (!name || !name[0])
|
||||
continue;
|
||||
if (!str)
|
||||
str = g_string_new ("");
|
||||
else
|
||||
g_string_append_c (str, ESCAPED_TOKENS_WITH_SPACES_DELIMTER);
|
||||
nm_utils_escaped_tokens_escape_gstr (name, ESCAPED_TOKENS_WITH_SPACES_DELIMTERS, str);
|
||||
}
|
||||
|
||||
NM_SET_OUT (out_is_default, num == 0);
|
||||
if (!str)
|
||||
return NULL;
|
||||
RETURN_STR_TO_FREE (g_string_free (str, FALSE));
|
||||
}
|
||||
|
||||
static gconstpointer
|
||||
_get_fcn_olpc_mesh_ssid (ARGS_GET_FCN)
|
||||
{
|
||||
|
|
@ -4905,10 +4910,38 @@ static const NMMetaPropertyInfo *const property_infos_BRIDGE[] = {
|
|||
.prompt = N_("Group forward mask [0]"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_MULTICAST_HASH_MAX,
|
||||
.property_type = &_pt_gobject_int,
|
||||
.hide_if_default = TRUE,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_MULTICAST_LAST_MEMBER_COUNT,
|
||||
.property_type = &_pt_gobject_int,
|
||||
.hide_if_default = TRUE,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL,
|
||||
.property_type = &_pt_gobject_int,
|
||||
.hide_if_default = TRUE,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL,
|
||||
.property_type = &_pt_gobject_int,
|
||||
.hide_if_default = TRUE,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_MULTICAST_QUERIER,
|
||||
.property_type = &_pt_gobject_bool,
|
||||
.hide_if_default = TRUE,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_MULTICAST_QUERIER_INTERVAL,
|
||||
.property_type = &_pt_gobject_int,
|
||||
.hide_if_default = TRUE,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_MULTICAST_QUERY_INTERVAL,
|
||||
.property_type = &_pt_gobject_int,
|
||||
.hide_if_default = TRUE,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL,
|
||||
.property_type = &_pt_gobject_int,
|
||||
.hide_if_default = TRUE,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_MULTICAST_QUERY_USE_IFADDR,
|
||||
.property_type = &_pt_gobject_bool,
|
||||
.hide_if_default = TRUE,
|
||||
|
|
@ -4919,6 +4952,14 @@ static const NMMetaPropertyInfo *const property_infos_BRIDGE[] = {
|
|||
.prompt = N_("Enable IGMP snooping [no]"),
|
||||
.property_type = &_pt_gobject_bool,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT,
|
||||
.property_type = &_pt_gobject_int,
|
||||
.hide_if_default = TRUE,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL,
|
||||
.property_type = &_pt_gobject_int,
|
||||
.hide_if_default = TRUE,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_MULTICAST_ROUTER,
|
||||
.property_type = &_pt_gobject_string,
|
||||
.hide_if_default = TRUE,
|
||||
|
|
@ -5227,6 +5268,10 @@ static const NMMetaPropertyInfo *const property_infos_CONNECTION[] = {
|
|||
),
|
||||
),
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_CONNECTION_MUD_URL,
|
||||
.property_type = &_pt_gobject_string,
|
||||
.hide_if_default = TRUE,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_CONNECTION_WAIT_DEVICE_TIMEOUT,
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
|
|
@ -6120,11 +6165,7 @@ static const NMMetaPropertyInfo *const property_infos_MACVLAN[] = {
|
|||
#define _CURRENT_NM_META_SETTING_TYPE NM_META_SETTING_TYPE_MATCH
|
||||
static const NMMetaPropertyInfo *const property_infos_MATCH[] = {
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_MATCH_INTERFACE_NAME,
|
||||
.property_type = DEFINE_PROPERTY_TYPE (
|
||||
.get_fcn = _get_fcn_match_interface_name,
|
||||
.set_fcn = _set_fcn_multilist,
|
||||
.set_supports_remove = TRUE,
|
||||
),
|
||||
.property_type = &_pt_multilist,
|
||||
.property_typ_data = DEFINE_PROPERTY_TYP_DATA (
|
||||
PROPERTY_TYP_DATA_SUBTYPE (multilist,
|
||||
.get_num_fcn_u = MULTILIST_GET_NUM_FCN_U (NMSettingMatch, nm_setting_match_get_num_interface_names),
|
||||
|
|
@ -6135,6 +6176,30 @@ static const NMMetaPropertyInfo *const property_infos_MATCH[] = {
|
|||
),
|
||||
),
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_MATCH_KERNEL_COMMAND_LINE,
|
||||
.property_type = &_pt_multilist,
|
||||
.property_typ_data = DEFINE_PROPERTY_TYP_DATA (
|
||||
PROPERTY_TYP_DATA_SUBTYPE (multilist,
|
||||
.get_num_fcn_u = MULTILIST_GET_NUM_FCN_U (NMSettingMatch, nm_setting_match_get_num_kernel_command_lines),
|
||||
.add2_fcn = MULTILIST_ADD2_FCN (NMSettingMatch, nm_setting_match_add_kernel_command_line),
|
||||
.remove_by_idx_fcn_u = MULTILIST_REMOVE_BY_IDX_FCN_U (NMSettingMatch, nm_setting_match_remove_kernel_command_line),
|
||||
.remove_by_value_fcn = MULTILIST_REMOVE_BY_VALUE_FCN (NMSettingMatch, nm_setting_match_remove_kernel_command_line_by_value),
|
||||
.strsplit_with_spaces = TRUE,
|
||||
),
|
||||
),
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_MATCH_DRIVER,
|
||||
.property_type = &_pt_multilist,
|
||||
.property_typ_data = DEFINE_PROPERTY_TYP_DATA (
|
||||
PROPERTY_TYP_DATA_SUBTYPE (multilist,
|
||||
.get_num_fcn_u = MULTILIST_GET_NUM_FCN_U (NMSettingMatch, nm_setting_match_get_num_drivers),
|
||||
.add2_fcn = MULTILIST_ADD2_FCN (NMSettingMatch, nm_setting_match_add_driver),
|
||||
.remove_by_idx_fcn_u = MULTILIST_REMOVE_BY_IDX_FCN_U (NMSettingMatch, nm_setting_match_remove_driver),
|
||||
.remove_by_value_fcn = MULTILIST_REMOVE_BY_VALUE_FCN (NMSettingMatch, nm_setting_match_remove_driver_by_value),
|
||||
.strsplit_with_spaces = TRUE,
|
||||
),
|
||||
),
|
||||
),
|
||||
NULL
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -257,6 +257,7 @@ struct _NMMetaPropertyTypData {
|
|||
} gobject_int;
|
||||
struct {
|
||||
const char *(*validate_fcn) (const char *value, char **out_to_free, GError **error);
|
||||
bool handle_emptyunset:1;
|
||||
} gobject_string;
|
||||
struct {
|
||||
bool legacy_format:1;
|
||||
|
|
|
|||
|
|
@ -422,7 +422,7 @@ add_vpn_secrets (RequestData *request,
|
|||
char **msg)
|
||||
{
|
||||
NMSettingVpn *s_vpn = nm_connection_get_setting_vpn (request->connection);
|
||||
const VpnPasswordName *secret_names, *p;
|
||||
const NmcVpnPasswordName *p;
|
||||
const char *vpn_msg = NULL;
|
||||
char **iter;
|
||||
|
||||
|
|
@ -439,7 +439,7 @@ add_vpn_secrets (RequestData *request,
|
|||
NM_SET_OUT (msg, g_strdup (vpn_msg));
|
||||
|
||||
/* Now add what client thinks might be required, because hints may be empty or incomplete */
|
||||
p = secret_names = nm_vpn_get_secret_names (nm_setting_vpn_get_service_type (s_vpn));
|
||||
p = nm_vpn_get_secret_names (nm_setting_vpn_get_service_type (s_vpn));
|
||||
while (p && p->name) {
|
||||
add_vpn_secret_helper (secrets, s_vpn, p->name, _(p->ui_name));
|
||||
p++;
|
||||
|
|
|
|||
|
|
@ -103,63 +103,73 @@ nm_vpn_supports_ipv6 (NMConnection *connection)
|
|||
return NM_FLAGS_HAS (capabilities, NM_VPN_EDITOR_PLUGIN_CAPABILITY_IPV6);
|
||||
}
|
||||
|
||||
const VpnPasswordName *
|
||||
const NmcVpnPasswordName *
|
||||
nm_vpn_get_secret_names (const char *service_type)
|
||||
{
|
||||
static const VpnPasswordName generic_vpn_secrets[] = {
|
||||
{ "password", N_("Password") },
|
||||
{ 0 }
|
||||
};
|
||||
static const VpnPasswordName openvpn_secrets[] = {
|
||||
{ "password", N_("Password") },
|
||||
{ "cert-pass", N_("Certificate password") },
|
||||
{ "http-proxy-password", N_("HTTP proxy password") },
|
||||
{ 0 }
|
||||
};
|
||||
static const VpnPasswordName vpnc_secrets[] = {
|
||||
{ "Xauth password", N_("Password") },
|
||||
{ "IPSec secret", N_("Group password") },
|
||||
{ 0 }
|
||||
};
|
||||
static const VpnPasswordName swan_secrets[] = {
|
||||
{ "xauthpassword", N_("Password") },
|
||||
{ "pskvalue", N_("Group password") },
|
||||
{ 0 }
|
||||
};
|
||||
static const VpnPasswordName openconnect_secrets[] = {
|
||||
{ "gateway", N_("Gateway") },
|
||||
{ "cookie", N_("Cookie") },
|
||||
{ "gwcert", N_("Gateway certificate hash") },
|
||||
{ 0 }
|
||||
};
|
||||
const char *type;
|
||||
|
||||
if (!service_type)
|
||||
return NULL;
|
||||
|
||||
if ( !g_str_has_prefix (service_type, NM_DBUS_INTERFACE)
|
||||
if ( !NM_STR_HAS_PREFIX (service_type, NM_DBUS_INTERFACE)
|
||||
|| service_type[NM_STRLEN (NM_DBUS_INTERFACE)] != '.') {
|
||||
/* all our well-known, hard-coded vpn-types start with NM_DBUS_INTERFACE. */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
type = service_type + (NM_STRLEN (NM_DBUS_INTERFACE) + 1);
|
||||
if ( !g_strcmp0 (type, "pptp")
|
||||
|| !g_strcmp0 (type, "iodine")
|
||||
|| !g_strcmp0 (type, "ssh")
|
||||
|| !g_strcmp0 (type, "l2tp")
|
||||
|| !g_strcmp0 (type, "fortisslvpn"))
|
||||
return generic_vpn_secrets;
|
||||
else if (!g_strcmp0 (type, "openvpn"))
|
||||
return openvpn_secrets;
|
||||
else if (!g_strcmp0 (type, "vpnc"))
|
||||
return vpnc_secrets;
|
||||
else if ( !g_strcmp0 (type, "openswan")
|
||||
|| !g_strcmp0 (type, "libreswan")
|
||||
|| !g_strcmp0 (type, "strongswan"))
|
||||
return swan_secrets;
|
||||
else if (!g_strcmp0 (type, "openconnect"))
|
||||
return openconnect_secrets;
|
||||
|
||||
#define _VPN_PASSWORD_LIST(...) \
|
||||
({ \
|
||||
static const NmcVpnPasswordName _arr[] = { \
|
||||
__VA_ARGS__ \
|
||||
{ 0 }, \
|
||||
}; \
|
||||
_arr; \
|
||||
})
|
||||
|
||||
if (NM_IN_STRSET (type, "pptp",
|
||||
"iodine",
|
||||
"ssh",
|
||||
"l2tp",
|
||||
"fortisslvpn")) {
|
||||
return _VPN_PASSWORD_LIST (
|
||||
{ "password", N_("Password") },
|
||||
);
|
||||
}
|
||||
|
||||
if (NM_IN_STRSET (type, "openvpn")) {
|
||||
return _VPN_PASSWORD_LIST (
|
||||
{ "password", N_("Password") },
|
||||
{ "cert-pass", N_("Certificate password") },
|
||||
{ "http-proxy-password", N_("HTTP proxy password") },
|
||||
);
|
||||
}
|
||||
|
||||
if (NM_IN_STRSET (type, "vpnc")) {
|
||||
return _VPN_PASSWORD_LIST (
|
||||
{ "Xauth password", N_("Password") },
|
||||
{ "IPSec secret", N_("Group password") },
|
||||
);
|
||||
};
|
||||
|
||||
if (NM_IN_STRSET (type, "openswan",
|
||||
"libreswan",
|
||||
"strongswan")) {
|
||||
return _VPN_PASSWORD_LIST (
|
||||
{ "xauthpassword", N_("Password") },
|
||||
{ "pskvalue", N_("Group password") },
|
||||
);
|
||||
};
|
||||
|
||||
if (NM_IN_STRSET (type, "openconnect")) {
|
||||
return _VPN_PASSWORD_LIST (
|
||||
{ "gateway", N_("Gateway") },
|
||||
{ "cookie", N_("Cookie") },
|
||||
{ "gwcert", N_("Gateway certificate hash") },
|
||||
);
|
||||
};
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
typedef struct {
|
||||
const char *name;
|
||||
const char *ui_name;
|
||||
} VpnPasswordName;
|
||||
} NmcVpnPasswordName;
|
||||
|
||||
GSList *nm_vpn_get_plugin_infos (void);
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ NMVpnEditorPlugin *nm_vpn_get_editor_plugin (const char *service_type, GError **
|
|||
|
||||
gboolean nm_vpn_supports_ipv6 (NMConnection *connection);
|
||||
|
||||
const VpnPasswordName * nm_vpn_get_secret_names (const char *service_type);
|
||||
const NmcVpnPasswordName *nm_vpn_get_secret_names (const char *service_type);
|
||||
|
||||
gboolean nm_vpn_openconnect_authenticate_helper (const char *host,
|
||||
char **cookie,
|
||||
|
|
|
|||
|
|
@ -119,10 +119,19 @@
|
|||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_HELLO_TIME N_("The Spanning Tree Protocol (STP) hello time, in seconds.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_MAC_ADDRESS N_("If specified, the MAC address of bridge. When creating a new bridge, this MAC address will be set. If this field is left unspecified, the \"ethernet.cloned-mac-address\" is referred instead to generate the initial MAC address. Note that setting \"ethernet.cloned-mac-address\" anyway overwrites the MAC address of the bridge later while activating the bridge. Hence, this property is deprecated. Deprecated: 1")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_MAX_AGE N_("The Spanning Tree Protocol (STP) maximum message age, in seconds.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_MULTICAST_HASH_MAX N_("Set maximum size of multicast hash table (value must be a power of 2).")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_MULTICAST_LAST_MEMBER_COUNT N_("Set the number of queries the bridge will send before stopping forwarding a multicast group after a \"leave\" message has been received.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL N_("Set interval (in deciseconds) between queries to find remaining members of a group, after a \"leave\" message is received.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL N_("Set delay (in deciseconds) after which the bridge will leave a group, if no membership reports for this group are received.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_MULTICAST_QUERIER N_("Enable or disable sending of multicast queries by the bridge. If not specified the option is disabled.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_MULTICAST_QUERIER_INTERVAL N_("If no queries are seen after this delay (in deciseconds) has passed, the bridge will start to send its own queries.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_MULTICAST_QUERY_INTERVAL N_("Interval (in deciseconds) between queries sent by the bridge after the end of the startup phase.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL N_("Set the Max Response Time/Max Response Delay (in deciseconds) for IGMP/MLD queries sent by the bridge.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_MULTICAST_QUERY_USE_IFADDR N_("If enabled the bridge's own IP address is used as the source address for IGMP queries otherwise the default of 0.0.0.0 is used.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_MULTICAST_ROUTER N_("Sets bridge's multicast router. multicast-snooping must be enabled for this option to work. Supported values are: 'auto', 'disabled', 'enabled'. If not specified the default value is 'auto'.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_MULTICAST_SNOOPING N_("Controls whether IGMP snooping is enabled for this bridge. Note that if snooping was automatically disabled due to hash collisions, the system may refuse to enable the feature until the collisions are resolved.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT N_("Set the number of IGMP queries to send during startup phase.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL N_("Sets the time (in deciseconds) between queries sent out at startup to determine membership information.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_PRIORITY N_("Sets the Spanning Tree Protocol (STP) priority for this bridge. Lower values are \"better\"; the lowest priority bridge will be elected the root bridge.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_STP N_("Controls whether Spanning Tree Protocol (STP) is enabled for this bridge.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_BRIDGE_VLAN_DEFAULT_PVID N_("The default PVID for the ports of the bridge, that is the VLAN id assigned to incoming untagged frames.")
|
||||
|
|
@ -152,6 +161,7 @@
|
|||
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_MASTER N_("Interface name of the master device or UUID of the master connection.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_MDNS N_("Whether mDNS is enabled for the connection. The permitted values are: \"yes\" (2) register hostname and resolving for the connection, \"no\" (0) disable mDNS for the interface, \"resolve\" (1) do not register hostname but allow resolving of mDNS host names and \"default\" (-1) to allow lookup of a global default in NetworkManager.conf. If unspecified, \"default\" ultimately depends on the DNS plugin (which for systemd-resolved currently means \"no\"). This feature requires a plugin which supports mDNS. Otherwise the setting has no effect. One such plugin is dns-systemd-resolved.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_METERED N_("Whether the connection is metered. When updating this property on a currently activated connection, the change takes effect immediately.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_MUD_URL N_("If configured, set to a Manufacturer Usage Description (MUD) URL that points to manufacturer-recommended network policies for IoT devices. It is transmitted as a DHCPv4 or DHCPv6 option. The value must be a valid URL starting with \"https://\". The special value \"none\" is allowed to indicate that no MUD URL is used. If the per-profile value is unspecified (the default), a global connection default gets consulted. If still unspecified, the ultimate default is \"none\".")
|
||||
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_MULTI_CONNECT N_("Specifies whether the profile can be active multiple times at a particular moment. The value is of type NMConnectionMultiConnect.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_PERMISSIONS N_("An array of strings defining what access a given user has to this connection. If this is NULL or empty, all users are allowed to access this connection; otherwise users are allowed if and only if they are in this list. When this is not empty, the connection can be active only when one of the specified users is logged into an active session. Each entry is of the form \"[type]:[id]:[reserved]\"; for example, \"user:dcbw:blah\". At this time only the \"user\" [type] is allowed. Any other values are ignored and reserved for future use. [id] is the username that this permission refers to, which may not contain the \":\" character. Any [reserved] information present must be ignored and is reserved for future use. All of [type], [id], and [reserved] must be valid UTF-8.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_READ_ONLY N_("FALSE if the connection can be modified using the provided settings service's D-Bus interface with the right privileges, or TRUE if the connection is read-only and cannot be modified.")
|
||||
|
|
@ -270,7 +280,9 @@
|
|||
#define DESCRIBE_DOC_NM_SETTING_MACVLAN_PARENT N_("If given, specifies the parent interface name or parent connection UUID from which this MAC-VLAN interface should be created. If this property is not specified, the connection must contain an \"802-3-ethernet\" setting with a \"mac-address\" property.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_MACVLAN_PROMISCUOUS N_("Whether the interface should be put in promiscuous mode.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_MACVLAN_TAP N_("Whether the interface should be a MACVTAP.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_MATCH_DRIVER N_("A list of driver names to match. Each element is a shell wildcard pattern. When an element is prefixed with exclamation mark (!) the condition is inverted. A candidate driver name is considered matching when both these conditions are satisfied: (a) any of the elements not prefixed with '!' matches or there aren't such elements; (b) none of the elements prefixed with '!' match.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_MATCH_INTERFACE_NAME N_("A list of interface names to match. Each element is a shell wildcard pattern. When an element is prefixed with exclamation mark (!) the condition is inverted. A candidate interface name is considered matching when both these conditions are satisfied: (a) any of the elements not prefixed with '!' matches or there aren't such elements; (b) none of the elements prefixed with '!' match.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_MATCH_KERNEL_COMMAND_LINE N_("A list of kernel command line arguments to match. This may be used to check whether a specific kernel command line option is set (or if prefixed with the exclamation mark unset). The argument must either be a single word, or an assignment (i.e. two words, separated \"=\"). In the former case the kernel command line is searched for the word appearing as is, or as left hand side of an assignment. In the latter case, the exact assignment is looked for with right and left hand side matching.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_OVS_BRIDGE_DATAPATH_TYPE N_("The data path type. One of \"system\", \"netdev\" or empty.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_OVS_BRIDGE_FAIL_MODE N_("The bridge failure mode. One of \"secure\", \"standalone\" or empty.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_OVS_BRIDGE_MCAST_SNOOPING_ENABLE N_("Enable or disable multicast snooping.")
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ dnl - add corresponding NM_VERSION_x_y_z macros in
|
|||
dnl "shared/nm-version-macros.h.in"
|
||||
dnl - update number in meson.build
|
||||
m4_define([nm_major_version], [1])
|
||||
m4_define([nm_minor_version], [24])
|
||||
m4_define([nm_micro_version], [0])
|
||||
m4_define([nm_minor_version], [25])
|
||||
m4_define([nm_micro_version], [1])
|
||||
m4_define([nm_version],
|
||||
[nm_major_version.nm_minor_version.nm_micro_version])
|
||||
|
||||
|
|
|
|||
|
|
@ -226,3 +226,10 @@ else
|
|||
LOG
|
||||
fi
|
||||
|
||||
if [[ "$DO_RELEASE" == 1 ]]; then
|
||||
LOG "RELEASE \"$SOURCE\" :"
|
||||
for c in md5 sha1 sha256 sha512; do
|
||||
LOG "$(printf '%8s: %s' "$c" $("${c}sum" "$SOURCE" | sed 's/ .*//'))"
|
||||
done
|
||||
LOG
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ NO_DIST=0
|
|||
WITH_LIST=()
|
||||
SOURCE_FROM_GIT=0
|
||||
SNAPSHOT="$NM_BUILD_SNAPSHOT"
|
||||
DO_RELEASE=0
|
||||
|
||||
ADD_WITH_TEST=1
|
||||
|
||||
|
|
@ -64,6 +65,7 @@ while [[ $# -gt 0 ]]; do
|
|||
[[ $NARGS -eq 1 ]] || die "--release option must be alone"
|
||||
export NMTST_CHECK_GTK_DOC=1
|
||||
BUILDTYPE=SRPM
|
||||
DO_RELEASE=1
|
||||
;;
|
||||
-c|--clean)
|
||||
GIT_CLEAN=1
|
||||
|
|
@ -173,6 +175,7 @@ export SOURCE_FROM_GIT
|
|||
export BUILDTYPE
|
||||
export NM_RPMBUILD_ARGS="${WITH_LIST[@]}"
|
||||
export SNAPSHOT
|
||||
export DO_RELEASE
|
||||
|
||||
"$SCRIPTDIR"/build.sh
|
||||
|
||||
|
|
|
|||
|
|
@ -2,13 +2,12 @@
|
|||
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||
<busconfig>
|
||||
<policy user="root">
|
||||
<allow own="org.freedesktop.nm_dispatcher"/>
|
||||
<allow send_destination="org.freedesktop.nm_dispatcher"/>
|
||||
<policy user="root">
|
||||
<allow own="org.freedesktop.nm_dispatcher"/>
|
||||
<allow send_destination="org.freedesktop.nm_dispatcher"/>
|
||||
</policy>
|
||||
<policy context="default">
|
||||
<deny own="org.freedesktop.nm_dispatcher"/>
|
||||
<deny send_destination="org.freedesktop.nm_dispatcher"/>
|
||||
<deny own="org.freedesktop.nm_dispatcher"/>
|
||||
<deny send_destination="org.freedesktop.nm_dispatcher"/>
|
||||
</policy>
|
||||
</busconfig>
|
||||
|
||||
|
|
|
|||
|
|
@ -30,10 +30,15 @@ show_connection (NMConnection *connection)
|
|||
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
if (s_con) {
|
||||
struct tm localtime_data;
|
||||
|
||||
/* Get various info from NMSettingConnection and show it */
|
||||
timestamp = nm_setting_connection_get_timestamp (s_con);
|
||||
timestamp_str = g_strdup_printf ("%" G_GUINT64_FORMAT, timestamp);
|
||||
strftime (timestamp_real_str, sizeof (timestamp_real_str), "%c", localtime ((time_t *) ×tamp));
|
||||
strftime (timestamp_real_str,
|
||||
sizeof (timestamp_real_str),
|
||||
"%c",
|
||||
localtime_r ((time_t *) ×tamp, &localtime_data));
|
||||
|
||||
val1 = nm_setting_connection_get_id (s_con);
|
||||
val2 = nm_setting_connection_get_uuid (s_con);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ devList = []
|
|||
|
||||
for arg in sys.argv[2:]:
|
||||
path = GetDevicePath(arg)
|
||||
if path == None:
|
||||
if path is None:
|
||||
raise Exception("NetworkManager knows nothing about %s" % arg)
|
||||
else:
|
||||
devList.append(path)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
# Copyright (C) 2010 Red Hat, Inc.
|
||||
#
|
||||
|
||||
import dbus, sys
|
||||
import dbus
|
||||
|
||||
# This example takes a device interface name as a parameter and tells
|
||||
# NetworkManager to disconnect that device, closing down any network
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
# Copyright (C) 2011 - 2012 Red Hat, Inc.
|
||||
#
|
||||
|
||||
import dbus, sys
|
||||
import dbus
|
||||
|
||||
# This example lists basic information about network interfaces known to NM
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@ def get_active_connection_path(uuid):
|
|||
proxy = bus.get_object('org.freedesktop.NetworkManager', '/org/freedesktop/NetworkManager')
|
||||
iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.DBus.Properties')
|
||||
active_connections = iface.Get('org.freedesktop.NetworkManager', 'ActiveConnections')
|
||||
all_connections = get_connections()
|
||||
|
||||
for a in active_connections:
|
||||
proxy = bus.get_object('org.freedesktop.NetworkManager', a)
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@
|
|||
#
|
||||
|
||||
#
|
||||
# This example starts or stops a wifi hotspot
|
||||
# This example prints the current wifi access point
|
||||
#
|
||||
# Configuration settings are described at
|
||||
# https://developer.gnome.org/NetworkManager/1.0/ref-settings.html
|
||||
#
|
||||
|
||||
import dbus, sys, time
|
||||
import dbus, sys
|
||||
|
||||
bus = dbus.SystemBus()
|
||||
service_name = "org.freedesktop.NetworkManager"
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@ import gi
|
|||
gi.require_version('NM', '1.0')
|
||||
from gi.repository import GLib, NM
|
||||
|
||||
import os
|
||||
|
||||
###############################################################################
|
||||
|
||||
def usage():
|
||||
|
|
@ -136,7 +134,7 @@ def do_adjust_rollback_timeout(client):
|
|||
sys.exit("Missing timeout")
|
||||
try:
|
||||
add_timeout = int(sys.argv[3])
|
||||
except:
|
||||
except Exception:
|
||||
sys.exit("Invalid timeout")
|
||||
|
||||
path = validate_path(sys.argv[2], client)
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ if __name__ == "__main__":
|
|||
|
||||
# deactivate the connections
|
||||
for ac in connections:
|
||||
if ctype == None or ctype == ac.get_connection_type():
|
||||
if ctype is None or ctype == ac.get_connection_type():
|
||||
sys.stdout.write("Deactivating %s (%s)" % (ac.get_id(), ac.get_uuid()))
|
||||
try:
|
||||
client.deactivate_connection(ac, None)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
# Copyright (C) 2016 Red Hat, Inc.
|
||||
#
|
||||
|
||||
import sys
|
||||
import gi
|
||||
gi.require_version('NM', '1.0')
|
||||
from gi.repository import GLib, NM
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import gi
|
||||
gi.require_version('NM', '1.0')
|
||||
from gi.repository import GLib, NM
|
||||
from gi.repository import NM
|
||||
|
||||
if __name__ == "__main__":
|
||||
client = NM.Client.new(None)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import gi
|
||||
gi.require_version('NM', '1.0')
|
||||
from gi.repository import GLib, NM
|
||||
from gi.repository import NM
|
||||
|
||||
if __name__ == "__main__":
|
||||
client = NM.Client.new(None)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import gi
|
||||
gi.require_version('NM', '1.0')
|
||||
from gi.repository import GLib, NM
|
||||
from gi.repository import NM
|
||||
|
||||
if __name__ == "__main__":
|
||||
client = NM.Client.new(None)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
import sys, socket
|
||||
import gi
|
||||
gi.require_version('NM', '1.0')
|
||||
from gi.repository import GLib, NM
|
||||
from gi.repository import NM
|
||||
|
||||
#
|
||||
# This example shows how to get addresses, routes and DNS information
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
#
|
||||
|
||||
import sys
|
||||
import re
|
||||
|
||||
import gi
|
||||
gi.require_version('NM', '1.0')
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
#
|
||||
|
||||
import sys
|
||||
import re
|
||||
|
||||
import gi
|
||||
gi.require_version('NM', '1.0')
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@
|
|||
# nm-wg-set id "$PROFILE" $WG_ARGS
|
||||
|
||||
import sys
|
||||
import re
|
||||
import os
|
||||
|
||||
import gi
|
||||
|
|
@ -443,7 +442,7 @@ if __name__ == '__main__':
|
|||
secrets = conn.get_secrets(NM.SETTING_WIREGUARD_SETTING_NAME)
|
||||
if secrets:
|
||||
conn.update_secrets(NM.SETTING_WIREGUARD_SETTING_NAME, secrets)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if not argv:
|
||||
|
|
|
|||
109
examples/python/gi/wifi-p2p.py
Executable file
109
examples/python/gi/wifi-p2p.py
Executable file
|
|
@ -0,0 +1,109 @@
|
|||
#!/usr/bin/env python
|
||||
# SPDX-License-Identifier: GPL-2.0+
|
||||
#
|
||||
# Copyright (C) 2020 Red Hat, Inc.
|
||||
|
||||
# This example performs a scan of Wi-Fi P2P peers and connects to one
|
||||
# of them.
|
||||
|
||||
import sys
|
||||
import uuid
|
||||
import gi
|
||||
gi.require_version('NM', '1.0')
|
||||
from gi.repository import GLib, NM
|
||||
|
||||
main_loop = None
|
||||
client = None
|
||||
|
||||
def create_profile(name, peer_mac):
|
||||
profile = NM.SimpleConnection.new()
|
||||
|
||||
s_con = NM.SettingConnection.new()
|
||||
s_con.set_property(NM.SETTING_CONNECTION_ID, name)
|
||||
s_con.set_property(NM.SETTING_CONNECTION_UUID, str(uuid.uuid4()))
|
||||
s_con.set_property(NM.SETTING_CONNECTION_TYPE, "wifi-p2p")
|
||||
s_con.set_property(NM.SETTING_CONNECTION_AUTOCONNECT, False)
|
||||
|
||||
s_ip4 = NM.SettingIP4Config.new()
|
||||
s_ip4.set_property(NM.SETTING_IP_CONFIG_METHOD, "auto")
|
||||
|
||||
s_ip6 = NM.SettingIP6Config.new()
|
||||
s_ip6.set_property(NM.SETTING_IP_CONFIG_METHOD, "auto")
|
||||
|
||||
s_wifi_p2p = NM.SettingWifiP2P.new()
|
||||
s_wifi_p2p.set_property(NM.SETTING_WIFI_P2P_PEER, peer_mac)
|
||||
s_wifi_p2p.set_property(NM.SETTING_WIFI_P2P_WFD_IES,
|
||||
GLib.Bytes.new(b'\x00\x00\x06\x00\x90\x1c\x44\x00\xc8'))
|
||||
|
||||
profile.add_setting(s_con)
|
||||
profile.add_setting(s_ip4)
|
||||
profile.add_setting(s_ip6)
|
||||
profile.add_setting(s_wifi_p2p)
|
||||
|
||||
return profile
|
||||
|
||||
def activated_cb(client, result, data):
|
||||
try:
|
||||
client.add_and_activate_connection2_finish(result)
|
||||
print(" * Connection profile activated successfully")
|
||||
except Exception as e:
|
||||
sys.stderr.write("Error: %s\n" % e)
|
||||
main_loop.quit()
|
||||
|
||||
def scan_timeout_cb(device):
|
||||
peers = device.get_peers()
|
||||
if len(peers) == 0:
|
||||
main_loop.quit()
|
||||
sys.exit("No peer found")
|
||||
|
||||
print("\n {:20} {:30} {:3} {:30}".format("MAC", "Name", "Sig", "Wfd-IEs"));
|
||||
for p in peers:
|
||||
if p.get_wfd_ies() is not None:
|
||||
ies = p.get_wfd_ies().get_data().hex()
|
||||
else:
|
||||
ies = ""
|
||||
print(" {:20} {:30} {:3} {:30}".format(p.get_hw_address(),
|
||||
p.get_name(),
|
||||
p.get_strength(),
|
||||
ies))
|
||||
print("")
|
||||
|
||||
# Connect to first peer
|
||||
profile = create_profile('P2P-connection', peers[0].get_hw_address())
|
||||
client.add_and_activate_connection2(profile,
|
||||
device,
|
||||
"/",
|
||||
GLib.Variant('a{sv}', {}),
|
||||
None,
|
||||
activated_cb,
|
||||
None)
|
||||
print(" * Connecting to peer {} using profile '{}'".format(peers[0].get_hw_address(),
|
||||
profile.get_id()))
|
||||
|
||||
def start_find_cb(device, async_result, user_data):
|
||||
try:
|
||||
device.start_find_finish(async_result)
|
||||
except Exception as e:
|
||||
sys.stderr.write("Error: %s\n" % e)
|
||||
main_loop.quit()
|
||||
|
||||
print(" * Scanning on device {}...".format(device.get_iface()));
|
||||
GLib.timeout_add(10000, scan_timeout_cb, device)
|
||||
|
||||
if __name__ == "__main__":
|
||||
client = NM.Client.new(None)
|
||||
device = None
|
||||
|
||||
devices = client.get_devices()
|
||||
for d in devices:
|
||||
if d.get_device_type() == NM.DeviceType.WIFI_P2P:
|
||||
device = d
|
||||
break
|
||||
|
||||
if device is None:
|
||||
sys.exit("No Wi-Fi P2P device found")
|
||||
|
||||
device.start_find(GLib.Variant('a{sv}', {}), None, start_find_cb, None)
|
||||
|
||||
main_loop = GLib.MainLoop()
|
||||
main_loop.run()
|
||||
|
|
@ -78,24 +78,82 @@
|
|||
#include "nm-libnm-core-intern/nm-libnm-core-utils.h"
|
||||
|
||||
/* IEEE 802.1D-1998 timer values */
|
||||
#define NM_BR_MIN_HELLO_TIME 1
|
||||
#define NM_BR_MAX_HELLO_TIME 10
|
||||
#define NM_BRIDGE_HELLO_TIME_MIN 1u
|
||||
#define NM_BRIDGE_HELLO_TIME_DEF 2u
|
||||
#define NM_BRIDGE_HELLO_TIME_MAX 10u
|
||||
|
||||
#define NM_BR_MIN_FORWARD_DELAY 2
|
||||
#define NM_BR_MAX_FORWARD_DELAY 30
|
||||
#define NM_BRIDGE_FORWARD_DELAY_MIN 2u
|
||||
#define NM_BRIDGE_FORWARD_DELAY_DEF 15u
|
||||
#define NM_BRIDGE_FORWARD_DELAY_MAX 30u
|
||||
|
||||
#define NM_BR_MIN_MAX_AGE 6
|
||||
#define NM_BR_MAX_MAX_AGE 40
|
||||
#define NM_BRIDGE_MAX_AGE_MIN 6u
|
||||
#define NM_BRIDGE_MAX_AGE_DEF 20u
|
||||
#define NM_BRIDGE_MAX_AGE_MAX 40u
|
||||
|
||||
/* IEEE 802.1D-1998 Table 7.4 */
|
||||
#define NM_BR_MIN_AGEING_TIME 0
|
||||
#define NM_BR_MAX_AGEING_TIME 1000000
|
||||
#define NM_BRIDGE_AGEING_TIME_MIN 0u
|
||||
#define NM_BRIDGE_AGEING_TIME_DEF 300u
|
||||
#define NM_BRIDGE_AGEING_TIME_MAX 1000000u
|
||||
|
||||
#define NM_BR_PORT_MAX_PRIORITY 63
|
||||
#define NM_BR_PORT_DEF_PRIORITY 32
|
||||
#define NM_BRIDGE_PORT_PRIORITY_MIN 0u
|
||||
#define NM_BRIDGE_PORT_PRIORITY_DEF 32u
|
||||
#define NM_BRIDGE_PORT_PRIORITY_MAX 63u
|
||||
|
||||
#define NM_BR_PORT_MAX_PATH_COST 65535
|
||||
#define NM_BR_PORT_DEF_PATH_COST 100
|
||||
#define NM_BRIDGE_PORT_PATH_COST_MIN 0u
|
||||
#define NM_BRIDGE_PORT_PATH_COST_DEF 100u
|
||||
#define NM_BRIDGE_PORT_PATH_COST_MAX 65535u
|
||||
|
||||
#define NM_BRIDGE_MULTICAST_HASH_MAX_MIN 1u
|
||||
#define NM_BRIDGE_MULTICAST_HASH_MAX_DEF 4096u
|
||||
#define NM_BRIDGE_MULTICAST_HASH_MAX_MAX ((guint) G_MAXUINT32)
|
||||
|
||||
#define NM_BRIDGE_STP_DEF TRUE
|
||||
|
||||
#define NM_BRIDGE_PRIORITY_MIN 0u
|
||||
#define NM_BRIDGE_PRIORITY_DEF 0x8000u
|
||||
#define NM_BRIDGE_PRIORITY_MAX ((guint) G_MAXUINT16)
|
||||
|
||||
#define NM_BRIDGE_MULTICAST_LAST_MEMBER_COUNT_MIN 0u
|
||||
#define NM_BRIDGE_MULTICAST_LAST_MEMBER_COUNT_DEF 2u
|
||||
#define NM_BRIDGE_MULTICAST_LAST_MEMBER_COUNT_MAX ((guint) G_MAXUINT32)
|
||||
|
||||
#define NM_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL_MIN ((guint64) 0)
|
||||
#define NM_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL_DEF ((guint64) 100)
|
||||
#define NM_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL_MAX G_MAXUINT64
|
||||
|
||||
#define NM_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL_MIN ((guint64) 0)
|
||||
#define NM_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL_DEF ((guint64) 26000)
|
||||
#define NM_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL_MAX G_MAXUINT64
|
||||
|
||||
#define NM_BRIDGE_MULTICAST_QUERIER_INTERVAL_MIN ((guint64) 0)
|
||||
#define NM_BRIDGE_MULTICAST_QUERIER_INTERVAL_DEF ((guint64) 25500)
|
||||
#define NM_BRIDGE_MULTICAST_QUERIER_INTERVAL_MAX G_MAXUINT64
|
||||
|
||||
#define NM_BRIDGE_MULTICAST_QUERIER_DEF FALSE
|
||||
|
||||
#define NM_BRIDGE_MULTICAST_QUERY_INTERVAL_MIN ((guint64) 0)
|
||||
#define NM_BRIDGE_MULTICAST_QUERY_INTERVAL_DEF ((guint64) 12500)
|
||||
#define NM_BRIDGE_MULTICAST_QUERY_INTERVAL_MAX G_MAXUINT64
|
||||
|
||||
#define NM_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL_MIN ((guint64) 0)
|
||||
#define NM_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL_DEF ((guint64) 1000)
|
||||
#define NM_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL_MAX G_MAXUINT64
|
||||
|
||||
#define NM_BRIDGE_MULTICAST_QUERY_USE_IFADDR_DEF FALSE
|
||||
|
||||
#define NM_BRIDGE_MULTICAST_SNOOPING_DEF TRUE
|
||||
|
||||
#define NM_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT_MIN 0u
|
||||
#define NM_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT_DEF 2u
|
||||
#define NM_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT_MAX ((guint) G_MAXUINT32)
|
||||
|
||||
#define NM_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL_MIN ((guint64) 0)
|
||||
#define NM_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL_DEF ((guint64) 3125)
|
||||
#define NM_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL_MAX G_MAXUINT64
|
||||
|
||||
#define NM_BRIDGE_VLAN_STATS_ENABLED_DEF FALSE
|
||||
|
||||
#define NM_BRIDGE_VLAN_DEFAULT_PVID_DEF 1u
|
||||
|
||||
/* NM_SETTING_COMPARE_FLAG_INFERRABLE: check whether a device-generated
|
||||
* connection can be replaced by a already-defined connection. This flag only
|
||||
|
|
|
|||
|
|
@ -236,18 +236,20 @@ nm_setting_bridge_port_remove_vlan_by_vid (NMSettingBridgePort *setting,
|
|||
guint16 vid_end)
|
||||
{
|
||||
NMSettingBridgePortPrivate *priv;
|
||||
guint16 v_start, v_end;
|
||||
NMBridgeVlan *vlan;
|
||||
guint i;
|
||||
|
||||
if (vid_end == 0)
|
||||
vid_end = vid_start;
|
||||
|
||||
g_return_val_if_fail (NM_IS_SETTING_BRIDGE_PORT (setting), FALSE);
|
||||
|
||||
priv = NM_SETTING_BRIDGE_PORT_GET_PRIVATE (setting);
|
||||
|
||||
for (i = 0; i < priv->vlans->len; i++) {
|
||||
vlan = (NMBridgeVlan *) priv->vlans->pdata[i];
|
||||
NMBridgeVlan *vlan = priv->vlans->pdata[i];
|
||||
guint16 v_start = 0;
|
||||
guint16 v_end = 0;
|
||||
|
||||
nm_bridge_vlan_get_vid_range (vlan, &v_start, &v_end);
|
||||
if (v_start == vid_start && v_end == vid_end) {
|
||||
g_ptr_array_remove_index (priv->vlans, i);
|
||||
|
|
@ -440,8 +442,8 @@ nm_setting_bridge_port_init (NMSettingBridgePort *setting)
|
|||
|
||||
priv->vlans = g_ptr_array_new_with_free_func ((GDestroyNotify) nm_bridge_vlan_unref);
|
||||
|
||||
priv->priority = NM_BR_PORT_DEF_PRIORITY;
|
||||
priv->path_cost = NM_BR_PORT_DEF_PATH_COST;
|
||||
priv->priority = NM_BRIDGE_PORT_PRIORITY_DEF;
|
||||
priv->path_cost = NM_BRIDGE_PORT_PATH_COST_DEF;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -498,7 +500,7 @@ nm_setting_bridge_port_class_init (NMSettingBridgePortClass *klass)
|
|||
*/
|
||||
obj_properties[PROP_PRIORITY] =
|
||||
g_param_spec_uint (NM_SETTING_BRIDGE_PORT_PRIORITY, "", "",
|
||||
0, NM_BR_PORT_MAX_PRIORITY, NM_BR_PORT_DEF_PRIORITY,
|
||||
NM_BRIDGE_PORT_PRIORITY_MIN, NM_BRIDGE_PORT_PRIORITY_MAX, NM_BRIDGE_PORT_PRIORITY_DEF,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
|
@ -519,7 +521,7 @@ nm_setting_bridge_port_class_init (NMSettingBridgePortClass *klass)
|
|||
*/
|
||||
obj_properties[PROP_PATH_COST] =
|
||||
g_param_spec_uint (NM_SETTING_BRIDGE_PORT_PATH_COST, "", "",
|
||||
0, NM_BR_PORT_MAX_PATH_COST, NM_BR_PORT_DEF_PATH_COST,
|
||||
NM_BRIDGE_PORT_PATH_COST_MIN, NM_BRIDGE_PORT_PATH_COST_MAX, NM_BRIDGE_PORT_PATH_COST_DEF,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,18 +22,6 @@
|
|||
* necessary for bridging connections.
|
||||
**/
|
||||
|
||||
#define BRIDGE_AGEING_TIME_DEFAULT 300
|
||||
#define BRIDGE_FORWARD_DELAY_DEFAULT 15
|
||||
#define BRIDGE_HELLO_TIME_DEFAULT 2
|
||||
#define BRIDGE_MAX_AGE_DEFAULT 20
|
||||
#define BRIDGE_MULTICAST_QUERIER_DEFAULT FALSE
|
||||
#define BRIDGE_MULTICAST_QUERY_USE_IFADDR_DEFAULT FALSE
|
||||
#define BRIDGE_MULTICAST_SNOOPING_DEFAULT TRUE
|
||||
#define BRIDGE_PRIORITY_DEFAULT 0x8000
|
||||
#define BRIDGE_STP_DEFAULT TRUE
|
||||
#define BRIDGE_VLAN_DEFAULT_PVID_DEFAULT 1
|
||||
#define BRIDGE_VLAN_STATS_ENABLED_DEFAULT FALSE
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
NM_GOBJECT_PROPERTIES_DEFINE (NMSettingBridge,
|
||||
|
|
@ -46,10 +34,19 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMSettingBridge,
|
|||
PROP_AGEING_TIME,
|
||||
PROP_GROUP_ADDRESS,
|
||||
PROP_GROUP_FORWARD_MASK,
|
||||
PROP_MULTICAST_HASH_MAX,
|
||||
PROP_MULTICAST_LAST_MEMBER_COUNT,
|
||||
PROP_MULTICAST_LAST_MEMBER_INTERVAL,
|
||||
PROP_MULTICAST_MEMBERSHIP_INTERVAL,
|
||||
PROP_MULTICAST_ROUTER,
|
||||
PROP_MULTICAST_QUERIER,
|
||||
PROP_MULTICAST_QUERIER_INTERVAL,
|
||||
PROP_MULTICAST_QUERY_INTERVAL,
|
||||
PROP_MULTICAST_QUERY_RESPONSE_INTERVAL,
|
||||
PROP_MULTICAST_QUERY_USE_IFADDR,
|
||||
PROP_MULTICAST_SNOOPING,
|
||||
PROP_MULTICAST_STARTUP_QUERY_COUNT,
|
||||
PROP_MULTICAST_STARTUP_QUERY_INTERVAL,
|
||||
PROP_VLAN_FILTERING,
|
||||
PROP_VLAN_DEFAULT_PVID,
|
||||
PROP_VLAN_PROTOCOL,
|
||||
|
|
@ -63,7 +60,16 @@ typedef struct {
|
|||
char * multicast_router;
|
||||
char * group_address;
|
||||
char * vlan_protocol;
|
||||
guint64 multicast_last_member_interval;
|
||||
guint64 multicast_membership_interval;
|
||||
guint64 multicast_querier_interval;
|
||||
guint64 multicast_query_interval;
|
||||
guint64 multicast_query_response_interval;
|
||||
guint64 multicast_startup_query_interval;
|
||||
guint32 ageing_time;
|
||||
guint32 multicast_hash_max;
|
||||
guint32 multicast_last_member_count;
|
||||
guint32 multicast_startup_query_count;
|
||||
guint16 priority;
|
||||
guint16 forward_delay;
|
||||
guint16 hello_time;
|
||||
|
|
@ -1010,6 +1016,150 @@ nm_setting_bridge_get_multicast_querier (const NMSettingBridge *setting)
|
|||
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->multicast_querier;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_get_multicast_hash_max:
|
||||
* @setting: the #NMSettingBridge
|
||||
*
|
||||
* Returns: the #NMSettingBridge:multicast-hash-max property of the setting
|
||||
*
|
||||
* Since 1.26
|
||||
**/
|
||||
guint32
|
||||
nm_setting_bridge_get_multicast_hash_max (const NMSettingBridge *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
|
||||
|
||||
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->multicast_hash_max;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_get_multicast_last_member_count:
|
||||
* @setting: the #NMSettingBridge
|
||||
*
|
||||
* Returns: the #NMSettingBridge:multicast-last-member-count property of the setting
|
||||
*
|
||||
* Since 1.26
|
||||
**/
|
||||
guint32
|
||||
nm_setting_bridge_get_multicast_last_member_count (const NMSettingBridge *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
|
||||
|
||||
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->multicast_last_member_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_get_multicast_last_member_interval:
|
||||
* @setting: the #NMSettingBridge
|
||||
*
|
||||
* Returns: the #NMSettingBridge:multicast-last-member-interval property of the setting
|
||||
*
|
||||
* Since 1.26
|
||||
**/
|
||||
guint64
|
||||
nm_setting_bridge_get_multicast_last_member_interval (const NMSettingBridge *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
|
||||
|
||||
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->multicast_last_member_interval;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_get_multicast_membership_interval:
|
||||
* @setting: the #NMSettingBridge
|
||||
*
|
||||
* Returns: the #NMSettingBridge:multicast-membership-interval property of the setting
|
||||
*
|
||||
* Since 1.26
|
||||
**/
|
||||
guint64
|
||||
nm_setting_bridge_get_multicast_membership_interval (const NMSettingBridge *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
|
||||
|
||||
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->multicast_membership_interval;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_get_multicast_querier_interval:
|
||||
* @setting: the #NMSettingBridge
|
||||
*
|
||||
* Returns: the #NMSettingBridge:multicast-querier-interval property of the setting
|
||||
*
|
||||
* Since 1.26
|
||||
**/
|
||||
guint64
|
||||
nm_setting_bridge_get_multicast_querier_interval (const NMSettingBridge *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
|
||||
|
||||
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->multicast_querier_interval;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_get_multicast_query_interval:
|
||||
* @setting: the #NMSettingBridge
|
||||
*
|
||||
* Returns: the #NMSettingBridge:multicast-query-interval property of the setting
|
||||
*
|
||||
* Since 1.26
|
||||
**/
|
||||
guint64
|
||||
nm_setting_bridge_get_multicast_query_interval (const NMSettingBridge *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
|
||||
|
||||
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->multicast_query_interval;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_get_multicast_query_response_interval:
|
||||
* @setting: the #NMSettingBridge
|
||||
*
|
||||
* Returns: the #NMSettingBridge:multicast-query-response-interval property of the setting
|
||||
*
|
||||
* Since 1.26
|
||||
**/
|
||||
guint64
|
||||
nm_setting_bridge_get_multicast_query_response_interval (const NMSettingBridge *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
|
||||
|
||||
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->multicast_query_response_interval;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_get_multicast_startup_query_count:
|
||||
* @setting: the #NMSettingBridge
|
||||
*
|
||||
* Returns: the #NMSettingBridge:multicast-query-response-interval property of the setting
|
||||
*
|
||||
* Since 1.26
|
||||
**/
|
||||
guint32
|
||||
nm_setting_bridge_get_multicast_startup_query_count (const NMSettingBridge *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
|
||||
|
||||
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->multicast_startup_query_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_bridge_get_multicast_startup_query_interval:
|
||||
* @setting: the #NMSettingBridge
|
||||
*
|
||||
* Returns: the #NMSettingBridge:multicast-startup-query-interval property of the setting
|
||||
*
|
||||
* Since 1.26
|
||||
**/
|
||||
guint64
|
||||
nm_setting_bridge_get_multicast_startup_query_interval (const NMSettingBridge *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
|
||||
|
||||
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->multicast_startup_query_interval;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
|
|
@ -1050,32 +1200,32 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
|
|||
}
|
||||
|
||||
if (!check_range (priv->forward_delay,
|
||||
NM_BR_MIN_FORWARD_DELAY,
|
||||
NM_BR_MAX_FORWARD_DELAY,
|
||||
NM_BRIDGE_FORWARD_DELAY_MIN,
|
||||
NM_BRIDGE_FORWARD_DELAY_MAX,
|
||||
!priv->stp,
|
||||
NM_SETTING_BRIDGE_FORWARD_DELAY,
|
||||
error))
|
||||
return FALSE;
|
||||
|
||||
if (!check_range (priv->hello_time,
|
||||
NM_BR_MIN_HELLO_TIME,
|
||||
NM_BR_MAX_HELLO_TIME,
|
||||
NM_BRIDGE_HELLO_TIME_MIN,
|
||||
NM_BRIDGE_HELLO_TIME_MAX,
|
||||
!priv->stp,
|
||||
NM_SETTING_BRIDGE_HELLO_TIME,
|
||||
error))
|
||||
return FALSE;
|
||||
|
||||
if (!check_range (priv->max_age,
|
||||
NM_BR_MIN_MAX_AGE,
|
||||
NM_BR_MAX_MAX_AGE,
|
||||
NM_BRIDGE_MAX_AGE_MIN,
|
||||
NM_BRIDGE_MAX_AGE_MAX,
|
||||
!priv->stp,
|
||||
NM_SETTING_BRIDGE_MAX_AGE,
|
||||
error))
|
||||
return FALSE;
|
||||
|
||||
if (!check_range (priv->ageing_time,
|
||||
NM_BR_MIN_AGEING_TIME,
|
||||
NM_BR_MAX_AGEING_TIME,
|
||||
NM_BRIDGE_AGEING_TIME_MIN,
|
||||
NM_BRIDGE_AGEING_TIME_MAX,
|
||||
!priv->stp,
|
||||
NM_SETTING_BRIDGE_AGEING_TIME,
|
||||
error))
|
||||
|
|
@ -1149,6 +1299,16 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
|
|||
}
|
||||
}
|
||||
|
||||
if (!nm_utils_is_power_of_two (priv->multicast_hash_max)) {
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("'%s' option must be a power of 2"),
|
||||
NM_SETTING_BRIDGE_MULTICAST_HASH_MAX);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_BRIDGE_SETTING_NAME, NM_SETTING_BRIDGE_MULTICAST_HASH_MAX);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Failures from here on are NORMALIZABLE... */
|
||||
|
||||
if (!_nm_utils_bridge_vlan_verify_list (priv->vlans,
|
||||
|
|
@ -1235,6 +1395,18 @@ get_property (GObject *object, guint prop_id,
|
|||
case PROP_GROUP_FORWARD_MASK:
|
||||
g_value_set_uint (value, priv->group_forward_mask);
|
||||
break;
|
||||
case PROP_MULTICAST_HASH_MAX:
|
||||
g_value_set_uint (value, priv->multicast_hash_max);
|
||||
break;
|
||||
case PROP_MULTICAST_LAST_MEMBER_COUNT:
|
||||
g_value_set_uint (value, priv->multicast_last_member_count);
|
||||
break;
|
||||
case PROP_MULTICAST_LAST_MEMBER_INTERVAL:
|
||||
g_value_set_uint64 (value, priv->multicast_last_member_interval);
|
||||
break;
|
||||
case PROP_MULTICAST_MEMBERSHIP_INTERVAL:
|
||||
g_value_set_uint64 (value, priv->multicast_membership_interval);
|
||||
break;
|
||||
case PROP_MULTICAST_SNOOPING:
|
||||
g_value_set_boolean (value, priv->multicast_snooping);
|
||||
break;
|
||||
|
|
@ -1244,9 +1416,24 @@ get_property (GObject *object, guint prop_id,
|
|||
case PROP_MULTICAST_QUERIER:
|
||||
g_value_set_boolean (value, priv->multicast_querier);
|
||||
break;
|
||||
case PROP_MULTICAST_QUERIER_INTERVAL:
|
||||
g_value_set_uint64 (value, priv->multicast_querier_interval);
|
||||
break;
|
||||
case PROP_MULTICAST_QUERY_INTERVAL:
|
||||
g_value_set_uint64 (value, priv->multicast_query_interval);
|
||||
break;
|
||||
case PROP_MULTICAST_QUERY_RESPONSE_INTERVAL:
|
||||
g_value_set_uint64 (value, priv->multicast_query_response_interval);
|
||||
break;
|
||||
case PROP_MULTICAST_QUERY_USE_IFADDR:
|
||||
g_value_set_boolean (value, priv->multicast_query_use_ifaddr);
|
||||
break;
|
||||
case PROP_MULTICAST_STARTUP_QUERY_COUNT:
|
||||
g_value_set_uint (value, priv->multicast_startup_query_count);
|
||||
break;
|
||||
case PROP_MULTICAST_STARTUP_QUERY_INTERVAL:
|
||||
g_value_set_uint64 (value, priv->multicast_startup_query_interval);
|
||||
break;
|
||||
case PROP_VLAN_FILTERING:
|
||||
g_value_set_boolean (value, priv->vlan_filtering);
|
||||
break;
|
||||
|
|
@ -1308,6 +1495,18 @@ set_property (GObject *object, guint prop_id,
|
|||
case PROP_GROUP_FORWARD_MASK:
|
||||
priv->group_forward_mask = (guint16) g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_MULTICAST_HASH_MAX:
|
||||
priv->multicast_hash_max = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_MULTICAST_LAST_MEMBER_COUNT:
|
||||
priv->multicast_last_member_count = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_MULTICAST_LAST_MEMBER_INTERVAL:
|
||||
priv->multicast_last_member_interval = g_value_get_uint64 (value);
|
||||
break;
|
||||
case PROP_MULTICAST_MEMBERSHIP_INTERVAL:
|
||||
priv->multicast_membership_interval = g_value_get_uint64 (value);
|
||||
break;
|
||||
case PROP_MULTICAST_SNOOPING:
|
||||
priv->multicast_snooping = g_value_get_boolean (value);
|
||||
break;
|
||||
|
|
@ -1318,9 +1517,24 @@ set_property (GObject *object, guint prop_id,
|
|||
case PROP_MULTICAST_QUERIER:
|
||||
priv->multicast_querier = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_MULTICAST_QUERIER_INTERVAL:
|
||||
priv->multicast_querier_interval = g_value_get_uint64 (value);
|
||||
break;
|
||||
case PROP_MULTICAST_QUERY_INTERVAL:
|
||||
priv->multicast_query_interval = g_value_get_uint64 (value);
|
||||
break;
|
||||
case PROP_MULTICAST_QUERY_RESPONSE_INTERVAL:
|
||||
priv->multicast_query_response_interval = g_value_get_uint64 (value);
|
||||
break;
|
||||
case PROP_MULTICAST_QUERY_USE_IFADDR:
|
||||
priv->multicast_query_use_ifaddr = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_MULTICAST_STARTUP_QUERY_COUNT:
|
||||
priv->multicast_startup_query_count = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_MULTICAST_STARTUP_QUERY_INTERVAL:
|
||||
priv->multicast_startup_query_interval = g_value_get_uint64 (value);
|
||||
break;
|
||||
case PROP_VLAN_FILTERING:
|
||||
priv->vlan_filtering = g_value_get_boolean (value);
|
||||
break;
|
||||
|
|
@ -1355,17 +1569,27 @@ nm_setting_bridge_init (NMSettingBridge *setting)
|
|||
|
||||
priv->vlans = g_ptr_array_new_with_free_func ((GDestroyNotify) nm_bridge_vlan_unref);
|
||||
|
||||
priv->ageing_time = BRIDGE_AGEING_TIME_DEFAULT;
|
||||
priv->forward_delay = BRIDGE_FORWARD_DELAY_DEFAULT;
|
||||
priv->hello_time = BRIDGE_HELLO_TIME_DEFAULT;
|
||||
priv->max_age = BRIDGE_MAX_AGE_DEFAULT;
|
||||
priv->multicast_snooping = BRIDGE_MULTICAST_SNOOPING_DEFAULT;
|
||||
priv->priority = BRIDGE_PRIORITY_DEFAULT;
|
||||
priv->stp = BRIDGE_STP_DEFAULT;
|
||||
priv->vlan_default_pvid = BRIDGE_VLAN_DEFAULT_PVID_DEFAULT;
|
||||
priv->vlan_stats_enabled = BRIDGE_VLAN_STATS_ENABLED_DEFAULT;
|
||||
priv->multicast_query_use_ifaddr = BRIDGE_MULTICAST_QUERY_USE_IFADDR_DEFAULT;
|
||||
priv->multicast_querier = BRIDGE_MULTICAST_QUERIER_DEFAULT;
|
||||
priv->ageing_time = NM_BRIDGE_AGEING_TIME_DEF;
|
||||
priv->forward_delay = NM_BRIDGE_FORWARD_DELAY_DEF;
|
||||
priv->hello_time = NM_BRIDGE_HELLO_TIME_DEF;
|
||||
priv->max_age = NM_BRIDGE_MAX_AGE_DEF;
|
||||
priv->multicast_last_member_count = NM_BRIDGE_MULTICAST_LAST_MEMBER_COUNT_DEF;
|
||||
priv->multicast_last_member_interval = NM_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL_DEF;
|
||||
priv->multicast_membership_interval = NM_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL_DEF;
|
||||
priv->multicast_hash_max = NM_BRIDGE_MULTICAST_HASH_MAX_DEF;
|
||||
priv->multicast_snooping = NM_BRIDGE_MULTICAST_SNOOPING_DEF;
|
||||
priv->priority = NM_BRIDGE_PRIORITY_DEF;
|
||||
priv->stp = NM_BRIDGE_STP_DEF;
|
||||
priv->vlan_default_pvid = NM_BRIDGE_VLAN_DEFAULT_PVID_DEF;
|
||||
priv->multicast_query_interval = NM_BRIDGE_MULTICAST_QUERY_INTERVAL_DEF;
|
||||
priv->multicast_query_response_interval = NM_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL_DEF;
|
||||
priv->multicast_querier_interval = NM_BRIDGE_MULTICAST_QUERIER_INTERVAL_DEF;
|
||||
priv->multicast_startup_query_count = NM_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT_DEF;
|
||||
priv->multicast_startup_query_interval = NM_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL_DEF;
|
||||
|
||||
nm_assert (priv->multicast_querier == NM_BRIDGE_MULTICAST_QUERIER_DEF);
|
||||
nm_assert (priv->multicast_query_use_ifaddr == NM_BRIDGE_MULTICAST_QUERY_USE_IFADDR_DEF);
|
||||
nm_assert (priv->vlan_stats_enabled == NM_BRIDGE_VLAN_STATS_ENABLED_DEF);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1461,7 +1685,7 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *klass)
|
|||
*/
|
||||
obj_properties[PROP_STP] =
|
||||
g_param_spec_boolean (NM_SETTING_BRIDGE_STP, "", "",
|
||||
BRIDGE_STP_DEFAULT,
|
||||
NM_BRIDGE_STP_DEF,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
|
@ -1483,7 +1707,7 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *klass)
|
|||
*/
|
||||
obj_properties[PROP_PRIORITY] =
|
||||
g_param_spec_uint (NM_SETTING_BRIDGE_PRIORITY, "", "",
|
||||
0, G_MAXUINT16, BRIDGE_PRIORITY_DEFAULT,
|
||||
NM_BRIDGE_PRIORITY_MIN, NM_BRIDGE_PRIORITY_MAX, NM_BRIDGE_PRIORITY_DEF,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
|
@ -1503,7 +1727,7 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *klass)
|
|||
*/
|
||||
obj_properties[PROP_FORWARD_DELAY] =
|
||||
g_param_spec_uint (NM_SETTING_BRIDGE_FORWARD_DELAY, "", "",
|
||||
0, NM_BR_MAX_FORWARD_DELAY, BRIDGE_FORWARD_DELAY_DEFAULT,
|
||||
0, NM_BRIDGE_FORWARD_DELAY_MAX, NM_BRIDGE_FORWARD_DELAY_DEF,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
|
@ -1523,7 +1747,7 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *klass)
|
|||
*/
|
||||
obj_properties[PROP_HELLO_TIME] =
|
||||
g_param_spec_uint (NM_SETTING_BRIDGE_HELLO_TIME, "", "",
|
||||
0, NM_BR_MAX_HELLO_TIME, BRIDGE_HELLO_TIME_DEFAULT,
|
||||
0, NM_BRIDGE_HELLO_TIME_MAX, NM_BRIDGE_HELLO_TIME_DEF,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
|
@ -1543,7 +1767,7 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *klass)
|
|||
*/
|
||||
obj_properties[PROP_MAX_AGE] =
|
||||
g_param_spec_uint (NM_SETTING_BRIDGE_MAX_AGE, "", "",
|
||||
0, NM_BR_MAX_MAX_AGE, BRIDGE_MAX_AGE_DEFAULT,
|
||||
0, NM_BRIDGE_MAX_AGE_MAX, NM_BRIDGE_MAX_AGE_DEF,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
|
@ -1563,7 +1787,7 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *klass)
|
|||
*/
|
||||
obj_properties[PROP_AGEING_TIME] =
|
||||
g_param_spec_uint (NM_SETTING_BRIDGE_AGEING_TIME, "", "",
|
||||
NM_BR_MIN_AGEING_TIME, NM_BR_MAX_AGEING_TIME, BRIDGE_AGEING_TIME_DEFAULT,
|
||||
NM_BRIDGE_AGEING_TIME_MIN, NM_BRIDGE_AGEING_TIME_MAX, NM_BRIDGE_AGEING_TIME_DEF,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
|
@ -1607,7 +1831,7 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *klass)
|
|||
*/
|
||||
obj_properties[PROP_MULTICAST_SNOOPING] =
|
||||
g_param_spec_boolean (NM_SETTING_BRIDGE_MULTICAST_SNOOPING, "", "",
|
||||
BRIDGE_MULTICAST_SNOOPING_DEFAULT,
|
||||
NM_BRIDGE_MULTICAST_SNOOPING_DEF,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
|
@ -1652,7 +1876,7 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *klass)
|
|||
*/
|
||||
obj_properties[PROP_VLAN_DEFAULT_PVID] =
|
||||
g_param_spec_uint (NM_SETTING_BRIDGE_VLAN_DEFAULT_PVID, "", "",
|
||||
0, NM_BRIDGE_VLAN_VID_MAX, BRIDGE_VLAN_DEFAULT_PVID_DEFAULT,
|
||||
0, NM_BRIDGE_VLAN_VID_MAX, NM_BRIDGE_VLAN_DEFAULT_PVID_DEF,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
|
@ -1767,7 +1991,7 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *klass)
|
|||
*/
|
||||
obj_properties[PROP_VLAN_STATS_ENABLED] =
|
||||
g_param_spec_boolean (NM_SETTING_BRIDGE_VLAN_STATS_ENABLED, "", "",
|
||||
BRIDGE_VLAN_STATS_ENABLED_DEFAULT,
|
||||
NM_BRIDGE_VLAN_STATS_ENABLED_DEF,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
|
@ -1816,7 +2040,7 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *klass)
|
|||
*/
|
||||
obj_properties[PROP_MULTICAST_QUERY_USE_IFADDR] =
|
||||
g_param_spec_boolean (NM_SETTING_BRIDGE_MULTICAST_QUERY_USE_IFADDR, "", "",
|
||||
BRIDGE_MULTICAST_QUERY_USE_IFADDR_DEFAULT,
|
||||
NM_BRIDGE_MULTICAST_QUERY_USE_IFADDR_DEF,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
|
@ -1838,11 +2062,209 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *klass)
|
|||
*/
|
||||
obj_properties[PROP_MULTICAST_QUERIER] =
|
||||
g_param_spec_boolean (NM_SETTING_BRIDGE_MULTICAST_QUERIER, "", "",
|
||||
BRIDGE_MULTICAST_QUERIER_DEFAULT,
|
||||
NM_BRIDGE_MULTICAST_QUERIER_DEF,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:multicast-hash-max:
|
||||
*
|
||||
* Set maximum size of multicast hash table (value must be a power of 2).
|
||||
**/
|
||||
/* ---ifcfg-rh---
|
||||
* property: multicast-hash-max
|
||||
* variable: BRIDGING_OPTS: multicast_hash_max=
|
||||
* default: 4096
|
||||
* example: BRIDGING_OPTS="multicast_hash_max=8192"
|
||||
* ---end---
|
||||
*
|
||||
* Since: 1.26
|
||||
*/
|
||||
obj_properties[PROP_MULTICAST_HASH_MAX] =
|
||||
g_param_spec_uint (NM_SETTING_BRIDGE_MULTICAST_HASH_MAX, "", "",
|
||||
NM_BRIDGE_MULTICAST_HASH_MAX_MIN, NM_BRIDGE_MULTICAST_HASH_MAX_MAX, NM_BRIDGE_MULTICAST_HASH_MAX_DEF,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:multicast-last-member-count:
|
||||
*
|
||||
* Set the number of queries the bridge will send before
|
||||
* stopping forwarding a multicast group after a "leave"
|
||||
* message has been received.
|
||||
**/
|
||||
/* ---ifcfg-rh---
|
||||
* property: multicast-last-member-count
|
||||
* variable: BRIDGING_OPTS: multicast_last_member_count=
|
||||
* default: 2
|
||||
* example: BRIDGING_OPTS="multicast_last_member_count=4"
|
||||
* ---end---
|
||||
*
|
||||
* Since: 1.26
|
||||
*/
|
||||
obj_properties[PROP_MULTICAST_LAST_MEMBER_COUNT] =
|
||||
g_param_spec_uint (NM_SETTING_BRIDGE_MULTICAST_LAST_MEMBER_COUNT, "", "",
|
||||
NM_BRIDGE_MULTICAST_LAST_MEMBER_COUNT_MIN, NM_BRIDGE_MULTICAST_LAST_MEMBER_COUNT_MAX, NM_BRIDGE_MULTICAST_LAST_MEMBER_COUNT_DEF,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:multicast-last-member-interval:
|
||||
*
|
||||
* Set interval (in deciseconds) between queries to find remaining
|
||||
* members of a group, after a "leave" message is received.
|
||||
**/
|
||||
/* ---ifcfg-rh---
|
||||
* property: multicast-last-member-interval
|
||||
* variable: BRIDGING_OPTS: multicast_last_member_interval=
|
||||
* default: 100
|
||||
* example: BRIDGING_OPTS="multicast_last_member_interval=200"
|
||||
* ---end---
|
||||
*
|
||||
* Since: 1.26
|
||||
*/
|
||||
obj_properties[PROP_MULTICAST_LAST_MEMBER_INTERVAL] =
|
||||
g_param_spec_uint64 (NM_SETTING_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL, "", "",
|
||||
NM_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL_MIN, NM_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL_MAX, NM_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL_DEF,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:multicast-membership-interval:
|
||||
*
|
||||
* Set delay (in deciseconds) after which the bridge will
|
||||
* leave a group, if no membership reports for this
|
||||
* group are received.
|
||||
**/
|
||||
/* ---ifcfg-rh---
|
||||
* property: multicast-membership-interval
|
||||
* variable: BRIDGING_OPTS: multicast_membership_interval=
|
||||
* default: 26000
|
||||
* example: BRIDGING_OPTS="multicast_membership_interval=16000"
|
||||
* ---end---
|
||||
*
|
||||
* Since: 1.26
|
||||
*/
|
||||
obj_properties[PROP_MULTICAST_MEMBERSHIP_INTERVAL] =
|
||||
g_param_spec_uint64 (NM_SETTING_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL, "", "",
|
||||
NM_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL_MIN, NM_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL_MAX, NM_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL_DEF,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:multicast-querier-interval:
|
||||
*
|
||||
* If no queries are seen after this delay (in deciseconds) has passed,
|
||||
* the bridge will start to send its own queries.
|
||||
**/
|
||||
/* ---ifcfg-rh---
|
||||
* property: multicast-querier-interval
|
||||
* variable: BRIDGING_OPTS: multicast_querier_interval=
|
||||
* default: 25500
|
||||
* example: BRIDGING_OPTS="multicast_querier_interval=20000"
|
||||
* ---end---
|
||||
*
|
||||
* Since: 1.26
|
||||
*/
|
||||
obj_properties[PROP_MULTICAST_QUERIER_INTERVAL] =
|
||||
g_param_spec_uint64 (NM_SETTING_BRIDGE_MULTICAST_QUERIER_INTERVAL, "", "",
|
||||
NM_BRIDGE_MULTICAST_QUERIER_INTERVAL_MIN, NM_BRIDGE_MULTICAST_QUERIER_INTERVAL_MAX, NM_BRIDGE_MULTICAST_QUERIER_INTERVAL_DEF,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:multicast-query-interval:
|
||||
*
|
||||
* Interval (in deciseconds) between queries sent
|
||||
* by the bridge after the end of the startup phase.
|
||||
**/
|
||||
/* ---ifcfg-rh---
|
||||
* property: multicast-query-interval
|
||||
* variable: BRIDGING_OPTS: multicast_query_interval=
|
||||
* default: 12500
|
||||
* example: BRIDGING_OPTS="multicast_query_interval=22500"
|
||||
* ---end---
|
||||
*
|
||||
* Since: 1.26
|
||||
*/
|
||||
obj_properties[PROP_MULTICAST_QUERY_INTERVAL] =
|
||||
g_param_spec_uint64 (NM_SETTING_BRIDGE_MULTICAST_QUERY_INTERVAL, "", "",
|
||||
NM_BRIDGE_MULTICAST_QUERY_INTERVAL_MIN, NM_BRIDGE_MULTICAST_QUERY_INTERVAL_MAX, NM_BRIDGE_MULTICAST_QUERY_INTERVAL_DEF,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:multicast-query-response-interval:
|
||||
*
|
||||
* Set the Max Response Time/Max Response Delay
|
||||
* (in deciseconds) for IGMP/MLD queries sent by the bridge.
|
||||
**/
|
||||
/* ---ifcfg-rh---
|
||||
* property: multicast-query-response-interval
|
||||
* variable: BRIDGING_OPTS: multicast_query_response_interval=
|
||||
* default: 1000
|
||||
* example: BRIDGING_OPTS="multicast_query_response_interval=2000"
|
||||
* ---end---
|
||||
*
|
||||
* Since: 1.26
|
||||
*/
|
||||
obj_properties[PROP_MULTICAST_QUERY_RESPONSE_INTERVAL] =
|
||||
g_param_spec_uint64 (NM_SETTING_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL, "", "",
|
||||
NM_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL_MIN, NM_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL_MAX, NM_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL_DEF,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:multicast-startup-query-count:
|
||||
*
|
||||
* Set the number of IGMP queries to send during startup phase.
|
||||
**/
|
||||
/* ---ifcfg-rh---
|
||||
* property: multicast-startup-query-count
|
||||
* variable: BRIDGING_OPTS: multicast_startup_query_count=
|
||||
* default: 2
|
||||
* example: BRIDGING_OPTS="multicast_startup_query_count=4"
|
||||
* ---end---
|
||||
*
|
||||
* Since: 1.26
|
||||
*/
|
||||
obj_properties[PROP_MULTICAST_STARTUP_QUERY_COUNT] =
|
||||
g_param_spec_uint (NM_SETTING_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT, "", "",
|
||||
NM_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT_MIN, NM_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT_MAX, NM_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT_DEF,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:multicast-startup-query-interval:
|
||||
*
|
||||
* Sets the time (in deciseconds) between queries sent out
|
||||
* at startup to determine membership information.
|
||||
**/
|
||||
/* ---ifcfg-rh---
|
||||
* property: multicast-startup-query-interval
|
||||
* variable: BRIDGING_OPTS: multicast_startup_query_interval=
|
||||
* default: 3125
|
||||
* example: BRIDGING_OPTS="multicast_startup_query_interval=4000"
|
||||
* ---end---
|
||||
*
|
||||
* Since: 1.26
|
||||
*/
|
||||
obj_properties[PROP_MULTICAST_STARTUP_QUERY_INTERVAL] =
|
||||
g_param_spec_uint64 (NM_SETTING_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL, "", "",
|
||||
NM_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL_MIN, NM_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL_MAX, NM_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL_DEF,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
|
||||
_nm_setting_class_commit_full (setting_class, NM_META_SETTING_TYPE_BRIDGE,
|
||||
|
|
|
|||
|
|
@ -23,24 +23,33 @@ G_BEGIN_DECLS
|
|||
|
||||
#define NM_SETTING_BRIDGE_SETTING_NAME "bridge"
|
||||
|
||||
#define NM_SETTING_BRIDGE_MAC_ADDRESS "mac-address"
|
||||
#define NM_SETTING_BRIDGE_STP "stp"
|
||||
#define NM_SETTING_BRIDGE_PRIORITY "priority"
|
||||
#define NM_SETTING_BRIDGE_FORWARD_DELAY "forward-delay"
|
||||
#define NM_SETTING_BRIDGE_HELLO_TIME "hello-time"
|
||||
#define NM_SETTING_BRIDGE_MAX_AGE "max-age"
|
||||
#define NM_SETTING_BRIDGE_AGEING_TIME "ageing-time"
|
||||
#define NM_SETTING_BRIDGE_GROUP_FORWARD_MASK "group-forward-mask"
|
||||
#define NM_SETTING_BRIDGE_MULTICAST_SNOOPING "multicast-snooping"
|
||||
#define NM_SETTING_BRIDGE_MULTICAST_ROUTER "multicast-router"
|
||||
#define NM_SETTING_BRIDGE_MULTICAST_QUERIER "multicast-querier"
|
||||
#define NM_SETTING_BRIDGE_MULTICAST_QUERY_USE_IFADDR "multicast-query-use-ifaddr"
|
||||
#define NM_SETTING_BRIDGE_VLAN_FILTERING "vlan-filtering"
|
||||
#define NM_SETTING_BRIDGE_VLAN_DEFAULT_PVID "vlan-default-pvid"
|
||||
#define NM_SETTING_BRIDGE_VLANS "vlans"
|
||||
#define NM_SETTING_BRIDGE_GROUP_ADDRESS "group-address"
|
||||
#define NM_SETTING_BRIDGE_VLAN_PROTOCOL "vlan-protocol"
|
||||
#define NM_SETTING_BRIDGE_VLAN_STATS_ENABLED "vlan-stats-enabled"
|
||||
#define NM_SETTING_BRIDGE_MAC_ADDRESS "mac-address"
|
||||
#define NM_SETTING_BRIDGE_STP "stp"
|
||||
#define NM_SETTING_BRIDGE_PRIORITY "priority"
|
||||
#define NM_SETTING_BRIDGE_FORWARD_DELAY "forward-delay"
|
||||
#define NM_SETTING_BRIDGE_HELLO_TIME "hello-time"
|
||||
#define NM_SETTING_BRIDGE_MAX_AGE "max-age"
|
||||
#define NM_SETTING_BRIDGE_AGEING_TIME "ageing-time"
|
||||
#define NM_SETTING_BRIDGE_GROUP_FORWARD_MASK "group-forward-mask"
|
||||
#define NM_SETTING_BRIDGE_MULTICAST_HASH_MAX "multicast-hash-max"
|
||||
#define NM_SETTING_BRIDGE_MULTICAST_LAST_MEMBER_COUNT "multicast-last-member-count"
|
||||
#define NM_SETTING_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL "multicast-last-member-interval"
|
||||
#define NM_SETTING_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL "multicast-membership-interval"
|
||||
#define NM_SETTING_BRIDGE_MULTICAST_SNOOPING "multicast-snooping"
|
||||
#define NM_SETTING_BRIDGE_MULTICAST_ROUTER "multicast-router"
|
||||
#define NM_SETTING_BRIDGE_MULTICAST_QUERIER "multicast-querier"
|
||||
#define NM_SETTING_BRIDGE_MULTICAST_QUERIER_INTERVAL "multicast-querier-interval"
|
||||
#define NM_SETTING_BRIDGE_MULTICAST_QUERY_INTERVAL "multicast-query-interval"
|
||||
#define NM_SETTING_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL "multicast-query-response-interval"
|
||||
#define NM_SETTING_BRIDGE_MULTICAST_QUERY_USE_IFADDR "multicast-query-use-ifaddr"
|
||||
#define NM_SETTING_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT "multicast-startup-query-count"
|
||||
#define NM_SETTING_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL "multicast-startup-query-interval"
|
||||
#define NM_SETTING_BRIDGE_VLAN_FILTERING "vlan-filtering"
|
||||
#define NM_SETTING_BRIDGE_VLAN_DEFAULT_PVID "vlan-default-pvid"
|
||||
#define NM_SETTING_BRIDGE_VLANS "vlans"
|
||||
#define NM_SETTING_BRIDGE_GROUP_ADDRESS "group-address"
|
||||
#define NM_SETTING_BRIDGE_VLAN_PROTOCOL "vlan-protocol"
|
||||
#define NM_SETTING_BRIDGE_VLAN_STATS_ENABLED "vlan-stats-enabled"
|
||||
|
||||
#define NM_BRIDGE_VLAN_VID_MIN 1
|
||||
#define NM_BRIDGE_VLAN_VID_MAX 4094
|
||||
|
|
@ -140,6 +149,33 @@ gboolean nm_setting_bridge_get_multicast_query_use_ifaddr (const NMSettingBridge
|
|||
NM_AVAILABLE_IN_1_24
|
||||
gboolean nm_setting_bridge_get_multicast_querier (const NMSettingBridge *setting);
|
||||
|
||||
NM_AVAILABLE_IN_1_26
|
||||
guint32 nm_setting_bridge_get_multicast_hash_max (const NMSettingBridge *setting);
|
||||
|
||||
NM_AVAILABLE_IN_1_26
|
||||
guint32 nm_setting_bridge_get_multicast_last_member_count (const NMSettingBridge *setting);
|
||||
|
||||
NM_AVAILABLE_IN_1_26
|
||||
guint64 nm_setting_bridge_get_multicast_last_member_interval (const NMSettingBridge *setting);
|
||||
|
||||
NM_AVAILABLE_IN_1_26
|
||||
guint64 nm_setting_bridge_get_multicast_membership_interval (const NMSettingBridge *setting);
|
||||
|
||||
NM_AVAILABLE_IN_1_26
|
||||
guint64 nm_setting_bridge_get_multicast_querier_interval (const NMSettingBridge *setting);
|
||||
|
||||
NM_AVAILABLE_IN_1_26
|
||||
guint64 nm_setting_bridge_get_multicast_query_interval (const NMSettingBridge *setting);
|
||||
|
||||
NM_AVAILABLE_IN_1_26
|
||||
guint64 nm_setting_bridge_get_multicast_query_response_interval (const NMSettingBridge *setting);
|
||||
|
||||
NM_AVAILABLE_IN_1_26
|
||||
guint32 nm_setting_bridge_get_multicast_startup_query_count (const NMSettingBridge *setting);
|
||||
|
||||
NM_AVAILABLE_IN_1_26
|
||||
guint64 nm_setting_bridge_get_multicast_startup_query_interval (const NMSettingBridge *setting);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NM_SETTING_BRIDGE_H__ */
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "nm-setting-connection.h"
|
||||
|
||||
#include "nm-libnm-core-intern/nm-common-macros.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-utils-private.h"
|
||||
#include "nm-core-enum-types.h"
|
||||
|
|
@ -16,6 +17,7 @@
|
|||
#include "nm-setting-bridge.h"
|
||||
#include "nm-setting-team.h"
|
||||
#include "nm-setting-vlan.h"
|
||||
#include "systemd/nm-sd-utils-shared.h"
|
||||
|
||||
/**
|
||||
* SECTION:nm-setting-connection
|
||||
|
|
@ -63,6 +65,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMSettingConnection,
|
|||
PROP_STABLE_ID,
|
||||
PROP_AUTH_RETRIES,
|
||||
PROP_WAIT_DEVICE_TIMEOUT,
|
||||
PROP_MUD_URL,
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -76,6 +79,7 @@ typedef struct {
|
|||
char *master;
|
||||
char *slave_type;
|
||||
char *zone;
|
||||
char *mud_url;
|
||||
guint64 timestamp;
|
||||
int autoconnect_priority;
|
||||
int autoconnect_retries;
|
||||
|
|
@ -750,6 +754,23 @@ nm_setting_connection_get_secondary (NMSettingConnection *setting, guint32 idx)
|
|||
return (const char *) g_slist_nth_data (priv->secondaries, idx);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_connection_get_mud_url:
|
||||
* @setting: the #NMSettingConnection
|
||||
*
|
||||
* Returns the value contained in the #NMSettingConnection:mud-url
|
||||
* property.
|
||||
*
|
||||
* Since: 1.26
|
||||
**/
|
||||
const char *
|
||||
nm_setting_connection_get_mud_url (NMSettingConnection *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL);
|
||||
|
||||
return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->mud_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_connection_add_secondary:
|
||||
* @setting: the #NMSettingConnection
|
||||
|
|
@ -1211,6 +1232,31 @@ after_interface_name:
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (priv->mud_url) {
|
||||
if (!priv->mud_url[0]) {
|
||||
g_set_error_literal (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("property is empty"));
|
||||
g_prefix_error (error, "%s.%s: ", nm_setting_get_name (setting), NM_SETTING_CONNECTION_MUD_URL);
|
||||
return FALSE;
|
||||
}
|
||||
if (nm_streq (priv->mud_url, NM_CONNECTION_MUD_URL_NONE)) {
|
||||
/* pass */
|
||||
} else {
|
||||
if (strlen (priv->mud_url) > 255) {
|
||||
g_set_error_literal (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("DHCP option cannot be longer than 255 characters"));
|
||||
g_prefix_error (error, "%s.%s: ", nm_setting_get_name (setting), NM_SETTING_CONNECTION_MUD_URL);
|
||||
return FALSE;
|
||||
}
|
||||
if (!nm_sd_http_url_is_valid_https (priv->mud_url)) {
|
||||
g_set_error_literal (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("MUD URL is not a valid URL"));
|
||||
g_prefix_error (error, "%s.%s: ", nm_setting_get_name (setting), NM_SETTING_CONNECTION_MUD_URL);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* *** errors above here should be always fatal, below NORMALIZABLE_ERROR *** */
|
||||
|
||||
if (!priv->uuid) {
|
||||
|
|
@ -1467,6 +1513,9 @@ get_property (GObject *object, guint prop_id,
|
|||
case PROP_WAIT_DEVICE_TIMEOUT:
|
||||
g_value_set_int (value, priv->wait_device_timeout);
|
||||
break;
|
||||
case PROP_MUD_URL:
|
||||
g_value_set_string (value, priv->mud_url);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -1562,6 +1611,10 @@ set_property (GObject *object, guint prop_id,
|
|||
case PROP_WAIT_DEVICE_TIMEOUT:
|
||||
priv->wait_device_timeout = g_value_get_int (value);
|
||||
break;
|
||||
case PROP_MUD_URL:
|
||||
g_free (priv->mud_url);
|
||||
priv->mud_url = g_value_dup_string (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -1611,6 +1664,7 @@ finalize (GObject *object)
|
|||
g_free (priv->zone);
|
||||
g_free (priv->master);
|
||||
g_free (priv->slave_type);
|
||||
g_free (priv->mud_url);
|
||||
g_slist_free_full (priv->permissions, (GDestroyNotify) permission_free);
|
||||
g_slist_free_full (priv->secondaries, g_free);
|
||||
|
||||
|
|
@ -2286,6 +2340,35 @@ nm_setting_connection_class_init (NMSettingConnectionClass *klass)
|
|||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
|
||||
/**
|
||||
* NMSettingConnection:mud-url:
|
||||
*
|
||||
* If configured, set to a Manufacturer Usage Description (MUD) URL that points
|
||||
* to manufacturer-recommended network policies for IoT devices. It is transmitted
|
||||
* as a DHCPv4 or DHCPv6 option. The value must be a valid URL starting with "https://".
|
||||
*
|
||||
* The special value "none" is allowed to indicate that no MUD URL is used.
|
||||
*
|
||||
* If the per-profile value is unspecified (the default), a global connection default gets
|
||||
* consulted. If still unspecified, the ultimate default is "none".
|
||||
*
|
||||
* Since: 1.26
|
||||
**/
|
||||
/* ---ifcfg-rh---
|
||||
* property: mud-url
|
||||
* variable: MUD_URL
|
||||
* values: a valid URL that points to recommended policy for this device
|
||||
* description: MUD_URL to be sent by device (See RFC 8520).
|
||||
* example: https://yourdevice.example.com/model.json
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_MUD_URL] =
|
||||
g_param_spec_string (NM_SETTING_CONNECTION_MUD_URL, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
|
||||
_nm_setting_class_commit_full (setting_class, NM_META_SETTING_TYPE_CONNECTION,
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ G_BEGIN_DECLS
|
|||
#define NM_SETTING_CONNECTION_MDNS "mdns"
|
||||
#define NM_SETTING_CONNECTION_LLMNR "llmnr"
|
||||
#define NM_SETTING_CONNECTION_WAIT_DEVICE_TIMEOUT "wait-device-timeout"
|
||||
#define NM_SETTING_CONNECTION_MUD_URL "mud-url"
|
||||
|
||||
/* Types for property values */
|
||||
/**
|
||||
|
|
@ -204,6 +205,9 @@ NMSettingConnectionLlmnr nm_setting_connection_get_llmnr (NMSettingConnection *
|
|||
NM_AVAILABLE_IN_1_20
|
||||
gint32 nm_setting_connection_get_wait_device_timeout (NMSettingConnection *setting);
|
||||
|
||||
NM_AVAILABLE_IN_1_26
|
||||
const char *nm_setting_connection_get_mud_url (NMSettingConnection *setting);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NM_SETTING_CONNECTION_H__ */
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
NM_GOBJECT_PROPERTIES_DEFINE (NMSettingMatch,
|
||||
PROP_INTERFACE_NAME,
|
||||
PROP_KERNEL_COMMAND_LINE,
|
||||
PROP_DRIVER,
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
@ -31,7 +33,9 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMSettingMatch,
|
|||
*/
|
||||
struct _NMSettingMatch {
|
||||
NMSetting parent;
|
||||
GPtrArray *interface_name;
|
||||
GArray *interface_name;
|
||||
GArray *kernel_command_line;
|
||||
GArray *driver;
|
||||
};
|
||||
|
||||
struct _NMSettingMatchClass {
|
||||
|
|
@ -55,7 +59,7 @@ nm_setting_match_get_num_interface_names (NMSettingMatch *setting)
|
|||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_MATCH (setting), 0);
|
||||
|
||||
return setting->interface_name->len;
|
||||
return nm_g_array_len (setting->interface_name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -72,9 +76,9 @@ nm_setting_match_get_interface_name (NMSettingMatch *setting, int idx)
|
|||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_MATCH (setting), NULL);
|
||||
|
||||
g_return_val_if_fail (idx >= 0 && idx < setting->interface_name->len, NULL);
|
||||
g_return_val_if_fail (setting->interface_name && idx >= 0 && idx < setting->interface_name->len, NULL);
|
||||
|
||||
return setting->interface_name->pdata[idx];
|
||||
return g_array_index (setting->interface_name, const char *, idx);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -94,7 +98,7 @@ nm_setting_match_add_interface_name (NMSettingMatch *setting,
|
|||
g_return_if_fail (interface_name != NULL);
|
||||
g_return_if_fail (interface_name[0] != '\0');
|
||||
|
||||
g_ptr_array_add (setting->interface_name, g_strdup (interface_name));
|
||||
nm_strvarray_add (nm_strvarray_ensure (&setting->interface_name), interface_name);
|
||||
_notify (setting, PROP_INTERFACE_NAME);
|
||||
}
|
||||
|
||||
|
|
@ -112,9 +116,9 @@ nm_setting_match_remove_interface_name (NMSettingMatch *setting, int idx)
|
|||
{
|
||||
g_return_if_fail (NM_IS_SETTING_MATCH (setting));
|
||||
|
||||
g_return_if_fail (idx >= 0 && idx < setting->interface_name->len);
|
||||
g_return_if_fail (setting->interface_name && idx >= 0 && idx < setting->interface_name->len);
|
||||
|
||||
g_ptr_array_remove_index (setting->interface_name, idx);
|
||||
g_array_remove_index (setting->interface_name, idx);
|
||||
_notify (setting, PROP_INTERFACE_NAME);
|
||||
}
|
||||
|
||||
|
|
@ -139,9 +143,12 @@ nm_setting_match_remove_interface_name_by_value (NMSettingMatch *setting,
|
|||
g_return_val_if_fail (interface_name != NULL, FALSE);
|
||||
g_return_val_if_fail (interface_name[0] != '\0', FALSE);
|
||||
|
||||
if (!setting->interface_name)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < setting->interface_name->len; i++) {
|
||||
if (nm_streq (interface_name, setting->interface_name->pdata[i])) {
|
||||
g_ptr_array_remove_index (setting->interface_name, i);
|
||||
if (nm_streq (interface_name, g_array_index (setting->interface_name, const char *, i))) {
|
||||
g_array_remove_index (setting->interface_name, i);
|
||||
_notify (setting, PROP_INTERFACE_NAME);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -162,8 +169,8 @@ nm_setting_match_clear_interface_names (NMSettingMatch *setting)
|
|||
{
|
||||
g_return_if_fail (NM_IS_SETTING_MATCH (setting));
|
||||
|
||||
if (setting->interface_name->len != 0) {
|
||||
g_ptr_array_set_size (setting->interface_name, 0);
|
||||
if (nm_g_array_len (setting->interface_name) != 0) {
|
||||
nm_clear_pointer (&setting->interface_name, g_array_unref);
|
||||
_notify (setting, PROP_INTERFACE_NAME);
|
||||
}
|
||||
}
|
||||
|
|
@ -171,11 +178,14 @@ nm_setting_match_clear_interface_names (NMSettingMatch *setting)
|
|||
/**
|
||||
* nm_setting_match_get_interface_names:
|
||||
* @setting: the #NMSettingMatch
|
||||
* @length: (out): the length of the returned interface names array.
|
||||
* @length: (out) (allow-none): the length of the returned interface names array.
|
||||
*
|
||||
* Returns all the interface names.
|
||||
*
|
||||
* Returns: (transfer none) (array length=length): the configured interface names.
|
||||
* Returns: (transfer none) (array length=length): the NULL terminated list of
|
||||
* configured interface names.
|
||||
*
|
||||
* Before 1.26, the returned array was not %NULL terminated and you MUST provide a length.
|
||||
*
|
||||
* Since: 1.14
|
||||
**/
|
||||
|
|
@ -183,10 +193,308 @@ const char *const *
|
|||
nm_setting_match_get_interface_names (NMSettingMatch *setting, guint *length)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_MATCH (setting), NULL);
|
||||
g_return_val_if_fail (length, NULL);
|
||||
|
||||
NM_SET_OUT (length, setting->interface_name->len);
|
||||
return (const char *const *) setting->interface_name->pdata;
|
||||
return nm_strvarray_get_strv (&setting->interface_name, length);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* nm_setting_match_get_num_kernel_command_lines:
|
||||
* @setting: the #NMSettingMatch
|
||||
*
|
||||
* Returns: the number of configured kernel command line arguments
|
||||
*
|
||||
* Since: 1.26
|
||||
**/
|
||||
guint
|
||||
nm_setting_match_get_num_kernel_command_lines (NMSettingMatch *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_MATCH (setting), 0);
|
||||
|
||||
return nm_g_array_len (setting->kernel_command_line);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_match_get_kernel_command_line:
|
||||
* @setting: the #NMSettingMatch
|
||||
* @idx: index number of the kernel command line argument to return
|
||||
*
|
||||
* Returns: the kernel command line argument at index @idx
|
||||
*
|
||||
* Since: 1.26
|
||||
**/
|
||||
const char *
|
||||
nm_setting_match_get_kernel_command_line (NMSettingMatch *setting, guint idx)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_MATCH (setting), NULL);
|
||||
|
||||
g_return_val_if_fail (setting->kernel_command_line && idx < setting->kernel_command_line->len, NULL);
|
||||
|
||||
return g_array_index (setting->kernel_command_line, const char *, idx);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_match_add_kernel_command_line:
|
||||
* @setting: the #NMSettingMatch
|
||||
* @kernel_command_line: the kernel command line argument to add
|
||||
*
|
||||
* Adds a new kernel command line argument to the setting.
|
||||
*
|
||||
* Since: 1.26
|
||||
**/
|
||||
void
|
||||
nm_setting_match_add_kernel_command_line (NMSettingMatch *setting,
|
||||
const char *kernel_command_line)
|
||||
{
|
||||
g_return_if_fail (NM_IS_SETTING_MATCH (setting));
|
||||
g_return_if_fail (kernel_command_line != NULL);
|
||||
g_return_if_fail (kernel_command_line[0] != '\0');
|
||||
|
||||
nm_strvarray_add (nm_strvarray_ensure (&setting->kernel_command_line), kernel_command_line);
|
||||
_notify (setting, PROP_KERNEL_COMMAND_LINE);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_match_remove_kernel_command_line:
|
||||
* @setting: the #NMSettingMatch
|
||||
* @idx: index number of the kernel command line argument
|
||||
*
|
||||
* Removes the kernel command line argument at index @idx.
|
||||
*
|
||||
* Since: 1.26
|
||||
**/
|
||||
void
|
||||
nm_setting_match_remove_kernel_command_line (NMSettingMatch *setting, guint idx)
|
||||
{
|
||||
g_return_if_fail (NM_IS_SETTING_MATCH (setting));
|
||||
|
||||
g_return_if_fail (setting->kernel_command_line && idx < setting->kernel_command_line->len);
|
||||
|
||||
g_array_remove_index (setting->kernel_command_line, idx);
|
||||
_notify (setting, PROP_KERNEL_COMMAND_LINE);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_match_remove_kernel_command_line_by_value:
|
||||
* @setting: the #NMSettingMatch
|
||||
* @kernel_command_line: the kernel command line argument name to remove
|
||||
*
|
||||
* Removes @kernel_command_line.
|
||||
*
|
||||
* Returns: %TRUE if the kernel command line argument was found and removed; %FALSE if it was not.
|
||||
*
|
||||
* Since: 1.26
|
||||
**/
|
||||
gboolean
|
||||
nm_setting_match_remove_kernel_command_line_by_value (NMSettingMatch *setting,
|
||||
const char *kernel_command_line)
|
||||
{
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (NM_IS_SETTING_MATCH (setting), FALSE);
|
||||
g_return_val_if_fail (kernel_command_line != NULL, FALSE);
|
||||
g_return_val_if_fail (kernel_command_line[0] != '\0', FALSE);
|
||||
|
||||
if (!setting->kernel_command_line)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < setting->kernel_command_line->len; i++) {
|
||||
if (nm_streq (kernel_command_line, g_array_index (setting->kernel_command_line, const char *, i))) {
|
||||
g_array_remove_index (setting->kernel_command_line, i);
|
||||
_notify (setting, PROP_KERNEL_COMMAND_LINE);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_match_clear_kernel_command_lines:
|
||||
* @setting: the #NMSettingMatch
|
||||
*
|
||||
* Removes all configured kernel command line arguments.
|
||||
*
|
||||
* Since: 1.26
|
||||
**/
|
||||
void
|
||||
nm_setting_match_clear_kernel_command_lines (NMSettingMatch *setting)
|
||||
{
|
||||
g_return_if_fail (NM_IS_SETTING_MATCH (setting));
|
||||
|
||||
if (nm_g_array_len (setting->kernel_command_line) != 0) {
|
||||
nm_clear_pointer (&setting->kernel_command_line, g_array_unref);
|
||||
_notify (setting, PROP_KERNEL_COMMAND_LINE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_match_get_kernel_command_lines:
|
||||
* @setting: the #NMSettingMatch
|
||||
* @length: (out) (allow-none): the length of the returned interface names array.
|
||||
*
|
||||
* Returns all the interface names.
|
||||
*
|
||||
* Returns: (transfer none) (array length=length): the configured interface names.
|
||||
*
|
||||
* Since: 1.26
|
||||
**/
|
||||
const char *const *
|
||||
nm_setting_match_get_kernel_command_lines (NMSettingMatch *setting, guint *length)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_MATCH (setting), NULL);
|
||||
|
||||
return nm_strvarray_get_strv (&setting->kernel_command_line, length);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* nm_setting_match_get_num_drivers:
|
||||
* @setting: the #NMSettingMatch
|
||||
*
|
||||
* Returns: the number of configured drivers
|
||||
*
|
||||
* Since: 1.26
|
||||
**/
|
||||
guint
|
||||
nm_setting_match_get_num_drivers (NMSettingMatch *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_MATCH (setting), 0);
|
||||
|
||||
return nm_g_array_len (setting->driver);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_match_get_driver:
|
||||
* @setting: the #NMSettingMatch
|
||||
* @idx: index number of the DNS search domain to return
|
||||
*
|
||||
* Returns: the driver at index @idx
|
||||
*
|
||||
* Since: 1.26
|
||||
**/
|
||||
const char *
|
||||
nm_setting_match_get_driver (NMSettingMatch *setting, guint idx)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_MATCH (setting), NULL);
|
||||
|
||||
g_return_val_if_fail (setting->driver && idx < setting->driver->len, NULL);
|
||||
|
||||
return g_array_index (setting->driver, const char *, idx);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_match_add_driver:
|
||||
* @setting: the #NMSettingMatch
|
||||
* @driver: the driver to add
|
||||
*
|
||||
* Adds a new driver to the setting.
|
||||
*
|
||||
* Since: 1.26
|
||||
**/
|
||||
void
|
||||
nm_setting_match_add_driver (NMSettingMatch *setting,
|
||||
const char *driver)
|
||||
{
|
||||
g_return_if_fail (NM_IS_SETTING_MATCH (setting));
|
||||
g_return_if_fail (driver != NULL);
|
||||
g_return_if_fail (driver[0] != '\0');
|
||||
|
||||
nm_strvarray_add (nm_strvarray_ensure (&setting->driver), driver);
|
||||
_notify (setting, PROP_DRIVER);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_match_remove_driver:
|
||||
* @setting: the #NMSettingMatch
|
||||
* @idx: index number of the driver
|
||||
*
|
||||
* Removes the driver at index @idx.
|
||||
*
|
||||
* Since: 1.26
|
||||
**/
|
||||
void
|
||||
nm_setting_match_remove_driver (NMSettingMatch *setting, guint idx)
|
||||
{
|
||||
g_return_if_fail (NM_IS_SETTING_MATCH (setting));
|
||||
|
||||
g_return_if_fail (setting->driver && idx < setting->driver->len);
|
||||
|
||||
g_array_remove_index (setting->driver, idx);
|
||||
_notify (setting, PROP_DRIVER);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_match_remove_driver_by_value:
|
||||
* @setting: the #NMSettingMatch
|
||||
* @driver: the driver to remove
|
||||
*
|
||||
* Removes @driver.
|
||||
*
|
||||
* Returns: %TRUE if the driver was found and removed; %FALSE if it was not.
|
||||
*
|
||||
* Since: 1.26
|
||||
**/
|
||||
gboolean
|
||||
nm_setting_match_remove_driver_by_value (NMSettingMatch *setting,
|
||||
const char *driver)
|
||||
{
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (NM_IS_SETTING_MATCH (setting), FALSE);
|
||||
g_return_val_if_fail (driver != NULL, FALSE);
|
||||
g_return_val_if_fail (driver[0] != '\0', FALSE);
|
||||
|
||||
if (!setting->driver)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < setting->driver->len; i++) {
|
||||
if (nm_streq (driver, g_array_index (setting->driver, const char *, i))) {
|
||||
g_array_remove_index (setting->driver, i);
|
||||
_notify (setting, PROP_DRIVER);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_match_clear_drivers:
|
||||
* @setting: the #NMSettingMatch
|
||||
*
|
||||
* Removes all configured drivers.
|
||||
*
|
||||
* Since: 1.26
|
||||
**/
|
||||
void
|
||||
nm_setting_match_clear_drivers (NMSettingMatch *setting)
|
||||
{
|
||||
g_return_if_fail (NM_IS_SETTING_MATCH (setting));
|
||||
|
||||
if (nm_g_array_len (setting->driver) != 0) {
|
||||
nm_clear_pointer (&setting->driver, g_array_unref);
|
||||
_notify (setting, PROP_DRIVER);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_match_get_drivers:
|
||||
* @setting: the #NMSettingMatch
|
||||
* @length: (out) (allow-none): the length of the returned interface names array.
|
||||
*
|
||||
* Returns all the drivers.
|
||||
*
|
||||
* Returns: (transfer none) (array length=length): the configured drivers.
|
||||
*
|
||||
* Since: 1.26
|
||||
**/
|
||||
const char *const *
|
||||
nm_setting_match_get_drivers (NMSettingMatch *setting, guint *length)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_MATCH (setting), NULL);
|
||||
|
||||
return nm_strvarray_get_strv (&setting->driver, length);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -199,7 +507,13 @@ get_property (GObject *object, guint prop_id,
|
|||
|
||||
switch (prop_id) {
|
||||
case PROP_INTERFACE_NAME:
|
||||
g_value_take_boxed (value, _nm_utils_ptrarray_to_strv (self->interface_name));
|
||||
g_value_set_boxed (value, nm_strvarray_get_strv (&self->interface_name, NULL));
|
||||
break;
|
||||
case PROP_KERNEL_COMMAND_LINE:
|
||||
g_value_set_boxed (value, nm_strvarray_get_strv (&self->kernel_command_line, NULL));
|
||||
break;
|
||||
case PROP_DRIVER:
|
||||
g_value_set_boxed (value, nm_strvarray_get_strv (&self->driver, NULL));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
@ -215,8 +529,13 @@ set_property (GObject *object, guint prop_id,
|
|||
|
||||
switch (prop_id) {
|
||||
case PROP_INTERFACE_NAME:
|
||||
g_ptr_array_unref (self->interface_name);
|
||||
self->interface_name = _nm_utils_strv_to_ptrarray (g_value_get_boxed (value));
|
||||
nm_strvarray_set_strv (&self->interface_name, g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_KERNEL_COMMAND_LINE:
|
||||
nm_strvarray_set_strv (&self->kernel_command_line, g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_DRIVER:
|
||||
nm_strvarray_set_strv (&self->driver, g_value_get_boxed (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
@ -229,7 +548,6 @@ set_property (GObject *object, guint prop_id,
|
|||
static void
|
||||
nm_setting_match_init (NMSettingMatch *setting)
|
||||
{
|
||||
setting->interface_name = g_ptr_array_new_with_free_func (g_free);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -247,12 +565,65 @@ nm_setting_match_new (void)
|
|||
return (NMSetting *) g_object_new (NM_TYPE_SETTING_MATCH, NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
verify (NMSetting *setting, NMConnection *connection, GError **error)
|
||||
{
|
||||
NMSettingMatch *self = NM_SETTING_MATCH (setting);
|
||||
guint i;
|
||||
|
||||
if (self->interface_name) {
|
||||
for (i = 0; i < self->interface_name->len; i++) {
|
||||
if (nm_str_is_empty (g_array_index (self->interface_name, const char *, i))) {
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("is empty"));
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_MATCH_SETTING_NAME,
|
||||
NM_SETTING_MATCH_INTERFACE_NAME);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (self->kernel_command_line) {
|
||||
for (i = 0; i < self->kernel_command_line->len; i++) {
|
||||
if (nm_str_is_empty (g_array_index (self->kernel_command_line, const char *, i))) {
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("is empty"));
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_MATCH_SETTING_NAME,
|
||||
NM_SETTING_MATCH_KERNEL_COMMAND_LINE);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (self->driver) {
|
||||
for (i = 0; i < self->driver->len; i++) {
|
||||
if (nm_str_is_empty (g_array_index (self->driver, const char *, i))) {
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("is empty"));
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_MATCH_SETTING_NAME,
|
||||
NM_SETTING_MATCH_DRIVER);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
NMSettingMatch *self = NM_SETTING_MATCH (object);
|
||||
|
||||
g_ptr_array_unref (self->interface_name);
|
||||
nm_clear_pointer (&self->interface_name, g_array_unref);
|
||||
nm_clear_pointer (&self->kernel_command_line, g_array_unref);
|
||||
nm_clear_pointer (&self->driver, g_array_unref);
|
||||
|
||||
G_OBJECT_CLASS (nm_setting_match_parent_class)->finalize (object);
|
||||
}
|
||||
|
|
@ -267,6 +638,8 @@ nm_setting_match_class_init (NMSettingMatchClass *klass)
|
|||
object_class->set_property = set_property;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
setting_class->verify = verify;
|
||||
|
||||
/**
|
||||
* NMSettingMatch:interface-name
|
||||
*
|
||||
|
|
@ -288,6 +661,45 @@ nm_setting_match_class_init (NMSettingMatchClass *klass)
|
|||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* NMSettingMatch:kernel-command-line
|
||||
*
|
||||
* A list of kernel command line arguments to match. This may be used to check
|
||||
* whether a specific kernel command line option is set (or if prefixed with
|
||||
* the exclamation mark unset). The argument must either be a single word, or
|
||||
* an assignment (i.e. two words, separated "="). In the former case the kernel
|
||||
* command line is searched for the word appearing as is, or as left hand side
|
||||
* of an assignment. In the latter case, the exact assignment is looked for
|
||||
* with right and left hand side matching.
|
||||
*
|
||||
* Since: 1.26
|
||||
**/
|
||||
obj_properties[PROP_KERNEL_COMMAND_LINE] =
|
||||
g_param_spec_boxed (NM_SETTING_MATCH_KERNEL_COMMAND_LINE, "", "",
|
||||
G_TYPE_STRV,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE |
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* NMSettingMatch:driver
|
||||
*
|
||||
* A list of driver names to match. Each element is a shell wildcard pattern.
|
||||
* When an element is prefixed with exclamation mark (!) the condition is
|
||||
* inverted. A candidate driver name is considered matching when both these
|
||||
* conditions are satisfied: (a) any of the elements not prefixed with '!'
|
||||
* matches or there aren't such elements; (b) none of the elements prefixed
|
||||
* with '!' match.
|
||||
*
|
||||
* Since: 1.26
|
||||
**/
|
||||
obj_properties[PROP_DRIVER] =
|
||||
g_param_spec_boxed (NM_SETTING_MATCH_DRIVER, "", "",
|
||||
G_TYPE_STRV,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE |
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
|
||||
_nm_setting_class_commit (setting_class, NM_META_SETTING_TYPE_MATCH);
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ G_BEGIN_DECLS
|
|||
#define NM_SETTING_MATCH_SETTING_NAME "match"
|
||||
|
||||
#define NM_SETTING_MATCH_INTERFACE_NAME "interface-name"
|
||||
#define NM_SETTING_MATCH_KERNEL_COMMAND_LINE "kernel-command-line"
|
||||
#define NM_SETTING_MATCH_DRIVER "driver"
|
||||
|
||||
typedef struct _NMSettingMatchClass NMSettingMatchClass;
|
||||
|
||||
|
|
@ -49,6 +51,43 @@ NM_AVAILABLE_IN_1_14
|
|||
void nm_setting_match_clear_interface_names (NMSettingMatch *setting);
|
||||
NM_AVAILABLE_IN_1_14
|
||||
const char *const *nm_setting_match_get_interface_names (NMSettingMatch *setting, guint *length);
|
||||
|
||||
|
||||
NM_AVAILABLE_IN_1_26
|
||||
guint nm_setting_match_get_num_kernel_command_lines (NMSettingMatch *setting);
|
||||
NM_AVAILABLE_IN_1_26
|
||||
const char *nm_setting_match_get_kernel_command_line (NMSettingMatch *setting, guint idx);
|
||||
NM_AVAILABLE_IN_1_26
|
||||
void nm_setting_match_remove_kernel_command_line (NMSettingMatch *setting, guint idx);
|
||||
NM_AVAILABLE_IN_1_26
|
||||
gboolean nm_setting_match_remove_kernel_command_line_by_value (NMSettingMatch *setting,
|
||||
const char *kernel_command_line);
|
||||
NM_AVAILABLE_IN_1_26
|
||||
void nm_setting_match_add_kernel_command_line (NMSettingMatch *setting,
|
||||
const char *kernel_command_line);
|
||||
NM_AVAILABLE_IN_1_26
|
||||
void nm_setting_match_clear_kernel_command_lines (NMSettingMatch *setting);
|
||||
NM_AVAILABLE_IN_1_26
|
||||
const char *const *nm_setting_match_get_kernel_command_lines (NMSettingMatch *setting, guint *length);
|
||||
|
||||
|
||||
NM_AVAILABLE_IN_1_26
|
||||
guint nm_setting_match_get_num_drivers (NMSettingMatch *setting);
|
||||
NM_AVAILABLE_IN_1_26
|
||||
const char *nm_setting_match_get_driver (NMSettingMatch *setting, guint idx);
|
||||
NM_AVAILABLE_IN_1_26
|
||||
void nm_setting_match_remove_driver (NMSettingMatch *setting, guint idx);
|
||||
NM_AVAILABLE_IN_1_26
|
||||
gboolean nm_setting_match_remove_driver_by_value (NMSettingMatch *setting,
|
||||
const char *driver);
|
||||
NM_AVAILABLE_IN_1_26
|
||||
void nm_setting_match_add_driver (NMSettingMatch *setting,
|
||||
const char *driver);
|
||||
NM_AVAILABLE_IN_1_26
|
||||
void nm_setting_match_clear_drivers (NMSettingMatch *setting);
|
||||
NM_AVAILABLE_IN_1_26
|
||||
const char *const *nm_setting_match_get_drivers (NMSettingMatch *setting, guint *length);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* NM_SETTING_MATCH_H */
|
||||
|
|
|
|||
|
|
@ -2500,7 +2500,7 @@ nm_utils_tc_qdisc_from_str (const char *str, GError **error)
|
|||
break;
|
||||
}
|
||||
}
|
||||
nm_clear_pointer (&rest, g_free);
|
||||
nm_clear_g_free (&rest);
|
||||
|
||||
if (options) {
|
||||
value = g_hash_table_lookup (options, "");
|
||||
|
|
|
|||
|
|
@ -229,6 +229,20 @@
|
|||
# define NM_AVAILABLE_IN_1_24
|
||||
#endif
|
||||
|
||||
#if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_26
|
||||
# define NM_DEPRECATED_IN_1_26 G_DEPRECATED
|
||||
# define NM_DEPRECATED_IN_1_26_FOR(f) G_DEPRECATED_FOR(f)
|
||||
#else
|
||||
# define NM_DEPRECATED_IN_1_26
|
||||
# define NM_DEPRECATED_IN_1_26_FOR(f)
|
||||
#endif
|
||||
|
||||
#if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_26
|
||||
# define NM_AVAILABLE_IN_1_26 G_UNAVAILABLE(1,26)
|
||||
#else
|
||||
# define NM_AVAILABLE_IN_1_26
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Synchronous API for calling D-Bus in libnm is deprecated. See
|
||||
* https://developer.gnome.org/libnm/stable/usage.html#sync-api
|
||||
|
|
|
|||
|
|
@ -3334,6 +3334,7 @@ test_connection_diff_a_only (void)
|
|||
{ NM_SETTING_CONNECTION_AUTH_RETRIES, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_CONNECTION_MDNS, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_CONNECTION_LLMNR, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_CONNECTION_MUD_URL, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_CONNECTION_WAIT_DEVICE_TIMEOUT, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NULL, NM_SETTING_DIFF_RESULT_UNKNOWN }
|
||||
} },
|
||||
|
|
|
|||
|
|
@ -1998,6 +1998,13 @@ test_bridge_verify (void)
|
|||
test_verify_options_bridge (TRUE,
|
||||
"multicast-snooping", "yes",
|
||||
"multicast-router", "disabled");
|
||||
/* multicast-hash-max */
|
||||
test_verify_options_bridge (TRUE,
|
||||
"multicast-hash-max", "1024");
|
||||
test_verify_options_bridge (TRUE,
|
||||
"multicast-hash-max", "8192");
|
||||
test_verify_options_bridge (FALSE,
|
||||
"multicast-hash-max", "3");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import os
|
|||
import gi
|
||||
gi.require_version('GIRepository', '2.0')
|
||||
from gi.repository import GIRepository
|
||||
import argparse, datetime, re, sys
|
||||
import argparse, re, sys
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
try:
|
||||
|
|
@ -47,7 +47,6 @@ dbus_type_name_map = {
|
|||
'aay': 'array of byte array',
|
||||
'a(ayuay)': 'array of legacy IPv6 address struct',
|
||||
'a(ayuayu)': 'array of legacy IPv6 route struct',
|
||||
'aa{sv}': 'array of vardict',
|
||||
}
|
||||
|
||||
ns_map = {
|
||||
|
|
|
|||
|
|
@ -1695,3 +1695,31 @@ global:
|
|||
nm_setting_vrf_get_type;
|
||||
nm_setting_vrf_new;
|
||||
} libnm_1_22_8;
|
||||
|
||||
libnm_1_26_0 {
|
||||
global:
|
||||
nm_setting_bridge_get_multicast_hash_max;
|
||||
nm_setting_bridge_get_multicast_last_member_count;
|
||||
nm_setting_bridge_get_multicast_last_member_interval;
|
||||
nm_setting_bridge_get_multicast_membership_interval;
|
||||
nm_setting_bridge_get_multicast_querier_interval;
|
||||
nm_setting_bridge_get_multicast_query_interval;
|
||||
nm_setting_bridge_get_multicast_query_response_interval;
|
||||
nm_setting_bridge_get_multicast_startup_query_count;
|
||||
nm_setting_bridge_get_multicast_startup_query_interval;
|
||||
nm_setting_connection_get_mud_url;
|
||||
nm_setting_match_add_driver;
|
||||
nm_setting_match_add_kernel_command_line;
|
||||
nm_setting_match_clear_drivers;
|
||||
nm_setting_match_clear_kernel_command_lines;
|
||||
nm_setting_match_get_driver;
|
||||
nm_setting_match_get_drivers;
|
||||
nm_setting_match_get_kernel_command_line;
|
||||
nm_setting_match_get_kernel_command_lines;
|
||||
nm_setting_match_get_num_drivers;
|
||||
nm_setting_match_get_num_kernel_command_lines;
|
||||
nm_setting_match_remove_driver;
|
||||
nm_setting_match_remove_driver_by_value;
|
||||
nm_setting_match_remove_kernel_command_line;
|
||||
nm_setting_match_remove_kernel_command_line_by_value;
|
||||
} libnm_1_24_0;
|
||||
|
|
|
|||
|
|
@ -678,6 +678,10 @@ ipv6.ip6-privacy=0
|
|||
<varlistentry>
|
||||
<term><varname>connection.autoconnect-slaves</varname></term>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>connection.mud-url</varname></term>
|
||||
<listitem><para>If unspecified, MUD URL defaults to <literal>"none"</literal>.</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>connection.lldp</varname></term>
|
||||
</varlistentry>
|
||||
|
|
|
|||
|
|
@ -74,6 +74,20 @@
|
|||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<group choice='plain'>
|
||||
<arg choice='plain'><option>-i</option></arg>
|
||||
<arg choice='plain'><option>--initrd-data-dir</option></arg>
|
||||
</group>
|
||||
<arg choice='plain'><replaceable>path</replaceable></arg>
|
||||
</term>
|
||||
|
||||
<listitem>
|
||||
<para>Output directory for initrd data (e.g. hostname).</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<group choice='plain'>
|
||||
|
|
@ -118,6 +132,7 @@
|
|||
<member><option>nameserver</option></member>
|
||||
<member><option>rd.peerdns</option></member>
|
||||
<member><option>rd.bootif</option></member>
|
||||
<member><option>rd.net.timeout.dhcp</option></member>
|
||||
<member><option>BOOTIF</option></member>
|
||||
</simplelist>
|
||||
|
||||
|
|
@ -128,6 +143,34 @@
|
|||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id='differences_from_network_legacy'><title>Differences from the network-legacy dracut module</title>
|
||||
|
||||
<para><command>nm-initrd-generator</command> generates a set of
|
||||
connections that are then configured by the NetworkManager
|
||||
instance running in the initrd. There are some differences in
|
||||
behavior compared to the network-legacy dracut module:</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>When an interface is configured with a static address
|
||||
and a gateway, the network-legacy module waits that the
|
||||
gateway responds to arping requests before proceeding, while
|
||||
NetworkManager doesn't.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>network-legacy configures interfaces one by one in the
|
||||
order in which they are announced by udev. If multiple
|
||||
interfaces specify a hostname (from command line or from
|
||||
DHCP), the one from the last interface activated wins. With
|
||||
NetworkManager, hostnames from command line have higher
|
||||
precedence over ones from DHCP, and the last that appears in
|
||||
the command line wins.</para>
|
||||
</listitem>
|
||||
|
||||
</itemizedlist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id='exit_status'><title>Exit Status</title>
|
||||
<para><command>nm-initrd-generator</command> exits with status 0. It ignores unrecognized
|
||||
options and prints an error message if it encounters a malformed option.</para>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ project(
|
|||
# - add corresponding NM_VERSION_x_y_z macros in
|
||||
# "shared/nm-version-macros.h.in"
|
||||
# - update number in configure.ac
|
||||
version: '1.24.0',
|
||||
version: '1.25.1',
|
||||
license: 'GPL2+',
|
||||
default_options: [
|
||||
'buildtype=debugoptimized',
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ libnm-core/nm-setting-ip4-config.c
|
|||
libnm-core/nm-setting-ip6-config.c
|
||||
libnm-core/nm-setting-macsec.c
|
||||
libnm-core/nm-setting-macvlan.c
|
||||
libnm-core/nm-setting-match.c
|
||||
libnm-core/nm-setting-olpc-mesh.c
|
||||
libnm-core/nm-setting-ovs-bridge.c
|
||||
libnm-core/nm-setting-ovs-interface.c
|
||||
|
|
|
|||
|
|
@ -630,6 +630,14 @@ NM_G_ERROR_MSG (GError *error)
|
|||
NM_CONSTCAST_FULL (type, (obj), _obj, GObject, ##__VA_ARGS__); \
|
||||
})
|
||||
|
||||
#define NM_ENSURE_NOT_NULL(ptr) \
|
||||
({ \
|
||||
typeof (ptr) _ptr = (ptr); \
|
||||
\
|
||||
nm_assert (_ptr != NULL); \
|
||||
_ptr; \
|
||||
})
|
||||
|
||||
#if _NM_CC_SUPPORT_GENERIC
|
||||
/* returns @value, if the type of @value matches @type.
|
||||
* This requires support for C11 _Generic(). If no support is
|
||||
|
|
@ -929,23 +937,38 @@ nm_streq0 (const char *s1, const char *s2)
|
|||
|
||||
#define NM_STR_HAS_PREFIX(str, prefix) \
|
||||
({ \
|
||||
const char *const _str = (str); \
|
||||
const char *const _str_has_prefix = (str); \
|
||||
\
|
||||
_str && (strncmp ((str), ""prefix"", NM_STRLEN (prefix)) == 0); \
|
||||
nm_assert (strlen (prefix) == NM_STRLEN (prefix)); \
|
||||
\
|
||||
_str_has_prefix \
|
||||
&& (strncmp (_str_has_prefix, ""prefix"", NM_STRLEN (prefix)) == 0); \
|
||||
})
|
||||
|
||||
#define NM_STR_HAS_SUFFIX(str, suffix) \
|
||||
({ \
|
||||
const char *_str; \
|
||||
const char *const _str_has_suffix = (str); \
|
||||
gsize _l; \
|
||||
\
|
||||
( (_str = (str)) \
|
||||
&& ((_l = strlen (_str)) >= NM_STRLEN (suffix)) \
|
||||
&& (memcmp (&_str[_l - NM_STRLEN (suffix)], \
|
||||
nm_assert (strlen (suffix) == NM_STRLEN (suffix)); \
|
||||
\
|
||||
( _str_has_suffix \
|
||||
&& ((_l = strlen (_str_has_suffix)) >= NM_STRLEN (suffix)) \
|
||||
&& (memcmp (&_str_has_suffix[_l - NM_STRLEN (suffix)], \
|
||||
""suffix"", \
|
||||
NM_STRLEN (suffix)) == 0)); \
|
||||
})
|
||||
|
||||
/* whether @str starts with the string literal @prefix and is followed by
|
||||
* some other text. It is like NM_STR_HAS_PREFIX() && !nm_streq() together. */
|
||||
#define NM_STR_HAS_PREFIX_WITH_MORE(str, prefix) \
|
||||
({ \
|
||||
const char *const _str_has_prefix_with_more = (str); \
|
||||
\
|
||||
NM_STR_HAS_PREFIX (_str_has_prefix_with_more, ""prefix"") \
|
||||
&& _str_has_prefix_with_more[NM_STRLEN (prefix)] != '\0'; \
|
||||
})
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static inline GString *
|
||||
|
|
@ -966,16 +989,23 @@ nm_gstring_add_space_delimiter (GString *str)
|
|||
return str;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
nm_str_is_empty (const char *str)
|
||||
{
|
||||
/* %NULL is also accepted, and also "empty". */
|
||||
return !str || !str[0];
|
||||
}
|
||||
|
||||
static inline const char *
|
||||
nm_str_not_empty (const char *str)
|
||||
{
|
||||
return str && str[0] ? str : NULL;
|
||||
return !nm_str_is_empty (str) ? str : NULL;
|
||||
}
|
||||
|
||||
static inline char *
|
||||
nm_strdup_not_empty (const char *str)
|
||||
{
|
||||
return str && str[0] ? g_strdup (str) : NULL;
|
||||
return !nm_str_is_empty (str) ? g_strdup (str) : NULL;
|
||||
}
|
||||
|
||||
static inline char *
|
||||
|
|
|
|||
|
|
@ -4817,3 +4817,23 @@ nm_str_buf_append_printf (NMStrBuf *strbuf,
|
|||
|
||||
strbuf->_priv_len += (gsize) l;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* nm_indirect_g_free:
|
||||
* @arg: a pointer to a pointer that is to be freed.
|
||||
*
|
||||
* This does the same as nm_clear_g_free(arg) (g_clear_pointer (arg, g_free)).
|
||||
* This is for example useful when you have a GArray with pointers and a
|
||||
* clear function to free them. g_array_set_clear_func()'s destroy notify
|
||||
* function gets a pointer to the array location, so we have to follow
|
||||
* the first pointer.
|
||||
*/
|
||||
void
|
||||
nm_indirect_g_free (gpointer arg)
|
||||
{
|
||||
gpointer *p = arg;
|
||||
|
||||
nm_clear_g_free (p);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -926,6 +926,21 @@ _nm_g_slice_free_fcn_define (32)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* Like g_error_matches() however:
|
||||
* - as macro it is always inlined.
|
||||
* - the @domain is usually a error quark getter function that cannot
|
||||
* be inlined. This macro calls the getter only if there is an error (lazy).
|
||||
* - accept a list of allowed codes, instead of only one.
|
||||
*/
|
||||
#define nm_g_error_matches(error, err_domain, ...) \
|
||||
({ \
|
||||
const GError *const _error = (error); \
|
||||
\
|
||||
_error \
|
||||
&& _error->domain == (err_domain) \
|
||||
&& NM_IN_SET (_error->code, __VA_ARGS__); \
|
||||
})
|
||||
|
||||
static inline void
|
||||
nm_g_set_error_take (GError **error, GError *error_take)
|
||||
{
|
||||
|
|
@ -1143,6 +1158,25 @@ GParamSpec *nm_g_object_class_find_property_from_gtype (GType gtype,
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _NM_G_PARAM_SPEC_CAST(param_spec, _value_type, _c_type) \
|
||||
({ \
|
||||
const GParamSpec *const _param_spec = (param_spec); \
|
||||
\
|
||||
nm_assert ( !_param_spec \
|
||||
|| _param_spec->value_type == (_value_type)); \
|
||||
((const _c_type *) _param_spec); \
|
||||
})
|
||||
|
||||
#define NM_G_PARAM_SPEC_CAST_BOOLEAN(param_spec) _NM_G_PARAM_SPEC_CAST (param_spec, G_TYPE_BOOLEAN, GParamSpecBoolean)
|
||||
#define NM_G_PARAM_SPEC_CAST_UINT(param_spec) _NM_G_PARAM_SPEC_CAST (param_spec, G_TYPE_UINT, GParamSpecUInt)
|
||||
#define NM_G_PARAM_SPEC_CAST_UINT64(param_spec) _NM_G_PARAM_SPEC_CAST (param_spec, G_TYPE_UINT64, GParamSpecUInt64)
|
||||
|
||||
#define NM_G_PARAM_SPEC_GET_DEFAULT_BOOLEAN(param_spec) (NM_G_PARAM_SPEC_CAST_BOOLEAN (NM_ENSURE_NOT_NULL (param_spec))->default_value)
|
||||
#define NM_G_PARAM_SPEC_GET_DEFAULT_UINT(param_spec) (NM_G_PARAM_SPEC_CAST_UINT (NM_ENSURE_NOT_NULL (param_spec))->default_value)
|
||||
#define NM_G_PARAM_SPEC_GET_DEFAULT_UINT64(param_spec) (NM_G_PARAM_SPEC_CAST_UINT64 (NM_ENSURE_NOT_NULL (param_spec))->default_value)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
GType nm_g_type_find_implementing_class_for_property (GType gtype,
|
||||
const char *pname);
|
||||
|
||||
|
|
@ -1435,6 +1469,22 @@ char *nm_utils_g_slist_strlist_join (const GSList *a, const char *separator);
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static inline guint
|
||||
nm_g_array_len (const GArray *arr)
|
||||
{
|
||||
return arr ? arr->len : 0u;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static inline guint
|
||||
nm_g_ptr_array_len (const GPtrArray *arr)
|
||||
{
|
||||
return arr ? arr->len : 0u;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static inline guint
|
||||
nm_g_hash_table_size (GHashTable *hash)
|
||||
{
|
||||
|
|
@ -1848,6 +1898,8 @@ nm_utils_strdup_reset (char **dst, const char *src)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
void nm_indirect_g_free (gpointer arg);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* nm_utils_get_next_realloc_size() is used to grow buffers exponentially, when
|
||||
|
|
@ -1887,4 +1939,52 @@ gboolean nm_utils_ifname_valid (const char* name,
|
|||
NMUtilsIfaceType type,
|
||||
GError **error);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static inline GArray *
|
||||
nm_strvarray_ensure (GArray **p)
|
||||
{
|
||||
if (!*p) {
|
||||
*p = g_array_new (TRUE, FALSE, sizeof (char *));
|
||||
g_array_set_clear_func (*p, nm_indirect_g_free);
|
||||
}
|
||||
return *p;
|
||||
}
|
||||
|
||||
static inline void
|
||||
nm_strvarray_add (GArray *array, const char *str)
|
||||
{
|
||||
char *s;
|
||||
|
||||
s = g_strdup (str);
|
||||
g_array_append_val (array, s);
|
||||
}
|
||||
|
||||
static inline const char *const*
|
||||
nm_strvarray_get_strv (GArray **arr, guint *length)
|
||||
{
|
||||
if (!*arr) {
|
||||
NM_SET_OUT (length, 0);
|
||||
return (const char *const*) arr;
|
||||
}
|
||||
|
||||
NM_SET_OUT (length, (*arr)->len);
|
||||
return &g_array_index (*arr, const char *, 0);
|
||||
}
|
||||
|
||||
static inline void
|
||||
nm_strvarray_set_strv (GArray **array, const char *const*strv)
|
||||
{
|
||||
gs_unref_array GArray *array_old = NULL;
|
||||
|
||||
array_old = g_steal_pointer (array);
|
||||
|
||||
if (!strv || !strv[0])
|
||||
return;
|
||||
|
||||
nm_strvarray_ensure (array);
|
||||
for (; strv[0]; strv++)
|
||||
nm_strvarray_add (*array, strv[0]);
|
||||
}
|
||||
|
||||
#endif /* __NM_SHARED_UTILS_H__ */
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "nm-glib-aux/nm-str-buf.h"
|
||||
|
||||
#include "nm-keyfile-internal.h"
|
||||
#include "nm-setting-wired.h"
|
||||
#include "nm-setting-wireless.h"
|
||||
|
|
@ -102,51 +104,114 @@ nm_keyfile_plugin_get_setting_name_for_alias (const char *alias)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* List helpers */
|
||||
#define DEFINE_KF_LIST_WRAPPER(stype, get_ctype, set_ctype) \
|
||||
get_ctype \
|
||||
nm_keyfile_plugin_kf_get_##stype##_list (GKeyFile *kf, \
|
||||
const char *group, \
|
||||
const char *key, \
|
||||
gsize *out_length, \
|
||||
GError **error) \
|
||||
{ \
|
||||
get_ctype list; \
|
||||
const char *alias; \
|
||||
GError *local = NULL; \
|
||||
gsize l; \
|
||||
\
|
||||
list = g_key_file_get_##stype##_list (kf, group, key, &l, &local); \
|
||||
if (g_error_matches (local, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND)) { \
|
||||
alias = nm_keyfile_plugin_get_alias_for_setting_name (group); \
|
||||
if (alias) { \
|
||||
g_clear_error (&local); \
|
||||
list = g_key_file_get_##stype##_list (kf, alias, key, &l, &local); \
|
||||
} \
|
||||
} \
|
||||
if (local) \
|
||||
g_propagate_error (error, local); \
|
||||
if (!list) \
|
||||
l = 0; \
|
||||
NM_SET_OUT (out_length, l); \
|
||||
return list; \
|
||||
} \
|
||||
\
|
||||
void \
|
||||
nm_keyfile_plugin_kf_set_##stype##_list (GKeyFile *kf, \
|
||||
const char *group, \
|
||||
const char *key, \
|
||||
set_ctype list[], \
|
||||
gsize length) \
|
||||
{ \
|
||||
const char *alias; \
|
||||
\
|
||||
alias = nm_keyfile_plugin_get_alias_for_setting_name (group); \
|
||||
g_key_file_set_##stype##_list (kf, alias ?: group, key, list, length); \
|
||||
char **
|
||||
nm_keyfile_plugin_kf_get_string_list (GKeyFile *kf,
|
||||
const char *group,
|
||||
const char *key,
|
||||
gsize *out_length,
|
||||
GError **error)
|
||||
{
|
||||
char **list;
|
||||
const char *alias;
|
||||
GError *local = NULL;
|
||||
gsize l;
|
||||
|
||||
list = g_key_file_get_string_list (kf, group, key, &l, &local);
|
||||
if (nm_g_error_matches (local, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND)) {
|
||||
alias = nm_keyfile_plugin_get_alias_for_setting_name (group);
|
||||
if (alias) {
|
||||
g_clear_error (&local);
|
||||
list = g_key_file_get_string_list (kf, alias, key, &l, &local);
|
||||
}
|
||||
}
|
||||
if (local)
|
||||
g_propagate_error (error, local);
|
||||
if (!list)
|
||||
l = 0;
|
||||
NM_SET_OUT (out_length, l);
|
||||
return list;
|
||||
}
|
||||
|
||||
DEFINE_KF_LIST_WRAPPER(integer, int*, int);
|
||||
DEFINE_KF_LIST_WRAPPER(string, char **, const char* const);
|
||||
guint *
|
||||
nm_keyfile_plugin_kf_get_integer_list_uint (GKeyFile *key_file,
|
||||
const char *group_name,
|
||||
const char *key,
|
||||
gsize *out_length,
|
||||
GError **error)
|
||||
{
|
||||
GError *key_file_error = NULL;
|
||||
gs_strfreev char **values = NULL;
|
||||
gs_free guint *int_values = NULL;
|
||||
gsize i, num_ints;
|
||||
|
||||
g_return_val_if_fail (key_file != NULL, NULL);
|
||||
g_return_val_if_fail (group_name != NULL, NULL);
|
||||
g_return_val_if_fail (key != NULL, NULL);
|
||||
|
||||
NM_SET_OUT (out_length, 0);
|
||||
|
||||
values = nm_keyfile_plugin_kf_get_string_list (key_file, group_name, key, &num_ints, &key_file_error);
|
||||
|
||||
if (key_file_error)
|
||||
g_propagate_error (error, key_file_error);
|
||||
if (!values)
|
||||
return NULL;
|
||||
|
||||
int_values = g_new (guint, num_ints);
|
||||
|
||||
for (i = 0; i < num_ints; i++) {
|
||||
gint64 v;
|
||||
|
||||
G_STATIC_ASSERT_EXPR (sizeof (v) > sizeof (guint));
|
||||
v = _nm_utils_ascii_str_to_int64 (values[i], 10, 0, G_MAXUINT, -1);
|
||||
if (v == -1) {
|
||||
g_set_error (error,
|
||||
G_KEY_FILE_ERROR,
|
||||
G_KEY_FILE_ERROR_INVALID_VALUE,
|
||||
_("Value cannot be interpreted as a list of numbers."));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int_values[i] = v;
|
||||
}
|
||||
|
||||
NM_SET_OUT (out_length, num_ints);
|
||||
return g_steal_pointer (&int_values);
|
||||
}
|
||||
|
||||
void
|
||||
nm_keyfile_plugin_kf_set_string_list (GKeyFile *kf,
|
||||
const char *group,
|
||||
const char *key,
|
||||
const char *const*list,
|
||||
gsize length)
|
||||
{
|
||||
const char *alias;
|
||||
|
||||
alias = nm_keyfile_plugin_get_alias_for_setting_name (group);
|
||||
g_key_file_set_string_list (kf, alias ?: group, key, list, length);
|
||||
}
|
||||
|
||||
void
|
||||
nm_keyfile_plugin_kf_set_integer_list_uint (GKeyFile *kf,
|
||||
const char *group,
|
||||
const char *key,
|
||||
const guint *data,
|
||||
gsize length)
|
||||
{
|
||||
nm_auto_str_buf NMStrBuf strbuf = { };
|
||||
gsize i;
|
||||
|
||||
g_return_if_fail (kf);
|
||||
g_return_if_fail (!length || data);
|
||||
g_return_if_fail (group && group[0]);
|
||||
g_return_if_fail (key && key[0]);
|
||||
|
||||
nm_str_buf_init (&strbuf, length * 4u + 2u, FALSE);
|
||||
for (i = 0; i < length; i++)
|
||||
nm_str_buf_append_printf (&strbuf, "%u;", data[i]);
|
||||
nm_keyfile_plugin_kf_set_value (kf, group, key, nm_str_buf_get_str (&strbuf));
|
||||
}
|
||||
|
||||
void
|
||||
nm_keyfile_plugin_kf_set_integer_list_uint8 (GKeyFile *kf,
|
||||
|
|
@ -155,63 +220,64 @@ nm_keyfile_plugin_kf_set_integer_list_uint8 (GKeyFile *kf,
|
|||
const guint8 *data,
|
||||
gsize length)
|
||||
{
|
||||
nm_auto_str_buf NMStrBuf strbuf = { };
|
||||
gsize i;
|
||||
gsize l = length * 4 + 2;
|
||||
gs_free char *value = g_malloc (l);
|
||||
char *s = value;
|
||||
|
||||
g_return_if_fail (kf);
|
||||
g_return_if_fail (!length || data);
|
||||
g_return_if_fail (group && group[0]);
|
||||
g_return_if_fail (key && key[0]);
|
||||
|
||||
value[0] = '\0';
|
||||
nm_str_buf_init (&strbuf, length * 4u + 2u, FALSE);
|
||||
for (i = 0; i < length; i++)
|
||||
nm_utils_strbuf_append (&s, &l, "%d;", (int) data[i]);
|
||||
nm_assert (l > 0);
|
||||
nm_keyfile_plugin_kf_set_value (kf, group, key, value);
|
||||
nm_str_buf_append_printf (&strbuf, "%u;", (guint) data[i]);
|
||||
nm_keyfile_plugin_kf_set_value (kf, group, key, nm_str_buf_get_str (&strbuf));
|
||||
}
|
||||
|
||||
/* Single value helpers */
|
||||
#define DEFINE_KF_WRAPPER(stype, get_ctype, set_ctype) \
|
||||
#define DEFINE_KF_WRAPPER_GET(fcn_name, get_ctype, key_file_get_fcn) \
|
||||
get_ctype \
|
||||
nm_keyfile_plugin_kf_get_##stype (GKeyFile *kf, \
|
||||
const char *group, \
|
||||
const char *key, \
|
||||
GError **error) \
|
||||
fcn_name (GKeyFile *kf, \
|
||||
const char *group, \
|
||||
const char *key, \
|
||||
GError **error) \
|
||||
{ \
|
||||
get_ctype val; \
|
||||
const char *alias; \
|
||||
GError *local = NULL; \
|
||||
\
|
||||
val = g_key_file_get_##stype (kf, group, key, &local); \
|
||||
if (g_error_matches (local, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND)) { \
|
||||
\
|
||||
val = key_file_get_fcn (kf, group, key, &local); \
|
||||
if (nm_g_error_matches (local, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND)) { \
|
||||
alias = nm_keyfile_plugin_get_alias_for_setting_name (group); \
|
||||
if (alias) { \
|
||||
g_clear_error (&local); \
|
||||
val = g_key_file_get_##stype (kf, alias, key, &local); \
|
||||
val = key_file_get_fcn (kf, alias, key, &local); \
|
||||
} \
|
||||
} \
|
||||
if (local) \
|
||||
g_propagate_error (error, local); \
|
||||
return val; \
|
||||
} \
|
||||
\
|
||||
void \
|
||||
nm_keyfile_plugin_kf_set_##stype (GKeyFile *kf, \
|
||||
const char *group, \
|
||||
const char *key, \
|
||||
set_ctype value) \
|
||||
{ \
|
||||
const char *alias; \
|
||||
\
|
||||
alias = nm_keyfile_plugin_get_alias_for_setting_name (group); \
|
||||
g_key_file_set_##stype (kf, alias ?: group, key, value); \
|
||||
}
|
||||
|
||||
DEFINE_KF_WRAPPER(string, char*, const char*);
|
||||
DEFINE_KF_WRAPPER(boolean, gboolean, gboolean);
|
||||
DEFINE_KF_WRAPPER(value, char*, const char*);
|
||||
DEFINE_KF_WRAPPER_GET (nm_keyfile_plugin_kf_get_string, char *, g_key_file_get_string);
|
||||
DEFINE_KF_WRAPPER_GET (nm_keyfile_plugin_kf_get_boolean, gboolean, g_key_file_get_boolean);
|
||||
DEFINE_KF_WRAPPER_GET (nm_keyfile_plugin_kf_get_value, char *, g_key_file_get_value);
|
||||
|
||||
#define DEFINE_KF_WRAPPER_SET(fcn_name, set_ctype, key_file_set_fcn) \
|
||||
void \
|
||||
fcn_name (GKeyFile *kf, \
|
||||
const char *group, \
|
||||
const char *key, \
|
||||
set_ctype value) \
|
||||
{ \
|
||||
const char *alias; \
|
||||
\
|
||||
alias = nm_keyfile_plugin_get_alias_for_setting_name (group); \
|
||||
key_file_set_fcn (kf, alias ?: group, key, value); \
|
||||
}
|
||||
|
||||
DEFINE_KF_WRAPPER_SET (nm_keyfile_plugin_kf_set_string, const char *, g_key_file_set_string);
|
||||
DEFINE_KF_WRAPPER_SET (nm_keyfile_plugin_kf_set_boolean, gboolean, g_key_file_set_boolean);
|
||||
DEFINE_KF_WRAPPER_SET (nm_keyfile_plugin_kf_set_value, const char *, g_key_file_set_value);
|
||||
|
||||
gint64
|
||||
nm_keyfile_plugin_kf_get_int64 (GKeyFile *kf,
|
||||
|
|
@ -257,7 +323,7 @@ nm_keyfile_plugin_kf_get_keys (GKeyFile *kf,
|
|||
gsize l;
|
||||
|
||||
keys = g_key_file_get_keys (kf, group, &l, &local);
|
||||
if (g_error_matches (local, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND)) {
|
||||
if (nm_g_error_matches (local, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND)) {
|
||||
alias = nm_keyfile_plugin_get_alias_for_setting_name (group);
|
||||
if (alias) {
|
||||
g_clear_error (&local);
|
||||
|
|
@ -285,7 +351,7 @@ nm_keyfile_plugin_kf_has_key (GKeyFile *kf,
|
|||
GError *local = NULL;
|
||||
|
||||
has = g_key_file_has_key (kf, group, key, &local);
|
||||
if (g_error_matches (local, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND)) {
|
||||
if (nm_g_error_matches (local, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND)) {
|
||||
alias = nm_keyfile_plugin_get_alias_for_setting_name (group);
|
||||
if (alias) {
|
||||
g_clear_error (&local);
|
||||
|
|
|
|||
|
|
@ -10,53 +10,41 @@
|
|||
#error Cannot use this header.
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "nm-glib-aux/nm-shared-utils.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define NM_KEYFILE_GROUP_VPN_SECRETS "vpn-secrets"
|
||||
#define NM_KEYFILE_GROUPPREFIX_WIREGUARD_PEER "wireguard-peer."
|
||||
|
||||
#define nm_keyfile_error_is_not_found(error) \
|
||||
nm_g_error_matches (error, \
|
||||
G_KEY_FILE_ERROR, \
|
||||
G_KEY_FILE_ERROR_GROUP_NOT_FOUND, \
|
||||
G_KEY_FILE_ERROR_KEY_NOT_FOUND)
|
||||
|
||||
const char *nm_keyfile_plugin_get_alias_for_setting_name (const char *setting_name);
|
||||
|
||||
const char *nm_keyfile_plugin_get_setting_name_for_alias (const char *alias);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* List helpers */
|
||||
#define DEFINE_KF_LIST_WRAPPER_PROTO(stype, get_ctype, set_ctype) \
|
||||
get_ctype nm_keyfile_plugin_kf_get_##stype##_list (GKeyFile *kf, \
|
||||
const char *group, \
|
||||
const char *key, \
|
||||
gsize *out_length, \
|
||||
GError **error); \
|
||||
\
|
||||
void nm_keyfile_plugin_kf_set_##stype##_list (GKeyFile *kf, \
|
||||
const char *group, \
|
||||
const char *key, \
|
||||
set_ctype list[], \
|
||||
gsize length);
|
||||
DEFINE_KF_LIST_WRAPPER_PROTO(integer, int*, int)
|
||||
DEFINE_KF_LIST_WRAPPER_PROTO(string, char**, const char* const)
|
||||
guint *nm_keyfile_plugin_kf_get_integer_list_uint (GKeyFile *kf, const char *group, const char *key, gsize *out_length, GError **error);
|
||||
char **nm_keyfile_plugin_kf_get_string_list (GKeyFile *kf, const char *group, const char *key, gsize *out_length, GError **error);
|
||||
char *nm_keyfile_plugin_kf_get_string (GKeyFile *kf, const char *group, const char *key, GError **error);
|
||||
gboolean nm_keyfile_plugin_kf_get_boolean (GKeyFile *kf, const char *group, const char *key, GError **error);
|
||||
char *nm_keyfile_plugin_kf_get_value (GKeyFile *kf, const char *group, const char *key, GError **error);
|
||||
|
||||
void nm_keyfile_plugin_kf_set_integer_list_uint8 (GKeyFile *kf,
|
||||
const char *group,
|
||||
const char *key,
|
||||
const guint8 *list,
|
||||
gsize length);
|
||||
void nm_keyfile_plugin_kf_set_integer_list_uint8 (GKeyFile *kf, const char *group, const char *key, const guint8 *list, gsize length);
|
||||
void nm_keyfile_plugin_kf_set_integer_list_uint (GKeyFile *kf, const char *group, const char *key, const guint *list, gsize length);
|
||||
void nm_keyfile_plugin_kf_set_string_list (GKeyFile *kf, const char *group, const char *key, const char *const*list, gsize length);
|
||||
|
||||
/* Single-value helpers */
|
||||
#define DEFINE_KF_WRAPPER_PROTO(stype, get_ctype, set_ctype) \
|
||||
get_ctype nm_keyfile_plugin_kf_get_##stype (GKeyFile *kf, \
|
||||
const char *group, \
|
||||
const char *key, \
|
||||
GError **error); \
|
||||
\
|
||||
void nm_keyfile_plugin_kf_set_##stype (GKeyFile *kf, \
|
||||
const char *group, \
|
||||
const char *key, \
|
||||
set_ctype value);
|
||||
DEFINE_KF_WRAPPER_PROTO(string, char*, const char*)
|
||||
DEFINE_KF_WRAPPER_PROTO(boolean, gboolean, gboolean)
|
||||
DEFINE_KF_WRAPPER_PROTO(value, char*, const char*)
|
||||
void nm_keyfile_plugin_kf_set_string (GKeyFile *kf, const char *group, const char *key, const char *value);
|
||||
void nm_keyfile_plugin_kf_set_boolean (GKeyFile *kf, const char *group, const char *key, gboolean value);
|
||||
void nm_keyfile_plugin_kf_set_value (GKeyFile *kf, const char *group, const char *key, const char *value);
|
||||
|
||||
/* Misc */
|
||||
gint64 nm_keyfile_plugin_kf_get_int64 (GKeyFile *kf,
|
||||
const char *group,
|
||||
const char *key,
|
||||
|
|
@ -66,15 +54,15 @@ gint64 nm_keyfile_plugin_kf_get_int64 (GKeyFile *kf,
|
|||
gint64 fallback,
|
||||
GError **error);
|
||||
|
||||
char ** nm_keyfile_plugin_kf_get_keys (GKeyFile *kf,
|
||||
const char *group,
|
||||
gsize *out_length,
|
||||
GError **error);
|
||||
char **nm_keyfile_plugin_kf_get_keys (GKeyFile *kf,
|
||||
const char *group,
|
||||
gsize *out_length,
|
||||
GError **error);
|
||||
|
||||
gboolean nm_keyfile_plugin_kf_has_key (GKeyFile *kf,
|
||||
const char *group,
|
||||
const char *key,
|
||||
GError **error);
|
||||
gboolean nm_keyfile_plugin_kf_has_key (GKeyFile *kf,
|
||||
const char *group,
|
||||
const char *key,
|
||||
GError **error);
|
||||
|
||||
const char *nm_keyfile_key_encode (const char *name,
|
||||
char **out_to_free);
|
||||
|
|
|
|||
|
|
@ -164,23 +164,16 @@ read_array_of_uint (GKeyFile *file,
|
|||
const char *key)
|
||||
{
|
||||
gs_unref_array GArray *array = NULL;
|
||||
gsize length;
|
||||
gsize i;
|
||||
gs_free int *tmp = NULL;
|
||||
gs_free_error GError *error = NULL;
|
||||
gs_free guint *tmp = NULL;
|
||||
gsize length;
|
||||
|
||||
tmp = nm_keyfile_plugin_kf_get_integer_list (file, nm_setting_get_name (setting), key, &length, &error);
|
||||
tmp = nm_keyfile_plugin_kf_get_integer_list_uint (file, nm_setting_get_name (setting), key, &length, &error);
|
||||
if (error)
|
||||
return;
|
||||
|
||||
array = g_array_sized_new (FALSE, FALSE, sizeof (guint), length);
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
if (tmp[i] < 0)
|
||||
return;
|
||||
g_array_append_val (array, tmp[i]);
|
||||
}
|
||||
|
||||
g_array_append_vals (array, tmp, length);
|
||||
g_object_set (setting, key, array, NULL);
|
||||
}
|
||||
|
||||
|
|
@ -941,7 +934,7 @@ mac_address_parser (KeyfileReaderInfo *info, NMSetting *setting, const char *key
|
|||
char addr_str[NM_UTILS_HWADDR_LEN_MAX * 3];
|
||||
guint8 addr_bin[NM_UTILS_HWADDR_LEN_MAX];
|
||||
gs_free char *tmp_string = NULL;
|
||||
gs_free int *int_list = NULL;
|
||||
gs_free guint *int_list = NULL;
|
||||
const char *mac_str;
|
||||
gsize int_list_len;
|
||||
gsize i;
|
||||
|
|
@ -962,12 +955,12 @@ mac_address_parser (KeyfileReaderInfo *info, NMSetting *setting, const char *key
|
|||
goto good_addr_bin;
|
||||
|
||||
/* Old format; list of ints */
|
||||
int_list = nm_keyfile_plugin_kf_get_integer_list (info->keyfile, setting_name, key, &int_list_len, NULL);
|
||||
int_list = nm_keyfile_plugin_kf_get_integer_list_uint (info->keyfile, setting_name, key, &int_list_len, NULL);
|
||||
if (int_list_len == addr_len) {
|
||||
for (i = 0; i < addr_len; i++) {
|
||||
const int val = int_list[i];
|
||||
const guint val = int_list[i];
|
||||
|
||||
if (val < 0 || val > 255)
|
||||
if (val > 255)
|
||||
break;
|
||||
addr_bin[i] = (guint8) val;
|
||||
}
|
||||
|
|
@ -1629,9 +1622,7 @@ parity_good:
|
|||
out_err:
|
||||
if (!err)
|
||||
return;
|
||||
if ( err->domain == G_KEY_FILE_ERROR
|
||||
&& NM_IN_SET (err->code, G_KEY_FILE_ERROR_GROUP_NOT_FOUND,
|
||||
G_KEY_FILE_ERROR_KEY_NOT_FOUND)) {
|
||||
if (nm_keyfile_error_is_not_found (err)) {
|
||||
/* ignore such errors. The key is not present. */
|
||||
return;
|
||||
}
|
||||
|
|
@ -1851,25 +1842,19 @@ write_array_of_uint (GKeyFile *file,
|
|||
const GValue *value)
|
||||
{
|
||||
GArray *array;
|
||||
guint i;
|
||||
gs_free int *tmp_array = NULL;
|
||||
|
||||
array = (GArray *) g_value_get_boxed (value);
|
||||
array = g_value_get_boxed (value);
|
||||
|
||||
nm_assert (!array || g_array_get_element_size (array) == sizeof (guint));
|
||||
|
||||
if (!array || !array->len)
|
||||
return;
|
||||
|
||||
g_return_if_fail (g_array_get_element_size (array) == sizeof (guint));
|
||||
|
||||
tmp_array = g_new (int, array->len);
|
||||
for (i = 0; i < array->len; i++) {
|
||||
guint v = g_array_index (array, guint, i);
|
||||
|
||||
if (v > G_MAXINT)
|
||||
g_return_if_reached ();
|
||||
tmp_array[i] = (int) v;
|
||||
}
|
||||
|
||||
nm_keyfile_plugin_kf_set_integer_list (file, nm_setting_get_name (setting), key, tmp_array, array->len);
|
||||
nm_keyfile_plugin_kf_set_integer_list_uint (file,
|
||||
nm_setting_get_name (setting),
|
||||
key,
|
||||
(const guint *) array->data,
|
||||
array->len);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -3101,24 +3086,24 @@ read_one_setting_value (KeyfileReaderInfo *info,
|
|||
nm_g_object_set_property_int64 (G_OBJECT (setting), key, i64, &err);
|
||||
}
|
||||
} else if (type == G_TYPE_BYTES) {
|
||||
gs_free int *tmp = NULL;
|
||||
gs_free guint *tmp = NULL;
|
||||
GByteArray *array;
|
||||
GBytes *bytes;
|
||||
gsize length;
|
||||
int i;
|
||||
gboolean already_warned = FALSE;
|
||||
|
||||
tmp = nm_keyfile_plugin_kf_get_integer_list (keyfile, setting_info->setting_name, key, &length, NULL);
|
||||
tmp = nm_keyfile_plugin_kf_get_integer_list_uint (keyfile, setting_info->setting_name, key, &length, NULL);
|
||||
|
||||
array = g_byte_array_sized_new (length);
|
||||
for (i = 0; i < length; i++) {
|
||||
const int val = tmp[i];
|
||||
const guint val = tmp[i];
|
||||
unsigned char v = (unsigned char) (val & 0xFF);
|
||||
|
||||
if (val < 0 || val > 255) {
|
||||
if (val > 255u) {
|
||||
if ( !already_warned
|
||||
&& !handle_warn (info, key, NM_KEYFILE_WARN_SEVERITY_WARN,
|
||||
_("ignoring invalid byte element '%d' (not between 0 and 255 inclusive)"),
|
||||
_("ignoring invalid byte element '%u' (not between 0 and 255 inclusive)"),
|
||||
val)) {
|
||||
g_byte_array_unref (array);
|
||||
return;
|
||||
|
|
@ -3167,9 +3152,7 @@ read_one_setting_value (KeyfileReaderInfo *info,
|
|||
g_return_if_reached ();
|
||||
|
||||
if (err) {
|
||||
if ( err->domain == G_KEY_FILE_ERROR
|
||||
&& NM_IN_SET (err->code, G_KEY_FILE_ERROR_GROUP_NOT_FOUND,
|
||||
G_KEY_FILE_ERROR_KEY_NOT_FOUND)) {
|
||||
if (nm_keyfile_error_is_not_found (err)) {
|
||||
/* ignore such errors. The key is not present. */
|
||||
} else {
|
||||
handle_warn (info, key, NM_KEYFILE_WARN_SEVERITY_WARN,
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ NM_CLONED_MAC_IS_SPECIAL (const char *str)
|
|||
#define NM_IAID_IFNAME "ifname"
|
||||
#define NM_IAID_STABLE "stable"
|
||||
|
||||
#define NM_CONNECTION_MUD_URL_NONE "none"
|
||||
|
||||
static inline gboolean
|
||||
NM_IAID_IS_SPECIAL (const char *str)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
* Copyright (C) 2014 - 2015 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NM_TEST_LIBNM_UTILS_H__
|
||||
#define __NM_TEST_LIBNM_UTILS_H__
|
||||
|
||||
#include "NetworkManager.h"
|
||||
|
||||
#include "nm-utils/nm-test-utils.h"
|
||||
|
|
@ -82,3 +85,5 @@ nmtstc_client_new (gboolean allow_iterate_main_context)
|
|||
{
|
||||
return nmtstc_context_object_new (NM_TYPE_CLIENT, allow_iterate_main_context, NULL);
|
||||
}
|
||||
|
||||
#endif /* __NM_TEST_LIBNM_UTILS_H__ */
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@
|
|||
#define NM_VERSION_1_20 (NM_ENCODE_VERSION (1, 20, 0))
|
||||
#define NM_VERSION_1_22 (NM_ENCODE_VERSION (1, 22, 0))
|
||||
#define NM_VERSION_1_24 (NM_ENCODE_VERSION (1, 24, 0))
|
||||
#define NM_VERSION_1_26 (NM_ENCODE_VERSION (1, 26, 0))
|
||||
|
||||
/* For releases, NM_API_VERSION is equal to NM_VERSION.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include "hexdecoct.h"
|
||||
#include "hostname-util.h"
|
||||
#include "path-util.h"
|
||||
#include "web-util.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
@ -94,3 +95,45 @@ gboolean nm_sd_hostname_is_valid (const char *s, bool allow_trailing_dot)
|
|||
{
|
||||
return hostname_is_valid (s, allow_trailing_dot);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
_http_url_is_valid (const char *url, gboolean only_https)
|
||||
{
|
||||
if ( !url
|
||||
|| !url[0])
|
||||
return FALSE;
|
||||
|
||||
if ( !only_https
|
||||
&& NM_STR_HAS_PREFIX (url, "http://"))
|
||||
url += NM_STRLEN ("http://");
|
||||
else if (NM_STR_HAS_PREFIX (url, "https://"))
|
||||
url += NM_STRLEN ("https://");
|
||||
else
|
||||
return FALSE;
|
||||
|
||||
if (!url[0])
|
||||
return FALSE;
|
||||
|
||||
return !NM_STRCHAR_ANY (url, ch, (guchar) ch >= 128u);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_sd_http_url_is_valid_https (const char *url)
|
||||
{
|
||||
/* We use this function to verify connection:mud-url property, it must thus
|
||||
* not change behavior.
|
||||
*
|
||||
* Note that sd_dhcp_client_set_mud_url() and sd_dhcp6_client_set_request_mud_url()
|
||||
* assert with http_url_is_valid() that the argument is valid. We thus must make
|
||||
* sure to only pass URLs that are valid according to http_url_is_valid().
|
||||
*
|
||||
* This is given, because our nm_sd_http_url_is_valid_https() is more strict
|
||||
* than http_url_is_valid().
|
||||
*
|
||||
* We only must make sure that this is also correct in the future, when we
|
||||
* re-import systemd code. */
|
||||
nm_assert (_http_url_is_valid (url, FALSE) == http_url_is_valid (url));
|
||||
return _http_url_is_valid (url, TRUE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,4 +34,8 @@ int nm_sd_dns_name_to_wire_format (const char *domain,
|
|||
int nm_sd_dns_name_is_valid (const char *s);
|
||||
gboolean nm_sd_hostname_is_valid(const char *s, bool allow_trailing_dot);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean nm_sd_http_url_is_valid_https (const char *url);
|
||||
|
||||
#endif /* __NM_SD_UTILS_SHARED_H__ */
|
||||
|
|
|
|||
|
|
@ -24,21 +24,25 @@ bool http_etag_is_valid(const char *etag) {
|
|||
}
|
||||
#endif /* NM_IGNORED */
|
||||
|
||||
bool http_url_is_valid(const char *url) {
|
||||
const char *p;
|
||||
|
||||
if (isempty(url))
|
||||
return false;
|
||||
|
||||
p = STARTSWITH_SET(url, "http://", "https://");
|
||||
if (!p)
|
||||
return false;
|
||||
|
||||
if (isempty(p))
|
||||
return false;
|
||||
|
||||
return ascii_is_valid(p);
|
||||
}
|
||||
/* NM: we use http_url_is_valid() for our own code, and it must not
|
||||
* change behavior. If a re-import results in a merge-conflict, you must
|
||||
* ensure that it does not change behavior, and possibly do something
|
||||
* about that. */
|
||||
/**/ bool http_url_is_valid(const char *url) {
|
||||
/**/ const char *p;
|
||||
/**/
|
||||
/**/ if (isempty(url))
|
||||
/**/ return false;
|
||||
/**/
|
||||
/**/ p = STARTSWITH_SET(url, "http://", "https://");
|
||||
/**/ if (!p)
|
||||
/**/ return false;
|
||||
/**/
|
||||
/**/ if (isempty(p))
|
||||
/**/ return false;
|
||||
/**/
|
||||
/**/ return ascii_is_valid(p);
|
||||
/**/ }
|
||||
|
||||
#if 0 /* NM_IGNORED */
|
||||
bool documentation_url_is_valid(const char *url) {
|
||||
|
|
|
|||
|
|
@ -237,88 +237,156 @@ typedef struct {
|
|||
const char *sysname;
|
||||
const char *(*to_sysfs) (GValue *value);
|
||||
void (*from_sysfs) (const char *value, GValue *out);
|
||||
uint nm_min;
|
||||
uint nm_max;
|
||||
uint nm_default;
|
||||
guint64 nm_min;
|
||||
guint64 nm_max;
|
||||
guint64 nm_default;
|
||||
bool default_if_zero;
|
||||
bool user_hz_compensate;
|
||||
bool only_with_stp;
|
||||
} Option;
|
||||
|
||||
#define OPTION(_name, _sysname, ...) \
|
||||
{ \
|
||||
.name = ""_name"", \
|
||||
.sysname = ""_sysname"", \
|
||||
__VA_ARGS__ \
|
||||
}
|
||||
|
||||
#define OPTION_TYPE_INT(min, max, def) \
|
||||
.nm_min = (min), .nm_max = (max), .nm_default = (def)
|
||||
|
||||
#define OPTION_TYPE_BOOL(def) \
|
||||
OPTION_TYPE_INT (FALSE, TRUE, def)
|
||||
|
||||
#define OPTION_TYPE_TOFROM(to, fro) \
|
||||
.to_sysfs = (to), .from_sysfs = (fro)
|
||||
|
||||
static const Option master_options[] = {
|
||||
{ NM_SETTING_BRIDGE_STP, "stp_state", /* this must stay as the first item */
|
||||
NULL, NULL,
|
||||
0, 1, 1,
|
||||
FALSE, FALSE, FALSE },
|
||||
{ NM_SETTING_BRIDGE_PRIORITY, "priority",
|
||||
NULL, NULL,
|
||||
0, G_MAXUINT16, 0x8000,
|
||||
TRUE, FALSE, TRUE },
|
||||
{ NM_SETTING_BRIDGE_FORWARD_DELAY, "forward_delay",
|
||||
NULL, NULL,
|
||||
0, NM_BR_MAX_FORWARD_DELAY, 15,
|
||||
TRUE, TRUE, TRUE},
|
||||
{ NM_SETTING_BRIDGE_HELLO_TIME, "hello_time",
|
||||
NULL, NULL,
|
||||
0, NM_BR_MAX_HELLO_TIME, 2,
|
||||
TRUE, TRUE, TRUE },
|
||||
{ NM_SETTING_BRIDGE_MAX_AGE, "max_age",
|
||||
NULL, NULL,
|
||||
0, NM_BR_MAX_MAX_AGE, 20,
|
||||
TRUE, TRUE, TRUE },
|
||||
{ NM_SETTING_BRIDGE_AGEING_TIME, "ageing_time",
|
||||
NULL, NULL,
|
||||
NM_BR_MIN_AGEING_TIME, NM_BR_MAX_AGEING_TIME, 300,
|
||||
TRUE, TRUE, FALSE },
|
||||
{ NM_SETTING_BRIDGE_GROUP_FORWARD_MASK, "group_fwd_mask",
|
||||
NULL, NULL,
|
||||
0, 0xFFFF, 0,
|
||||
TRUE, FALSE, FALSE },
|
||||
{ NM_SETTING_BRIDGE_MULTICAST_QUERIER, "multicast_querier",
|
||||
NULL, NULL,
|
||||
0, 1, 0,
|
||||
FALSE, FALSE, FALSE },
|
||||
{ NM_SETTING_BRIDGE_MULTICAST_QUERY_USE_IFADDR, "multicast_query_use_ifaddr",
|
||||
NULL, NULL,
|
||||
0, 1, 0,
|
||||
FALSE, FALSE, FALSE },
|
||||
{ NM_SETTING_BRIDGE_MULTICAST_SNOOPING, "multicast_snooping",
|
||||
NULL, NULL,
|
||||
0, 1, 1,
|
||||
FALSE, FALSE, FALSE },
|
||||
{ NM_SETTING_BRIDGE_MULTICAST_ROUTER, "multicast_router",
|
||||
to_sysfs_multicast_router, from_sysfs_multicast_router,
|
||||
0, 0, 0,
|
||||
FALSE, FALSE, FALSE },
|
||||
{ NM_SETTING_BRIDGE_GROUP_ADDRESS, "group_addr",
|
||||
to_sysfs_group_address, from_sysfs_group_address,
|
||||
0, 0, 0,
|
||||
FALSE, FALSE, FALSE },
|
||||
{ NM_SETTING_BRIDGE_VLAN_PROTOCOL, "vlan_protocol",
|
||||
to_sysfs_vlan_protocol, from_sysfs_vlan_protocol,
|
||||
0, 0, 0,
|
||||
FALSE, FALSE, FALSE },
|
||||
{ NM_SETTING_BRIDGE_VLAN_STATS_ENABLED, "vlan_stats_enabled",
|
||||
NULL, NULL,
|
||||
0, 1, 0,
|
||||
FALSE, FALSE, FALSE },
|
||||
{ NULL, NULL }
|
||||
OPTION (NM_SETTING_BRIDGE_STP, /* this must stay as the first item */
|
||||
"stp_state",
|
||||
OPTION_TYPE_BOOL (NM_BRIDGE_STP_DEF),
|
||||
),
|
||||
OPTION (NM_SETTING_BRIDGE_PRIORITY,
|
||||
"priority",
|
||||
OPTION_TYPE_INT (NM_BRIDGE_PRIORITY_MIN, NM_BRIDGE_PRIORITY_MAX, NM_BRIDGE_PRIORITY_DEF),
|
||||
.default_if_zero = TRUE,
|
||||
.only_with_stp = TRUE,
|
||||
),
|
||||
OPTION (NM_SETTING_BRIDGE_FORWARD_DELAY,
|
||||
"forward_delay",
|
||||
OPTION_TYPE_INT (NM_BRIDGE_FORWARD_DELAY_MIN, NM_BRIDGE_FORWARD_DELAY_MAX, NM_BRIDGE_FORWARD_DELAY_DEF),
|
||||
.default_if_zero = TRUE,
|
||||
.user_hz_compensate = TRUE,
|
||||
.only_with_stp = TRUE,
|
||||
),
|
||||
OPTION (NM_SETTING_BRIDGE_HELLO_TIME,
|
||||
"hello_time",
|
||||
OPTION_TYPE_INT (NM_BRIDGE_HELLO_TIME_MIN, NM_BRIDGE_HELLO_TIME_MAX, NM_BRIDGE_HELLO_TIME_DEF),
|
||||
.default_if_zero = TRUE,
|
||||
.user_hz_compensate = TRUE,
|
||||
.only_with_stp = TRUE,
|
||||
),
|
||||
OPTION (NM_SETTING_BRIDGE_MAX_AGE,
|
||||
"max_age",
|
||||
OPTION_TYPE_INT (NM_BRIDGE_MAX_AGE_MIN, NM_BRIDGE_MAX_AGE_MAX, NM_BRIDGE_MAX_AGE_DEF),
|
||||
.default_if_zero = TRUE,
|
||||
.user_hz_compensate = TRUE,
|
||||
.only_with_stp = TRUE,
|
||||
),
|
||||
OPTION (NM_SETTING_BRIDGE_AGEING_TIME,
|
||||
"ageing_time",
|
||||
OPTION_TYPE_INT (NM_BRIDGE_AGEING_TIME_MIN, NM_BRIDGE_AGEING_TIME_MAX, NM_BRIDGE_AGEING_TIME_DEF),
|
||||
.default_if_zero = TRUE,
|
||||
.user_hz_compensate = TRUE,
|
||||
),
|
||||
OPTION (NM_SETTING_BRIDGE_GROUP_FORWARD_MASK,
|
||||
"group_fwd_mask",
|
||||
OPTION_TYPE_INT (0, 0xFFFF, 0),
|
||||
.default_if_zero = TRUE,
|
||||
),
|
||||
OPTION (NM_SETTING_BRIDGE_MULTICAST_HASH_MAX,
|
||||
"hash_max",
|
||||
OPTION_TYPE_INT (NM_BRIDGE_MULTICAST_HASH_MAX_MIN, NM_BRIDGE_MULTICAST_HASH_MAX_MAX, NM_BRIDGE_MULTICAST_HASH_MAX_DEF),
|
||||
),
|
||||
OPTION (NM_SETTING_BRIDGE_MULTICAST_LAST_MEMBER_COUNT,
|
||||
"multicast_last_member_count",
|
||||
OPTION_TYPE_INT (NM_BRIDGE_MULTICAST_LAST_MEMBER_COUNT_MIN, NM_BRIDGE_MULTICAST_LAST_MEMBER_COUNT_MAX, NM_BRIDGE_MULTICAST_LAST_MEMBER_COUNT_DEF),
|
||||
),
|
||||
OPTION (NM_SETTING_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL,
|
||||
"multicast_last_member_interval",
|
||||
OPTION_TYPE_INT (NM_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL_MIN, NM_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL_MAX, NM_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL_DEF),
|
||||
),
|
||||
OPTION (NM_SETTING_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL,
|
||||
"multicast_membership_interval",
|
||||
OPTION_TYPE_INT (NM_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL_MIN, NM_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL_MAX, NM_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL_DEF),
|
||||
),
|
||||
OPTION (NM_SETTING_BRIDGE_MULTICAST_QUERIER,
|
||||
"multicast_querier",
|
||||
OPTION_TYPE_BOOL (NM_BRIDGE_MULTICAST_QUERIER_DEF),
|
||||
),
|
||||
OPTION (NM_SETTING_BRIDGE_MULTICAST_QUERIER_INTERVAL,
|
||||
"multicast_querier_interval",
|
||||
OPTION_TYPE_INT (NM_BRIDGE_MULTICAST_QUERIER_INTERVAL_MIN, NM_BRIDGE_MULTICAST_QUERIER_INTERVAL_MAX, NM_BRIDGE_MULTICAST_QUERIER_INTERVAL_DEF),
|
||||
),
|
||||
OPTION (NM_SETTING_BRIDGE_MULTICAST_QUERY_INTERVAL,
|
||||
"multicast_query_interval",
|
||||
OPTION_TYPE_INT (NM_BRIDGE_MULTICAST_QUERY_INTERVAL_MIN, NM_BRIDGE_MULTICAST_QUERY_INTERVAL_MAX, NM_BRIDGE_MULTICAST_QUERY_INTERVAL_DEF),
|
||||
),
|
||||
OPTION (NM_SETTING_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL,
|
||||
"multicast_query_response_interval",
|
||||
OPTION_TYPE_INT (NM_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL_MIN, NM_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL_MAX, NM_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL_DEF),
|
||||
),
|
||||
OPTION (NM_SETTING_BRIDGE_MULTICAST_QUERY_USE_IFADDR,
|
||||
"multicast_query_use_ifaddr",
|
||||
OPTION_TYPE_BOOL (NM_BRIDGE_MULTICAST_QUERY_USE_IFADDR_DEF),
|
||||
),
|
||||
OPTION (NM_SETTING_BRIDGE_MULTICAST_SNOOPING,
|
||||
"multicast_snooping",
|
||||
OPTION_TYPE_BOOL (NM_BRIDGE_MULTICAST_SNOOPING_DEF),
|
||||
),
|
||||
OPTION (NM_SETTING_BRIDGE_MULTICAST_ROUTER,
|
||||
"multicast_router",
|
||||
OPTION_TYPE_TOFROM (to_sysfs_multicast_router, from_sysfs_multicast_router),
|
||||
),
|
||||
OPTION (NM_SETTING_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT,
|
||||
"multicast_startup_query_count",
|
||||
OPTION_TYPE_INT (NM_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT_MIN, NM_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT_MAX, NM_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT_DEF),
|
||||
),
|
||||
OPTION (NM_SETTING_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL,
|
||||
"multicast_startup_query_interval",
|
||||
OPTION_TYPE_INT (NM_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL_MIN, NM_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL_MAX, NM_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL_DEF),
|
||||
),
|
||||
OPTION (NM_SETTING_BRIDGE_GROUP_ADDRESS,
|
||||
"group_addr",
|
||||
OPTION_TYPE_TOFROM (to_sysfs_group_address, from_sysfs_group_address),
|
||||
),
|
||||
OPTION (NM_SETTING_BRIDGE_VLAN_PROTOCOL,
|
||||
"vlan_protocol",
|
||||
OPTION_TYPE_TOFROM (to_sysfs_vlan_protocol, from_sysfs_vlan_protocol),
|
||||
),
|
||||
OPTION (NM_SETTING_BRIDGE_VLAN_STATS_ENABLED,
|
||||
"vlan_stats_enabled",
|
||||
OPTION_TYPE_BOOL (NM_BRIDGE_VLAN_STATS_ENABLED_DEF)
|
||||
),
|
||||
{ 0, }
|
||||
};
|
||||
|
||||
static const Option slave_options[] = {
|
||||
{ NM_SETTING_BRIDGE_PORT_PRIORITY, "priority",
|
||||
NULL, NULL,
|
||||
0, NM_BR_PORT_MAX_PRIORITY, NM_BR_PORT_DEF_PRIORITY,
|
||||
TRUE, FALSE },
|
||||
{ NM_SETTING_BRIDGE_PORT_PATH_COST, "path_cost",
|
||||
NULL, NULL,
|
||||
0, NM_BR_PORT_MAX_PATH_COST, 100,
|
||||
TRUE, FALSE },
|
||||
{ NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE, "hairpin_mode",
|
||||
NULL, NULL,
|
||||
0, 1, 0,
|
||||
FALSE, FALSE },
|
||||
{ NULL, NULL }
|
||||
OPTION (NM_SETTING_BRIDGE_PORT_PRIORITY,
|
||||
"priority",
|
||||
OPTION_TYPE_INT (NM_BRIDGE_PORT_PRIORITY_MIN, NM_BRIDGE_PORT_PRIORITY_MAX, NM_BRIDGE_PORT_PRIORITY_DEF),
|
||||
.default_if_zero = TRUE,
|
||||
),
|
||||
OPTION (NM_SETTING_BRIDGE_PORT_PATH_COST,
|
||||
"path_cost",
|
||||
OPTION_TYPE_INT (NM_BRIDGE_PORT_PATH_COST_MIN, NM_BRIDGE_PORT_PATH_COST_MAX, NM_BRIDGE_PORT_PATH_COST_DEF),
|
||||
.default_if_zero = TRUE,
|
||||
),
|
||||
OPTION (NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE,
|
||||
"hairpin_mode",
|
||||
OPTION_TYPE_BOOL (FALSE),
|
||||
),
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
static void
|
||||
|
|
@ -350,19 +418,24 @@ commit_option (NMDevice *device, NMSetting *setting, const Option *option, gbool
|
|||
case G_TYPE_BOOLEAN:
|
||||
value = g_value_get_boolean (&val) ? "1" : "0";
|
||||
break;
|
||||
case G_TYPE_UINT64:
|
||||
case G_TYPE_UINT: {
|
||||
guint uval;
|
||||
guint64 uval;
|
||||
|
||||
uval = g_value_get_uint (&val);
|
||||
if (pspec->value_type == G_TYPE_UINT64)
|
||||
uval = g_value_get_uint64 (&val);
|
||||
else
|
||||
uval = (guint) g_value_get_uint (&val);
|
||||
|
||||
/* zero means "unspecified" for some NM properties but isn't in the
|
||||
* allowed kernel range, so reset the property to the default value.
|
||||
*/
|
||||
if (option->default_if_zero && uval == 0) {
|
||||
g_value_unset (&val);
|
||||
g_value_init (&val, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
||||
g_param_value_set_default (pspec, &val);
|
||||
uval = g_value_get_uint (&val);
|
||||
if ( option->default_if_zero
|
||||
&& uval == 0) {
|
||||
if (pspec->value_type == G_TYPE_UINT64)
|
||||
uval = NM_G_PARAM_SPEC_GET_DEFAULT_UINT64 (pspec);
|
||||
else
|
||||
uval = NM_G_PARAM_SPEC_GET_DEFAULT_UINT (pspec);
|
||||
}
|
||||
|
||||
/* Linux kernel bridge interfaces use 'centiseconds' for time-based values.
|
||||
|
|
@ -373,7 +446,11 @@ commit_option (NMDevice *device, NMSetting *setting, const Option *option, gbool
|
|||
if (option->user_hz_compensate)
|
||||
uval *= 100;
|
||||
|
||||
nm_sprintf_buf (value_buf, "%u", uval);
|
||||
if (pspec->value_type == G_TYPE_UINT64)
|
||||
nm_sprintf_buf (value_buf, "%"G_GUINT64_FORMAT, uval);
|
||||
else
|
||||
nm_sprintf_buf (value_buf, "%u", (guint) uval);
|
||||
|
||||
value = value_buf;
|
||||
}
|
||||
break;
|
||||
|
|
@ -499,8 +576,9 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||
}
|
||||
|
||||
switch (pspec->value_type) {
|
||||
case G_TYPE_UINT64:
|
||||
case G_TYPE_UINT: {
|
||||
guint uvalue;
|
||||
guint64 uvalue;
|
||||
|
||||
/* See comments in set_sysfs_uint() about centiseconds. */
|
||||
if (option->user_hz_compensate) {
|
||||
|
|
@ -510,12 +588,16 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||
option->nm_default * 100);
|
||||
uvalue /= 100;
|
||||
} else {
|
||||
uvalue = _nm_utils_ascii_str_to_int64 (str, 10,
|
||||
option->nm_min,
|
||||
option->nm_max,
|
||||
option->nm_default);
|
||||
uvalue = _nm_utils_ascii_str_to_uint64 (str, 10,
|
||||
option->nm_min,
|
||||
option->nm_max,
|
||||
option->nm_default);
|
||||
}
|
||||
g_value_set_uint (&value, uvalue);
|
||||
|
||||
if (pspec->value_type == G_TYPE_UINT64)
|
||||
g_value_set_uint64(&value, uvalue);
|
||||
else
|
||||
g_value_set_uint (&value, (guint) uvalue);
|
||||
}
|
||||
break;
|
||||
case G_TYPE_BOOLEAN: {
|
||||
|
|
|
|||
|
|
@ -863,15 +863,14 @@ static void
|
|||
dispose (GObject *object)
|
||||
{
|
||||
NMDeviceMacsec *self = NM_DEVICE_MACSEC (object);
|
||||
NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE (self);
|
||||
|
||||
macsec_secrets_cancel (self);
|
||||
supplicant_interface_release (self);
|
||||
|
||||
G_OBJECT_CLASS (nm_device_macsec_parent_class)->dispose (object);
|
||||
|
||||
nm_assert (priv->parent_state_id == 0);
|
||||
nm_assert (priv->parent_mtu_id == 0);
|
||||
nm_assert (NM_DEVICE_MACSEC_GET_PRIVATE (self)->parent_state_id == 0);
|
||||
nm_assert (NM_DEVICE_MACSEC_GET_PRIVATE (self)->parent_mtu_id == 0);
|
||||
}
|
||||
|
||||
static const NMDBusInterfaceInfoExtended interface_info_device_macsec = {
|
||||
|
|
|
|||
|
|
@ -462,16 +462,16 @@ nm_device_macvlan_init (NMDeviceMacvlan *self)
|
|||
{
|
||||
}
|
||||
|
||||
#if NM_MORE_ASSERTS
|
||||
static void
|
||||
dispose (GObject *object)
|
||||
{
|
||||
NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE (object);
|
||||
|
||||
G_OBJECT_CLASS (nm_device_macvlan_parent_class)->dispose (object);
|
||||
|
||||
nm_assert (priv->parent_state_id == 0);
|
||||
nm_assert (priv->parent_mtu_id == 0);
|
||||
nm_assert (NM_DEVICE_MACVLAN_GET_PRIVATE (object)->parent_state_id == 0);
|
||||
nm_assert (NM_DEVICE_MACVLAN_GET_PRIVATE (object)->parent_mtu_id == 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
static const NMDBusInterfaceInfoExtended interface_info_device_macvlan = {
|
||||
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
|
||||
|
|
@ -496,7 +496,9 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass)
|
|||
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
|
||||
NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
|
||||
|
||||
#if NM_MORE_ASSERTS
|
||||
object_class->dispose = dispose;
|
||||
#endif
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include "nm-std-aux/unaligned.h"
|
||||
#include "nm-glib-aux/nm-dedup-multi.h"
|
||||
#include "nm-glib-aux/nm-random-utils.h"
|
||||
#include "systemd/nm-sd-utils-shared.h"
|
||||
|
||||
#include "nm-libnm-core-intern/nm-ethtool-utils.h"
|
||||
#include "nm-libnm-core-intern/nm-common-macros.h"
|
||||
|
|
@ -5998,7 +5999,6 @@ check_connection_compatible (NMDevice *self, NMConnection *connection, GError **
|
|||
gs_free_error GError *local = NULL;
|
||||
gs_free char *conn_iface = NULL;
|
||||
NMDeviceClass *klass;
|
||||
const char *const *patterns;
|
||||
NMSettingMatch *s_match;
|
||||
|
||||
klass = NM_DEVICE_GET_CLASS (self);
|
||||
|
|
@ -6041,6 +6041,8 @@ check_connection_compatible (NMDevice *self, NMConnection *connection, GError **
|
|||
s_match = (NMSettingMatch *) nm_connection_get_setting (connection,
|
||||
NM_TYPE_SETTING_MATCH);
|
||||
if (s_match) {
|
||||
const char *const *patterns;
|
||||
const char *device_driver;
|
||||
guint num_patterns = 0;
|
||||
|
||||
patterns = nm_setting_match_get_interface_names (s_match, &num_patterns);
|
||||
|
|
@ -6049,6 +6051,72 @@ check_connection_compatible (NMDevice *self, NMConnection *connection, GError **
|
|||
"device does not satisfy match.interface-name property");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
{
|
||||
const char *const*proc_cmdline;
|
||||
gboolean pos_patterns = FALSE;
|
||||
guint i;
|
||||
|
||||
patterns = nm_setting_match_get_kernel_command_lines (s_match, &num_patterns);
|
||||
proc_cmdline = nm_utils_proc_cmdline_split ();
|
||||
|
||||
for (i = 0; i < num_patterns; i++) {
|
||||
const char *patterns_i = patterns[i];
|
||||
const char *const*proc_cmdline_i;
|
||||
gboolean negative = FALSE;
|
||||
gboolean found = FALSE;
|
||||
const char *equal;
|
||||
|
||||
if (patterns_i[0] == '!') {
|
||||
++patterns_i;
|
||||
negative = TRUE;
|
||||
} else
|
||||
pos_patterns = TRUE;
|
||||
|
||||
equal = strchr (patterns_i, '=');
|
||||
|
||||
proc_cmdline_i = proc_cmdline;
|
||||
while (*proc_cmdline_i) {
|
||||
if (equal) {
|
||||
/* if pattern contains = compare full key=value */
|
||||
found = nm_streq (*proc_cmdline_i, patterns_i);
|
||||
} else {
|
||||
gsize l = strlen (patterns_i);
|
||||
|
||||
/* otherwise consider pattern as key only */
|
||||
if ( strncmp (*proc_cmdline_i, patterns_i, l) == 0
|
||||
&& NM_IN_SET ((*proc_cmdline_i)[l], '\0', '='))
|
||||
found = TRUE;
|
||||
}
|
||||
if ( found
|
||||
&& negative) {
|
||||
/* first negative match */
|
||||
nm_utils_error_set (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
|
||||
"device does not satisfy match.kernel-command-line property %s",
|
||||
patterns[i]);
|
||||
return FALSE;
|
||||
}
|
||||
proc_cmdline_i++;
|
||||
}
|
||||
|
||||
if ( pos_patterns
|
||||
&& !found) {
|
||||
/* positive patterns configured but no match */
|
||||
nm_utils_error_set (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
|
||||
"device does not satisfy any match.kernel-command-line property %s...",
|
||||
patterns[0]);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
device_driver = nm_device_get_driver (self);
|
||||
patterns = nm_setting_match_get_drivers (s_match, &num_patterns);
|
||||
if (!nm_wildcard_match_check (device_driver, patterns, num_patterns)) {
|
||||
nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
|
||||
"device does not satisfy match.driver property");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
@ -8315,6 +8383,37 @@ get_dhcp_hostname_flags (NMDevice *self, int addr_family)
|
|||
return NM_DHCP_HOSTNAME_FLAGS_FQDN_DEFAULT_IP6;
|
||||
}
|
||||
|
||||
static const char *
|
||||
connection_get_mud_url (NMDevice *self,
|
||||
NMSettingConnection *s_con,
|
||||
char **out_mud_url)
|
||||
{
|
||||
const char *mud_url;
|
||||
gs_free char *s = NULL;
|
||||
|
||||
nm_assert (out_mud_url && !*out_mud_url);
|
||||
|
||||
mud_url = nm_setting_connection_get_mud_url (s_con);
|
||||
|
||||
if (mud_url) {
|
||||
if (nm_streq (mud_url, NM_CONNECTION_MUD_URL_NONE))
|
||||
return NULL;
|
||||
return mud_url;
|
||||
}
|
||||
|
||||
s = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
|
||||
NM_CON_DEFAULT ("connection.mud-url"),
|
||||
self);
|
||||
if (s) {
|
||||
if (nm_streq (s, NM_CONNECTION_MUD_URL_NONE))
|
||||
return NULL;
|
||||
if (nm_sd_http_url_is_valid_https (s))
|
||||
return (*out_mud_url = g_steal_pointer (&s));
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static GBytes *
|
||||
dhcp4_get_client_id (NMDevice *self,
|
||||
NMConnection *connection,
|
||||
|
|
@ -8453,7 +8552,9 @@ dhcp4_start (NMDevice *self)
|
|||
gs_unref_bytes GBytes *hwaddr = NULL;
|
||||
gs_unref_bytes GBytes *bcast_hwaddr = NULL;
|
||||
gs_unref_bytes GBytes *client_id = NULL;
|
||||
gs_free char *mud_url_free = NULL;
|
||||
NMConnection *connection;
|
||||
NMSettingConnection *s_con;
|
||||
GError *error = NULL;
|
||||
const NMPlatformLink *pllink;
|
||||
|
||||
|
|
@ -8462,6 +8563,9 @@ dhcp4_start (NMDevice *self)
|
|||
|
||||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
||||
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
nm_assert (s_con);
|
||||
|
||||
/* Clear old exported DHCP options */
|
||||
nm_dbus_object_clear_and_unexport (&priv->dhcp_data_4.config);
|
||||
priv->dhcp_data_4.config = nm_dhcp_config_new (AF_INET);
|
||||
|
|
@ -8488,6 +8592,7 @@ dhcp4_start (NMDevice *self)
|
|||
nm_setting_ip_config_get_dhcp_hostname (s_ip4),
|
||||
nm_setting_ip4_config_get_dhcp_fqdn (NM_SETTING_IP4_CONFIG (s_ip4)),
|
||||
get_dhcp_hostname_flags (self, AF_INET),
|
||||
connection_get_mud_url (self, s_con, &mud_url_free),
|
||||
client_id,
|
||||
get_dhcp_timeout (self, AF_INET),
|
||||
priv->dhcp_anycast_address,
|
||||
|
|
@ -9235,15 +9340,19 @@ dhcp6_start_with_link_ready (NMDevice *self, NMConnection *connection)
|
|||
gs_unref_bytes GBytes *duid = NULL;
|
||||
gboolean enforce_duid = FALSE;
|
||||
const NMPlatformLink *pllink;
|
||||
gs_free char *mud_url_free = NULL;
|
||||
GError *error = NULL;
|
||||
guint32 iaid;
|
||||
gboolean iaid_explicit;
|
||||
|
||||
NMSettingConnection *s_con;
|
||||
const NMPlatformIP6Address *ll_addr = NULL;
|
||||
|
||||
g_assert (connection);
|
||||
g_return_val_if_fail (connection, FALSE);
|
||||
|
||||
s_ip6 = nm_connection_get_setting_ip6_config (connection);
|
||||
g_assert (s_ip6);
|
||||
nm_assert (s_ip6);
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
nm_assert (s_con);
|
||||
|
||||
if (priv->ext_ip6_config_captured) {
|
||||
ll_addr = nm_ip6_config_find_first_address (priv->ext_ip6_config_captured,
|
||||
|
|
@ -9278,6 +9387,7 @@ dhcp6_start_with_link_ready (NMDevice *self, NMConnection *connection)
|
|||
nm_setting_ip_config_get_dhcp_send_hostname (s_ip6),
|
||||
nm_setting_ip_config_get_dhcp_hostname (s_ip6),
|
||||
get_dhcp_hostname_flags (self, AF_INET6),
|
||||
connection_get_mud_url (self, s_con, &mud_url_free),
|
||||
duid,
|
||||
enforce_duid,
|
||||
iaid,
|
||||
|
|
|
|||
|
|
@ -131,10 +131,9 @@ typedef struct {
|
|||
#define OVSDB_MAX_FAILURES 3
|
||||
|
||||
static void
|
||||
_call_trace (const char *comment, OvsdbMethodCall *call, json_t *msg)
|
||||
_LOGT_call_do (const char *comment, OvsdbMethodCall *call, json_t *msg)
|
||||
{
|
||||
#if NM_MORE_LOGGING
|
||||
char *str = NULL;
|
||||
gs_free char *str = NULL;
|
||||
|
||||
if (msg)
|
||||
str = json_dumps (msg, 0);
|
||||
|
|
@ -169,12 +168,14 @@ _call_trace (const char *comment, OvsdbMethodCall *call, json_t *msg)
|
|||
call->mtu);
|
||||
break;
|
||||
}
|
||||
|
||||
if (msg)
|
||||
g_free (str);
|
||||
#endif
|
||||
}
|
||||
|
||||
#define _LOGT_call(comment, call, message) \
|
||||
G_STMT_START { \
|
||||
if (_LOGT_ENABLED ()) \
|
||||
_LOGT_call_do ((comment), (call), (message)); \
|
||||
} G_STMT_END
|
||||
|
||||
/**
|
||||
* ovsdb_call_method:
|
||||
*
|
||||
|
|
@ -226,7 +227,7 @@ ovsdb_call_method (NMOvsdb *self, OvsdbCommand command,
|
|||
break;
|
||||
}
|
||||
|
||||
_call_trace ("enqueue", call, NULL);
|
||||
_LOGT_call ("enqueue", call, NULL);
|
||||
|
||||
ovsdb_next_command (self);
|
||||
}
|
||||
|
|
@ -875,7 +876,7 @@ ovsdb_next_command (NMOvsdb *self)
|
|||
}
|
||||
|
||||
g_return_if_fail (msg);
|
||||
_call_trace ("send", call, msg);
|
||||
_LOGT_call ("send", call, msg);
|
||||
cmd = json_dumps (msg, 0);
|
||||
|
||||
g_string_append (priv->output, cmd);
|
||||
|
|
@ -1247,7 +1248,7 @@ ovsdb_got_msg (NMOvsdb *self, json_t *msg)
|
|||
}
|
||||
/* Cool, we found a corresponding call. Finish it. */
|
||||
|
||||
_call_trace ("response", call, msg);
|
||||
_LOGT_call ("response", call, msg);
|
||||
|
||||
if (!json_is_null (error)) {
|
||||
/* The response contains an error. */
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMDhcpClient,
|
|||
PROP_IAID_EXPLICIT,
|
||||
PROP_HOSTNAME,
|
||||
PROP_HOSTNAME_FLAGS,
|
||||
PROP_MUD_URL,
|
||||
);
|
||||
|
||||
typedef struct _NMDhcpClientPrivate {
|
||||
|
|
@ -60,6 +61,7 @@ typedef struct _NMDhcpClientPrivate {
|
|||
char * uuid;
|
||||
GBytes * client_id;
|
||||
char * hostname;
|
||||
char * mud_url;
|
||||
pid_t pid;
|
||||
guint timeout_id;
|
||||
guint watch_id;
|
||||
|
|
@ -312,6 +314,14 @@ nm_dhcp_client_get_use_fqdn (NMDhcpClient *self)
|
|||
return NM_DHCP_CLIENT_GET_PRIVATE (self)->use_fqdn;
|
||||
}
|
||||
|
||||
const char *
|
||||
nm_dhcp_client_get_mud_url (NMDhcpClient *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), NULL);
|
||||
|
||||
return NM_DHCP_CLIENT_GET_PRIVATE (self)->mud_url;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static const char *state_table[NM_DHCP_STATE_MAX + 1] = {
|
||||
|
|
@ -1052,6 +1062,10 @@ set_property (GObject *object, guint prop_id,
|
|||
/* construct-only */
|
||||
priv->hostname_flags = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_MUD_URL:
|
||||
/* construct-only */
|
||||
priv->mud_url = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_ROUTE_TABLE:
|
||||
priv->route_table = g_value_get_uint (value);
|
||||
break;
|
||||
|
|
@ -1102,6 +1116,7 @@ dispose (GObject *object)
|
|||
nm_clear_g_free (&priv->iface);
|
||||
nm_clear_g_free (&priv->hostname);
|
||||
nm_clear_g_free (&priv->uuid);
|
||||
nm_clear_g_free (&priv->mud_url);
|
||||
nm_clear_pointer (&priv->client_id, g_bytes_unref);
|
||||
nm_clear_pointer (&priv->hwaddr, g_bytes_unref);
|
||||
nm_clear_pointer (&priv->bcast_hwaddr, g_bytes_unref);
|
||||
|
|
@ -1191,6 +1206,12 @@ nm_dhcp_client_class_init (NMDhcpClientClass *client_class)
|
|||
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
obj_properties[PROP_MUD_URL] =
|
||||
g_param_spec_string (NM_DHCP_CLIENT_MUD_URL, "", "",
|
||||
NULL,
|
||||
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
obj_properties[PROP_ROUTE_TABLE] =
|
||||
g_param_spec_uint (NM_DHCP_CLIENT_ROUTE_TABLE, "", "",
|
||||
0, G_MAXUINT32, RT_TABLE_MAIN,
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#define NM_DHCP_CLIENT_INTERFACE "iface"
|
||||
#define NM_DHCP_CLIENT_MULTI_IDX "multi-idx"
|
||||
#define NM_DHCP_CLIENT_HOSTNAME "hostname"
|
||||
#define NM_DHCP_CLIENT_MUD_URL "mud-url"
|
||||
#define NM_DHCP_CLIENT_ROUTE_METRIC "route-metric"
|
||||
#define NM_DHCP_CLIENT_ROUTE_TABLE "route-table"
|
||||
#define NM_DHCP_CLIENT_TIMEOUT "timeout"
|
||||
|
|
@ -141,6 +142,7 @@ gboolean nm_dhcp_client_get_iaid_explicit (NMDhcpClient *self);
|
|||
GBytes *nm_dhcp_client_get_client_id (NMDhcpClient *self);
|
||||
|
||||
const char *nm_dhcp_client_get_hostname (NMDhcpClient *self);
|
||||
const char *nm_dhcp_client_get_mud_url (NMDhcpClient *self);
|
||||
|
||||
NMDhcpHostnameFlags nm_dhcp_client_get_hostname_flags (NMDhcpClient *self);
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,13 @@
|
|||
#define ALSOREQ_TAG "also request "
|
||||
#define REQ_TAG "request "
|
||||
|
||||
#define MUDURLv4_DEF "option mudurl code 161 = text;\n"
|
||||
#define MUDURLv4_FMT "send mudurl \"%s\";\n"
|
||||
|
||||
#define MUDURLv6_DEF "option dhcp6.mudurl code 112 = text;\n"
|
||||
#define MUDURLv6_FMT "send dhcp6.mudurl \"%s\";\n"
|
||||
|
||||
|
||||
static void
|
||||
add_request (GPtrArray *array, const char *item)
|
||||
{
|
||||
|
|
@ -183,6 +190,19 @@ add_hostname6 (GString *str,
|
|||
}
|
||||
}
|
||||
|
||||
static void add_mud_url_config(GString *str, const char *mud_url, int addr_family)
|
||||
{
|
||||
if (mud_url) {
|
||||
if (addr_family == AF_INET) {
|
||||
g_string_append (str, MUDURLv4_DEF);
|
||||
g_string_append_printf (str, MUDURLv4_FMT, mud_url);
|
||||
} else {
|
||||
g_string_append (str, MUDURLv6_DEF);
|
||||
g_string_append_printf (str, MUDURLv6_FMT, mud_url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static GBytes *
|
||||
read_client_id (const char *str)
|
||||
{
|
||||
|
|
@ -286,6 +306,7 @@ nm_dhcp_dhclient_create_config (const char *interface,
|
|||
guint32 timeout,
|
||||
gboolean use_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
const char *mud_url,
|
||||
const char *orig_path,
|
||||
const char *orig_contents,
|
||||
GBytes **out_new_client_id)
|
||||
|
|
@ -451,6 +472,7 @@ nm_dhcp_dhclient_create_config (const char *interface,
|
|||
g_string_append_printf (new_contents, "timeout %u;\n", timeout);
|
||||
}
|
||||
|
||||
add_mud_url_config (new_contents, mud_url, addr_family);
|
||||
if (addr_family == AF_INET) {
|
||||
add_ip4_config (new_contents, client_id, hostname, use_fqdn, hostname_flags);
|
||||
add_request (reqs, "rfc3442-classless-static-routes");
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ char *nm_dhcp_dhclient_create_config (const char *interface,
|
|||
guint32 timeout,
|
||||
gboolean use_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
const char *mud_url,
|
||||
const char *orig_path,
|
||||
const char *orig_contents,
|
||||
GBytes **out_new_client_id);
|
||||
|
|
|
|||
|
|
@ -147,6 +147,7 @@ merge_dhclient_config (NMDhcpDhclient *self,
|
|||
guint32 timeout,
|
||||
gboolean use_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
const char *mud_url,
|
||||
const char *orig_path,
|
||||
GBytes **out_new_client_id,
|
||||
GError **error)
|
||||
|
|
@ -176,6 +177,7 @@ merge_dhclient_config (NMDhcpDhclient *self,
|
|||
timeout,
|
||||
use_fqdn,
|
||||
hostname_flags,
|
||||
mud_url,
|
||||
orig_path,
|
||||
orig,
|
||||
out_new_client_id);
|
||||
|
|
@ -268,6 +270,7 @@ create_dhclient_config (NMDhcpDhclient *self,
|
|||
guint32 timeout,
|
||||
gboolean use_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
const char *mud_url,
|
||||
GBytes **out_new_client_id)
|
||||
{
|
||||
gs_free char *orig = NULL;
|
||||
|
|
@ -296,6 +299,7 @@ create_dhclient_config (NMDhcpDhclient *self,
|
|||
timeout,
|
||||
use_fqdn,
|
||||
hostname_flags,
|
||||
mud_url,
|
||||
orig,
|
||||
out_new_client_id,
|
||||
&error)) {
|
||||
|
|
@ -496,6 +500,7 @@ ip4_start (NMDhcpClient *client,
|
|||
nm_dhcp_client_get_timeout (client),
|
||||
nm_dhcp_client_get_use_fqdn (client),
|
||||
nm_dhcp_client_get_hostname_flags (client),
|
||||
nm_dhcp_client_get_mud_url (client),
|
||||
&new_client_id);
|
||||
if (!priv->conf_file) {
|
||||
nm_utils_error_set_literal (error,
|
||||
|
|
@ -540,6 +545,7 @@ ip6_start (NMDhcpClient *client,
|
|||
nm_dhcp_client_get_timeout (client),
|
||||
TRUE,
|
||||
nm_dhcp_client_get_hostname_flags (client),
|
||||
nm_dhcp_client_get_mud_url (client),
|
||||
NULL);
|
||||
if (!priv->conf_file) {
|
||||
nm_utils_error_set_literal (error,
|
||||
|
|
|
|||
|
|
@ -46,33 +46,46 @@
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static const char * ignore[] = {"PATH", "SHLVL", "_", "PWD", "dhc_dbus", NULL};
|
||||
|
||||
static GVariant *
|
||||
build_signal_parameters (void)
|
||||
{
|
||||
char **item;
|
||||
const char *const*environ_iter;
|
||||
GVariantBuilder builder;
|
||||
|
||||
g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
|
||||
|
||||
/* List environment and format for dbus dict */
|
||||
for (item = environ; *item; item++) {
|
||||
char *name, *val, **p;
|
||||
for (environ_iter = (const char *const*) environ; *environ_iter; environ_iter++) {
|
||||
static const char *const ignore_with_prefix_list[] = {
|
||||
"PATH",
|
||||
"SHLVL",
|
||||
"_",
|
||||
"PWD",
|
||||
"dhc_dbus",
|
||||
NULL
|
||||
};
|
||||
const char *item = *environ_iter;
|
||||
gs_free char *name = NULL;
|
||||
const char *val;
|
||||
const char *const*p;
|
||||
|
||||
/* Split on the = */
|
||||
name = g_strdup (*item);
|
||||
val = strchr (name, '=');
|
||||
if (!val || val == name)
|
||||
goto next;
|
||||
*val++ = '\0';
|
||||
val = strchr (item, '=');
|
||||
if ( !val
|
||||
|| item == val)
|
||||
continue;
|
||||
|
||||
/* Ignore non-DCHP-related environment variables */
|
||||
for (p = (char **) ignore; *p; p++) {
|
||||
name = g_strndup (item, val - item);
|
||||
val += 1;
|
||||
|
||||
/* Ignore non-DHCP-related environment variables */
|
||||
for (p = ignore_with_prefix_list; *p; p++) {
|
||||
if (strncmp (name, *p, strlen (*p)) == 0)
|
||||
goto next;
|
||||
}
|
||||
|
||||
if (!g_utf8_validate (name, -1, NULL))
|
||||
continue;
|
||||
|
||||
/* Value passed as a byte array rather than a string, because there are
|
||||
* no character encoding guarantees with DHCP, and D-Bus requires
|
||||
* strings to be UTF-8.
|
||||
|
|
@ -85,8 +98,8 @@ build_signal_parameters (void)
|
|||
g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE,
|
||||
val, strlen (val), 1));
|
||||
|
||||
next:
|
||||
g_free (name);
|
||||
next:
|
||||
;
|
||||
}
|
||||
|
||||
return g_variant_ref_sink (g_variant_new ("(a{sv})", &builder));
|
||||
|
|
|
|||
|
|
@ -220,6 +220,7 @@ client_start (NMDhcpManager *self,
|
|||
const char *hostname,
|
||||
gboolean hostname_use_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
const char *mud_url,
|
||||
gboolean info_only,
|
||||
NMSettingIP6ConfigPrivacy privacy,
|
||||
const char *last_ip4_address,
|
||||
|
|
@ -303,6 +304,7 @@ client_start (NMDhcpManager *self,
|
|||
NM_DHCP_CLIENT_IAID, (guint) iaid,
|
||||
NM_DHCP_CLIENT_IAID_EXPLICIT, iaid_explicit,
|
||||
NM_DHCP_CLIENT_HOSTNAME, hostname,
|
||||
NM_DHCP_CLIENT_MUD_URL, mud_url,
|
||||
NM_DHCP_CLIENT_ROUTE_TABLE, (guint) route_table,
|
||||
NM_DHCP_CLIENT_ROUTE_METRIC, (guint) route_metric,
|
||||
NM_DHCP_CLIENT_TIMEOUT, (guint) timeout,
|
||||
|
|
@ -382,6 +384,7 @@ nm_dhcp_manager_start_ip4 (NMDhcpManager *self,
|
|||
const char *dhcp_hostname,
|
||||
const char *dhcp_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
const char *mud_url,
|
||||
GBytes *dhcp_client_id,
|
||||
guint32 timeout,
|
||||
const char *dhcp_anycast_addr,
|
||||
|
|
@ -440,6 +443,7 @@ nm_dhcp_manager_start_ip4 (NMDhcpManager *self,
|
|||
hostname,
|
||||
use_fqdn,
|
||||
hostname_flags,
|
||||
mud_url,
|
||||
FALSE,
|
||||
0,
|
||||
last_ip_address,
|
||||
|
|
@ -462,6 +466,7 @@ nm_dhcp_manager_start_ip6 (NMDhcpManager *self,
|
|||
gboolean send_hostname,
|
||||
const char *dhcp_hostname,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
const char *mud_url,
|
||||
GBytes *duid,
|
||||
gboolean enforce_duid,
|
||||
guint32 iaid,
|
||||
|
|
@ -503,6 +508,7 @@ nm_dhcp_manager_start_ip6 (NMDhcpManager *self,
|
|||
hostname,
|
||||
TRUE,
|
||||
hostname_flags,
|
||||
mud_url,
|
||||
info_only,
|
||||
privacy,
|
||||
NULL,
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ NMDhcpClient * nm_dhcp_manager_start_ip4 (NMDhcpManager *manager,
|
|||
const char *dhcp_hostname,
|
||||
const char *dhcp_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
const char *mud_url,
|
||||
GBytes *dhcp_client_id,
|
||||
guint32 timeout,
|
||||
const char *dhcp_anycast_addr,
|
||||
|
|
@ -62,6 +63,7 @@ NMDhcpClient * nm_dhcp_manager_start_ip6 (NMDhcpManager *manager,
|
|||
gboolean send_hostname,
|
||||
const char *dhcp_hostname,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
const char *mud_url,
|
||||
GBytes *duid,
|
||||
gboolean enforce_duid,
|
||||
guint32 iaid,
|
||||
|
|
|
|||
|
|
@ -68,6 +68,20 @@ G_DEFINE_TYPE (NMDhcpNettools, nm_dhcp_nettools, NM_TYPE_DHCP_CLIENT)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
set_error_nettools (GError **error, int r, const char *message)
|
||||
{
|
||||
/* the error code returned from n_dhcp4_* API is either a negative
|
||||
* errno, or a positive internal error code. Generate different messages
|
||||
* for these. */
|
||||
if (r < 0)
|
||||
nm_utils_error_set_errno (error, r, "%s: %s", message);
|
||||
else
|
||||
nm_utils_error_set (error, r, "%s (code %d)", message, r);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define DHCP_MAX_FQDN_LENGTH 255
|
||||
|
||||
enum {
|
||||
|
|
@ -681,11 +695,10 @@ lease_parse_metered (NDhcp4ClientLease *lease,
|
|||
int r;
|
||||
|
||||
r = n_dhcp4_client_lease_query (lease, NM_DHCP_OPTION_DHCP4_VENDOR_SPECIFIC, &data, &n_data);
|
||||
if (r) {
|
||||
if (r)
|
||||
metered = FALSE;
|
||||
} else {
|
||||
else
|
||||
metered = !!memmem (data, n_data, "ANDROID_METERED", NM_STRLEN ("ANDROID_METERED"));
|
||||
}
|
||||
|
||||
/* TODO: expose the vendor specific option when present */
|
||||
nm_ip4_config_set_metered (ip4_config, metered);
|
||||
|
|
@ -1023,9 +1036,8 @@ dhcp4_event_handle (NMDhcpNettools *self,
|
|||
case N_DHCP4_CLIENT_EVENT_OFFER:
|
||||
/* always accept the first lease */
|
||||
r = n_dhcp4_client_lease_select (event->offer.lease);
|
||||
if (r) {
|
||||
if (r)
|
||||
_LOGW ("selecting lease failed: %d", r);
|
||||
}
|
||||
break;
|
||||
case N_DHCP4_CLIENT_EVENT_RETRACTED:
|
||||
case N_DHCP4_CLIENT_EVENT_EXPIRED:
|
||||
|
|
@ -1170,7 +1182,7 @@ nettools_create (NMDhcpNettools *self,
|
|||
|
||||
r = n_dhcp4_client_config_new (&config);
|
||||
if (r) {
|
||||
nm_utils_error_set_errno (error, r, "failed to create client-config: %s");
|
||||
set_error_nettools (error, r, "failed to create client-config");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -1184,13 +1196,13 @@ nettools_create (NMDhcpNettools *self,
|
|||
client_id_arr,
|
||||
NM_MIN (client_id_len, 1 + _NM_SD_MAX_CLIENT_ID_LEN));
|
||||
if (r) {
|
||||
nm_utils_error_set_errno (error, r, "failed to set client-id: %s");
|
||||
set_error_nettools (error, r, "failed to set client-id");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
r = n_dhcp4_client_new (&client, config);
|
||||
if (r) {
|
||||
nm_utils_error_set (error, NM_UTILS_ERROR_UNKNOWN, "failed to create client: error %d", r);
|
||||
set_error_nettools (error, r, "failed to create client");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -1224,7 +1236,7 @@ _accept (NMDhcpClient *client,
|
|||
|
||||
r = n_dhcp4_client_lease_accept (priv->lease);
|
||||
if (r) {
|
||||
nm_utils_error_set_errno (error, r, "failed to accept lease: %s");
|
||||
set_error_nettools (error, r, "failed to accept lease");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -1248,7 +1260,7 @@ decline (NMDhcpClient *client,
|
|||
|
||||
r = n_dhcp4_client_lease_decline (priv->lease, error_message);
|
||||
if (r) {
|
||||
nm_utils_error_set_errno (error, r, "failed to decline lease: %s");
|
||||
set_error_nettools (error, r, "failed to decline lease");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -1285,6 +1297,7 @@ ip4_start (NMDhcpClient *client,
|
|||
gs_free char *lease_file = NULL;
|
||||
struct in_addr last_addr = { 0 };
|
||||
const char *hostname;
|
||||
const char *mud_url;
|
||||
int r, i;
|
||||
|
||||
g_return_val_if_fail (!priv->probe, FALSE);
|
||||
|
|
@ -1294,7 +1307,7 @@ ip4_start (NMDhcpClient *client,
|
|||
|
||||
r = n_dhcp4_client_probe_config_new (&config);
|
||||
if (r) {
|
||||
nm_utils_error_set_errno (error, r, "failed to create dhcp-client-probe-config: %s");
|
||||
set_error_nettools (error, r, "failed to create dhcp-client-probe-config");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -1341,6 +1354,17 @@ ip4_start (NMDhcpClient *client,
|
|||
}
|
||||
}
|
||||
|
||||
mud_url = nm_dhcp_client_get_mud_url (client);
|
||||
if (mud_url) {
|
||||
r = n_dhcp4_client_probe_config_append_option (config,
|
||||
NM_DHCP_OPTION_DHCP4_MUD_URL,
|
||||
mud_url,
|
||||
strlen (mud_url));
|
||||
if (r) {
|
||||
set_error_nettools (error, r, "failed to set MUD URL");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
hostname = nm_dhcp_client_get_hostname (client);
|
||||
if (hostname) {
|
||||
if (nm_dhcp_client_get_use_fqdn (client)) {
|
||||
|
|
@ -1359,7 +1383,10 @@ ip4_start (NMDhcpClient *client,
|
|||
sizeof (buffer) - 3,
|
||||
FALSE);
|
||||
if (r <= 0) {
|
||||
nm_utils_error_set_errno (error, r, "failed to convert DHCP FQDN: %s");
|
||||
if (r < 0)
|
||||
nm_utils_error_set_errno (error, r, "failed to convert DHCP FQDN: %s");
|
||||
else
|
||||
nm_utils_error_set (error, r, "failed to convert DHCP FQDN");
|
||||
return FALSE;
|
||||
}
|
||||
fqdn_len = r;
|
||||
|
|
@ -1377,7 +1404,7 @@ ip4_start (NMDhcpClient *client,
|
|||
buffer,
|
||||
3 + fqdn_len);
|
||||
if (r) {
|
||||
nm_utils_error_set_errno (error, r, "failed to set DHCP FQDN: %s");
|
||||
set_error_nettools (error, r, "failed to set DHCP FQDN");
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1386,7 +1413,7 @@ ip4_start (NMDhcpClient *client,
|
|||
hostname,
|
||||
strlen (hostname));
|
||||
if (r) {
|
||||
nm_utils_error_set_errno (error, r, "failed to set DHCP hostname: %s");
|
||||
set_error_nettools (error, r, "failed to set DHCP hostname");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
@ -1397,7 +1424,7 @@ ip4_start (NMDhcpClient *client,
|
|||
|
||||
r = n_dhcp4_client_probe (priv->client, &priv->probe, config);
|
||||
if (r) {
|
||||
nm_utils_error_set_errno (error, r, "failed to start DHCP client: %s");
|
||||
set_error_nettools (error, r, "failed to start DHCP client");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -1434,7 +1461,7 @@ dispose (GObject *object)
|
|||
{
|
||||
NMDhcpNettoolsPrivate *priv = NM_DHCP_NETTOOLS_GET_PRIVATE (object);
|
||||
|
||||
nm_clear_pointer (&priv->lease_file, g_free);
|
||||
nm_clear_g_free (&priv->lease_file);
|
||||
nm_clear_g_source_inst (&priv->event_source);
|
||||
nm_clear_pointer (&priv->lease, n_dhcp4_client_lease_unref);
|
||||
nm_clear_pointer (&priv->probe, n_dhcp4_client_probe_free);
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ const NMDhcpOption _nm_dhcp_option_dhcp4_options[] = {
|
|||
REQ (NM_DHCP_OPTION_DHCP4_TFTP_SERVER_ADDRESS, "tftp_server_address", FALSE ),
|
||||
REQ (NM_DHCP_OPTION_DHCP4_V4_PORTPARAMS, "v4_portparams", FALSE ),
|
||||
REQ (NM_DHCP_OPTION_DHCP4_V4_CAPTIVE_PORTAL, "v4_captive_portal", FALSE ),
|
||||
REQ (NM_DHCP_OPTION_DHCP4_MUD_URL, "mud_url", FALSE ),
|
||||
REQ (NM_DHCP_OPTION_DHCP4_LOADER_CONFIGFILE, "loader_configfile", FALSE ),
|
||||
REQ (NM_DHCP_OPTION_DHCP4_LOADER_PATHPREFIX, "loader_pathprefix", FALSE ),
|
||||
REQ (NM_DHCP_OPTION_DHCP4_LOADER_REBOOTTIME, "loader_reboottime", FALSE ),
|
||||
|
|
@ -182,6 +183,7 @@ const NMDhcpOption _nm_dhcp_option_dhcp6_options[] = {
|
|||
REQ (NM_DHCP_OPTION_DHCP6_DNS_SERVERS, "dhcp6_name_servers", TRUE ),
|
||||
REQ (NM_DHCP_OPTION_DHCP6_DOMAIN_LIST, "dhcp6_domain_search", TRUE ),
|
||||
REQ (NM_DHCP_OPTION_DHCP6_SNTP_SERVERS, "dhcp6_sntp_servers", TRUE ),
|
||||
REQ (NM_DHCP_OPTION_DHCP6_MUD_URL, "dhcp6_mud_url", FALSE ),
|
||||
|
||||
/* Internal values */
|
||||
REQ (NM_DHCP_OPTION_DHCP6_NM_IP_ADDRESS, "ip6_address", FALSE ),
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ typedef enum {
|
|||
NM_DHCP_OPTION_DHCP4_TFTP_SERVER_ADDRESS = 150,
|
||||
NM_DHCP_OPTION_DHCP4_V4_PORTPARAMS = 159,
|
||||
NM_DHCP_OPTION_DHCP4_V4_CAPTIVE_PORTAL = 160,
|
||||
NM_DHCP_OPTION_DHCP4_MUD_URL = 161,
|
||||
NM_DHCP_OPTION_DHCP4_LOADER_CONFIGFILE = 209,
|
||||
NM_DHCP_OPTION_DHCP4_LOADER_PATHPREFIX = 210,
|
||||
NM_DHCP_OPTION_DHCP4_LOADER_REBOOTTIME = 211,
|
||||
|
|
@ -159,6 +160,7 @@ typedef enum {
|
|||
NM_DHCP_OPTION_DHCP6_DNS_SERVERS = 23,
|
||||
NM_DHCP_OPTION_DHCP6_DOMAIN_LIST = 24,
|
||||
NM_DHCP_OPTION_DHCP6_SNTP_SERVERS = 31,
|
||||
NM_DHCP_OPTION_DHCP6_MUD_URL = 112,
|
||||
/* Internal values */
|
||||
NM_DHCP_OPTION_DHCP6_NM_IP_ADDRESS = 1026,
|
||||
NM_DHCP_OPTION_DHCP6_NM_PREFIXLEN = 1027,
|
||||
|
|
|
|||
|
|
@ -573,6 +573,7 @@ ip4_start (NMDhcpClient *client,
|
|||
size_t client_id_len;
|
||||
struct in_addr last_addr = { 0 };
|
||||
const char *hostname;
|
||||
const char *mud_url;
|
||||
int r, i;
|
||||
|
||||
g_return_val_if_fail (!priv->client4, FALSE);
|
||||
|
|
@ -688,6 +689,15 @@ ip4_start (NMDhcpClient *client,
|
|||
}
|
||||
}
|
||||
|
||||
mud_url = nm_dhcp_client_get_mud_url (client);
|
||||
if (mud_url) {
|
||||
r = sd_dhcp_client_set_mud_url (sd_client, mud_url);
|
||||
if (r < 0) {
|
||||
nm_utils_error_set_errno (error, r, "failed to set DHCP MUDURL: %s");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
r = sd_dhcp_client_set_callback (sd_client, dhcp_event_cb, client);
|
||||
if (r < 0) {
|
||||
nm_utils_error_set_errno (error, r, "failed to set callback: %s");
|
||||
|
|
@ -894,6 +904,7 @@ ip6_start (NMDhcpClient *client,
|
|||
nm_auto (sd_dhcp6_client_unrefp) sd_dhcp6_client *sd_client = NULL;
|
||||
GBytes *hwaddr;
|
||||
const char *hostname;
|
||||
const char *mud_url;
|
||||
int r, i;
|
||||
const guint8 *duid_arr;
|
||||
gsize duid_len;
|
||||
|
|
@ -976,6 +987,15 @@ ip6_start (NMDhcpClient *client,
|
|||
}
|
||||
}
|
||||
|
||||
mud_url = nm_dhcp_client_get_mud_url (client);
|
||||
if (mud_url) {
|
||||
r = sd_dhcp6_client_set_request_mud_url (sd_client, mud_url);
|
||||
if (r < 0) {
|
||||
nm_utils_error_set_errno (error, r, "failed to set mud-url: %s");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (needed_prefixes > 0) {
|
||||
if (needed_prefixes > 1)
|
||||
_LOGW ("dhcp-client6: only one prefix request is supported");
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include "nm-test-utils-core.h"
|
||||
|
||||
#define TEST_DIR NM_BUILD_SRCDIR"/src/dhcp/tests"
|
||||
#define TEST_MUDURL "https://example.com/mud.json"
|
||||
|
||||
static void
|
||||
test_config (const char *orig,
|
||||
|
|
@ -33,7 +34,8 @@ test_config (const char *orig,
|
|||
const char *dhcp_client_id,
|
||||
GBytes *expected_new_client_id,
|
||||
const char *iface,
|
||||
const char *anycast_addr)
|
||||
const char *anycast_addr,
|
||||
const char *mud_url)
|
||||
{
|
||||
gs_free char *new = NULL;
|
||||
gs_unref_bytes GBytes *client_id = NULL;
|
||||
|
|
@ -52,6 +54,7 @@ test_config (const char *orig,
|
|||
timeout,
|
||||
use_fqdn,
|
||||
hostname_flags,
|
||||
mud_url,
|
||||
"/path/to/dhclient.conf",
|
||||
orig,
|
||||
&new_client_id);
|
||||
|
|
@ -100,7 +103,37 @@ test_orig_missing (void)
|
|||
orig_missing_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL, NULL, "eth0", NULL);
|
||||
NULL, NULL, "eth0", NULL, NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
static const char *orig_missing_add_mud_url_expected = \
|
||||
"# Created by NetworkManager\n"
|
||||
"\n"
|
||||
"option mudurl code 161 = text;\n"
|
||||
"send mudurl \"https://example.com/mud.json\";\n\n"
|
||||
"option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n"
|
||||
"option ms-classless-static-routes code 249 = array of unsigned integer 8;\n"
|
||||
"option wpad code 252 = string;\n"
|
||||
"\n"
|
||||
"also request rfc3442-classless-static-routes;\n"
|
||||
"also request ms-classless-static-routes;\n"
|
||||
"also request static-routes;\n"
|
||||
"also request wpad;\n"
|
||||
"also request ntp-servers;\n"
|
||||
"also request root-path;\n"
|
||||
"\n";
|
||||
|
||||
static void
|
||||
test_orig_missing_add_mud_url (void)
|
||||
{
|
||||
test_config (NULL,
|
||||
orig_missing_add_mud_url_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL, NULL, "eth0", NULL, TEST_MUDURL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -135,6 +168,7 @@ test_override_client_id (void)
|
|||
"11:22:33:44:55:66",
|
||||
NULL,
|
||||
"eth0",
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -166,6 +200,7 @@ test_quote_client_id (void)
|
|||
"abcd",
|
||||
NULL,
|
||||
"eth0",
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -197,6 +232,7 @@ test_quote_client_id_2 (void)
|
|||
"a\\bc",
|
||||
NULL,
|
||||
"eth0",
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -228,6 +264,7 @@ test_hex_zero_client_id (void)
|
|||
"00:11:22:33",
|
||||
NULL,
|
||||
"eth0",
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -259,6 +296,7 @@ test_ascii_client_id (void)
|
|||
"qb:cd:ef:12:34:56",
|
||||
NULL,
|
||||
"eth0",
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -290,6 +328,7 @@ test_hex_single_client_id (void)
|
|||
"ab:cd:e:12:34:56",
|
||||
NULL,
|
||||
"eth0",
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -329,6 +368,7 @@ test_existing_hex_client_id (void)
|
|||
NULL,
|
||||
new_client_id,
|
||||
"eth0",
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -367,6 +407,7 @@ test_existing_escaped_client_id (void)
|
|||
NULL,
|
||||
new_client_id,
|
||||
"eth0",
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -409,6 +450,7 @@ test_existing_ascii_client_id (void)
|
|||
NULL,
|
||||
new_client_id,
|
||||
"eth0",
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
|
@ -443,6 +485,7 @@ test_fqdn (void)
|
|||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -486,6 +529,7 @@ test_fqdn_options_override (void)
|
|||
TRUE, NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -521,6 +565,7 @@ test_override_hostname (void)
|
|||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -550,6 +595,7 @@ test_override_hostname6 (void)
|
|||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -576,6 +622,7 @@ test_nonfqdn_hostname6 (void)
|
|||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -613,6 +660,7 @@ test_existing_alsoreq (void)
|
|||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -653,6 +701,7 @@ test_existing_req (void)
|
|||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -694,6 +743,7 @@ test_existing_multiline_alsoreq (void)
|
|||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -934,6 +984,7 @@ test_interface1 (void)
|
|||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -981,6 +1032,7 @@ test_interface2 (void)
|
|||
NULL,
|
||||
NULL,
|
||||
"eth1",
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -1093,6 +1145,7 @@ test_structured (void)
|
|||
NULL,
|
||||
new_client_id,
|
||||
"eth0",
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -1149,6 +1202,7 @@ test_config_req_intf (void)
|
|||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -1162,6 +1216,7 @@ main (int argc, char **argv)
|
|||
nmtst_init_with_logging (&argc, &argv, NULL, "DEFAULT");
|
||||
|
||||
g_test_add_func ("/dhcp/dhclient/orig_missing", test_orig_missing);
|
||||
g_test_add_func ("/dhcp/dhclient/orig_missing_add_mud_url", test_orig_missing_add_mud_url);
|
||||
g_test_add_func ("/dhcp/dhclient/override_client_id", test_override_client_id);
|
||||
g_test_add_func ("/dhcp/dhclient/quote_client_id/1", test_quote_client_id);
|
||||
g_test_add_func ("/dhcp/dhclient/quote_client_id/2", test_quote_client_id_2);
|
||||
|
|
|
|||
|
|
@ -64,24 +64,28 @@ err_out:
|
|||
}
|
||||
|
||||
#define DEFAULT_SYSFS_DIR "/sys"
|
||||
#define DEFAULT_INITRD_DATA_DIR NMRUNDIR "/initrd"
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
GHashTable *connections;
|
||||
gs_free char *connections_dir = NULL;
|
||||
gs_free char *initrd_dir = NULL;
|
||||
gs_free char *sysfs_dir = NULL;
|
||||
gboolean dump_to_stdout = FALSE;
|
||||
gs_strfreev char **remaining = NULL;
|
||||
GOptionEntry option_entries[] = {
|
||||
{ "connections-dir", 'c', 0, G_OPTION_ARG_FILENAME, &connections_dir, "Output connection directory", NM_KEYFILE_PATH_NAME_RUN },
|
||||
{ "sysfs-dir", 'd', 0, G_OPTION_ARG_FILENAME, &sysfs_dir, "The sysfs mount point", DEFAULT_SYSFS_DIR },
|
||||
{ "stdout", 's', 0, G_OPTION_ARG_NONE, &dump_to_stdout, "Dump connections to standard output", NULL },
|
||||
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &remaining, NULL, NULL },
|
||||
{ "connections-dir", 'c', 0, G_OPTION_ARG_FILENAME, &connections_dir, "Output connection directory", NM_KEYFILE_PATH_NAME_RUN },
|
||||
{ "initrd-data-dir", 'i', 0, G_OPTION_ARG_FILENAME, &initrd_dir, "Output initrd data directory", DEFAULT_INITRD_DATA_DIR },
|
||||
{ "sysfs-dir", 'd', 0, G_OPTION_ARG_FILENAME, &sysfs_dir, "The sysfs mount point", DEFAULT_SYSFS_DIR },
|
||||
{ "stdout", 's', 0, G_OPTION_ARG_NONE, &dump_to_stdout, "Dump connections to standard output", NULL },
|
||||
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &remaining, NULL, NULL },
|
||||
{ NULL }
|
||||
};
|
||||
GOptionContext *option_context;
|
||||
GError *error = NULL;
|
||||
gs_free_error GError *error = NULL;
|
||||
gs_free char *hostname = NULL;
|
||||
int errsv;
|
||||
|
||||
option_context = g_option_context_new ("-- [ip=...] [rd.route=...] [bridge=...] [bond=...] [team=...] [vlan=...] "
|
||||
|
|
@ -108,6 +112,8 @@ main (int argc, char *argv[])
|
|||
connections_dir = g_strdup (NM_KEYFILE_PATH_NAME_RUN);
|
||||
if (!sysfs_dir)
|
||||
sysfs_dir = g_strdup (DEFAULT_SYSFS_DIR);
|
||||
if (!initrd_dir)
|
||||
initrd_dir = g_strdup (DEFAULT_INITRD_DATA_DIR);
|
||||
if (dump_to_stdout)
|
||||
nm_clear_g_free (&connections_dir);
|
||||
|
||||
|
|
@ -117,9 +123,31 @@ main (int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
connections = nmi_cmdline_reader_parse (sysfs_dir, (const char *const*) remaining);
|
||||
connections = nmi_cmdline_reader_parse (sysfs_dir,
|
||||
(const char *const*) remaining,
|
||||
&hostname);
|
||||
|
||||
g_hash_table_foreach (connections, output_conn, connections_dir);
|
||||
g_hash_table_destroy (connections);
|
||||
|
||||
if (g_mkdir_with_parents (initrd_dir, 0755) != 0) {
|
||||
errsv = errno;
|
||||
_LOGW (LOGD_CORE, "%s: %s", initrd_dir, nm_strerror_native (errsv));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (hostname) {
|
||||
gs_free char *hostname_file = NULL;
|
||||
gs_free char *data = NULL;
|
||||
|
||||
hostname_file = g_strdup_printf ("%s/hostname", initrd_dir);
|
||||
data = g_strdup_printf ("%s\n", hostname);
|
||||
|
||||
if (!g_file_set_contents (hostname_file, data, strlen (data), &error)) {
|
||||
_LOGW (LOGD_CORE, "%s: %s", hostname_file, error->message);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,6 @@ gboolean nmi_ibft_update_connection_from_nic (NMConnection *connection, GHashTab
|
|||
|
||||
NMConnection *nmi_dt_reader_parse (const char *sysfs_dir);
|
||||
|
||||
GHashTable *nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv);
|
||||
GHashTable *nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv, char **hostname);
|
||||
|
||||
#endif /* __NM_INITRD_GENERATOR_H__ */
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-initrd-generator.h"
|
||||
#include "systemd/nm-sd-utils-shared.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
@ -22,6 +23,11 @@ typedef struct {
|
|||
GPtrArray *array;
|
||||
NMConnection *bootdev_connection; /* connection for bootdev=$ifname */
|
||||
NMConnection *default_connection; /* connection not bound to any ifname */
|
||||
char *hostname;
|
||||
|
||||
/* Parameters to be set for all connections */
|
||||
gboolean ignore_auto_dns;
|
||||
int dhcp_timeout;
|
||||
} Reader;
|
||||
|
||||
static Reader *
|
||||
|
|
@ -45,6 +51,7 @@ reader_destroy (Reader *reader, gboolean free_hash)
|
|||
|
||||
g_ptr_array_unref (reader->array);
|
||||
hash = g_steal_pointer (&reader->hash);
|
||||
nm_clear_g_free (&reader->hostname);
|
||||
nm_g_slice_free (reader);
|
||||
if (!free_hash)
|
||||
return g_steal_pointer (&hash);
|
||||
|
|
@ -86,6 +93,8 @@ reader_create_connection (Reader *reader,
|
|||
g_object_set (setting,
|
||||
NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
|
||||
NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE,
|
||||
NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, reader->ignore_auto_dns,
|
||||
NM_SETTING_IP_CONFIG_DHCP_TIMEOUT, reader->dhcp_timeout,
|
||||
NULL);
|
||||
|
||||
setting = nm_setting_ip6_config_new ();
|
||||
|
|
@ -94,6 +103,8 @@ reader_create_connection (Reader *reader,
|
|||
NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
|
||||
NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE,
|
||||
NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, (int) NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64,
|
||||
NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, reader->ignore_auto_dns,
|
||||
NM_SETTING_IP_CONFIG_DHCP_TIMEOUT, reader->dhcp_timeout,
|
||||
NULL);
|
||||
|
||||
setting = nm_setting_connection_new ();
|
||||
|
|
@ -345,6 +356,14 @@ reader_parse_ip (Reader *reader, const char *sysfs_dir, char *argument)
|
|||
ifname = tmp;
|
||||
}
|
||||
|
||||
if (client_hostname && !nm_sd_hostname_is_valid (client_hostname, FALSE))
|
||||
client_hostname = NULL;
|
||||
|
||||
if (client_hostname) {
|
||||
g_free (reader->hostname);
|
||||
reader->hostname = g_strdup (client_hostname);
|
||||
}
|
||||
|
||||
/* <ifname>:{none|off|dhcp|on|any|dhcp6|auto6|ibft} */
|
||||
|
||||
kind = get_word (&argument, ':');
|
||||
|
|
@ -807,27 +826,6 @@ _normalize_conn (gpointer key, gpointer value, gpointer user_data)
|
|||
nm_connection_normalize (connection, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
reader_set_ignore_auto_dns (Reader *reader)
|
||||
{
|
||||
GHashTableIter iter;
|
||||
NMConnection *connection;
|
||||
NMSettingIPConfig *s_ip = NULL;
|
||||
|
||||
g_hash_table_iter_init (&iter, reader->hash);
|
||||
while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &connection)) {
|
||||
s_ip = nm_connection_get_setting_ip4_config (connection);
|
||||
g_object_set (s_ip,
|
||||
NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, TRUE,
|
||||
NULL);
|
||||
|
||||
s_ip = nm_connection_get_setting_ip6_config (connection);
|
||||
g_object_set (s_ip,
|
||||
NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, TRUE,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
reader_add_nameservers (Reader *reader, GPtrArray *nameservers)
|
||||
{
|
||||
|
|
@ -875,7 +873,7 @@ reader_add_nameservers (Reader *reader, GPtrArray *nameservers)
|
|||
}
|
||||
|
||||
GHashTable *
|
||||
nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv)
|
||||
nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv, char **hostname)
|
||||
{
|
||||
Reader *reader;
|
||||
const char *tag;
|
||||
|
|
@ -886,16 +884,27 @@ nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv)
|
|||
gboolean net_ifnames = TRUE;
|
||||
gs_unref_ptrarray GPtrArray *nameservers = NULL;
|
||||
gs_unref_ptrarray GPtrArray *routes = NULL;
|
||||
gboolean ignore_auto_dns = FALSE;
|
||||
int i;
|
||||
|
||||
reader = reader_new ();
|
||||
|
||||
for (i = 0; argv[i]; i++) {
|
||||
if (strcmp (argv[i], "net.ifnames=0") == 0)
|
||||
net_ifnames = FALSE;
|
||||
else if (g_str_has_prefix (argv[i], "net.ifnames="))
|
||||
net_ifnames = TRUE;
|
||||
gs_free char *argument_clone = NULL;
|
||||
char *argument;
|
||||
|
||||
argument_clone = g_strdup (argv[i]);
|
||||
argument = argument_clone;
|
||||
|
||||
tag = get_word (&argument, '=');
|
||||
|
||||
if (strcmp (tag, "net.ifnames") == 0)
|
||||
net_ifnames = strcmp (argument, "0") != 0;
|
||||
else if (strcmp (tag, "rd.peerdns") == 0)
|
||||
reader->ignore_auto_dns = !_nm_utils_ascii_str_to_bool (argument, TRUE);
|
||||
else if (strcmp (tag, "rd.net.timeout.dhcp") == 0) {
|
||||
reader->dhcp_timeout = _nm_utils_ascii_str_to_int64 (argument,
|
||||
10, 0, G_MAXINT32, 0);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; argv[i]; i++) {
|
||||
|
|
@ -933,9 +942,7 @@ nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv)
|
|||
}
|
||||
if (argument && *argument)
|
||||
_LOGW (LOGD_CORE, "Ignoring extra: '%s'.", argument);
|
||||
} else if (strcmp (tag, "rd.peerdns") == 0)
|
||||
ignore_auto_dns = !_nm_utils_ascii_str_to_bool (argument, TRUE);
|
||||
else if (strcmp (tag, "rd.iscsi.ibft") == 0 && _nm_utils_ascii_str_to_bool (argument, TRUE))
|
||||
} else if (strcmp (tag, "rd.iscsi.ibft") == 0 && _nm_utils_ascii_str_to_bool (argument, TRUE))
|
||||
reader_read_all_connections_from_fw (reader, sysfs_dir);
|
||||
else if (strcmp (tag, "rd.bootif") == 0)
|
||||
ignore_bootif = !_nm_utils_ascii_str_to_bool (argument, TRUE);
|
||||
|
|
@ -1009,9 +1016,9 @@ nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv)
|
|||
if (nameservers)
|
||||
reader_add_nameservers (reader, nameservers);
|
||||
|
||||
if (ignore_auto_dns)
|
||||
reader_set_ignore_auto_dns (reader);
|
||||
|
||||
g_hash_table_foreach (reader->hash, _normalize_conn, NULL);
|
||||
|
||||
NM_SET_OUT (hostname, g_steal_pointer (&reader->hostname));
|
||||
|
||||
return reader_destroy (reader, FALSE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,10 +30,12 @@ test_auto (void)
|
|||
NMSettingWired *s_wired;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
gs_free char *hostname = NULL;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
||||
g_assert_cmpstr (hostname, ==, NULL);
|
||||
|
||||
connection = g_hash_table_lookup (connections, "default_connection");
|
||||
g_assert (connection);
|
||||
|
|
@ -81,10 +83,12 @@ test_if_auto_with_mtu (void)
|
|||
NMSettingWired *s_wired;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
gs_free char *hostname = NULL;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
||||
g_assert_cmpstr (hostname, ==, NULL);
|
||||
|
||||
connection = g_hash_table_lookup (connections, "eth0");
|
||||
g_assert (connection);
|
||||
|
|
@ -115,10 +119,13 @@ test_if_dhcp6 (void)
|
|||
NMConnection *connection;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
gs_free char *hostname = NULL;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
||||
g_assert_cmpstr (hostname, ==, NULL);
|
||||
|
||||
connection = g_hash_table_lookup (connections, "eth1");
|
||||
g_assert (connection);
|
||||
nmtst_assert_connection_verifies_without_normalization (connection);
|
||||
|
|
@ -145,10 +152,12 @@ test_if_auto_with_mtu_and_mac (void)
|
|||
NMSettingWired *s_wired;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
gs_free char *hostname = NULL;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
||||
g_assert_cmpstr (hostname, ==, NULL);
|
||||
|
||||
connection = g_hash_table_lookup (connections, "eth2");
|
||||
g_assert (connection);
|
||||
|
|
@ -183,10 +192,12 @@ test_if_ip4_manual (void)
|
|||
NMConnection *connection;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMIPAddress *ip_addr;
|
||||
gs_free char *hostname = NULL;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||
g_assert_cmpstr (hostname, ==, "hostname1.example.com");
|
||||
|
||||
connection = g_hash_table_lookup (connections, "eth3");
|
||||
g_assert (connection);
|
||||
|
|
@ -237,10 +248,12 @@ test_if_ip6_manual (void)
|
|||
NMConnection *connection;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
NMIPAddress *ip_addr;
|
||||
gs_free char *hostname = NULL;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
||||
g_assert_cmpstr (hostname, ==, "hostname0.example.com");
|
||||
|
||||
connection = g_hash_table_lookup (connections, "eth4");
|
||||
g_assert (connection);
|
||||
|
|
@ -274,10 +287,12 @@ test_multiple_merge (void)
|
|||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
NMIPAddress *ip_addr;
|
||||
gs_free char *hostname = NULL;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
||||
g_assert_cmpstr (hostname, ==, NULL);
|
||||
|
||||
connection = g_hash_table_lookup (connections, "eth0");
|
||||
g_assert (connection);
|
||||
|
|
@ -317,10 +332,12 @@ test_multiple_bootdev (void)
|
|||
NMConnection *connection;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
gs_free char *hostname = NULL;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||
g_assert_cmpstr (hostname, ==, NULL);
|
||||
|
||||
connection = g_hash_table_lookup (connections, "eth3");
|
||||
g_assert (connection);
|
||||
|
|
@ -344,10 +361,12 @@ test_bootdev (void)
|
|||
const char *const*ARGV = NM_MAKE_STRV ("vlan=vlan2:ens5", "bootdev=ens3");
|
||||
NMConnection *connection;
|
||||
NMSettingConnection *s_con;
|
||||
gs_free char *hostname = NULL;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||
g_assert_cmpstr (hostname, ==, NULL);
|
||||
|
||||
connection = g_hash_table_lookup (connections, "ens3");
|
||||
g_assert (connection);
|
||||
|
|
@ -384,10 +403,12 @@ test_some_more (void)
|
|||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
NMIPRoute *ip_route;
|
||||
gs_free char *hostname = NULL;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||
g_assert_cmpstr (hostname, ==, NULL);
|
||||
|
||||
connection = g_hash_table_lookup (connections, "eth1");
|
||||
g_assert (connection);
|
||||
|
|
@ -466,10 +487,12 @@ test_bond (void)
|
|||
NMSettingBond *s_bond;
|
||||
NMIPRoute *ip_route;
|
||||
const char *master_uuid;
|
||||
gs_free char *hostname = NULL;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 3);
|
||||
g_assert_cmpstr (hostname, ==, NULL);
|
||||
|
||||
connection = g_hash_table_lookup (connections, "bong0");
|
||||
g_assert (connection);
|
||||
|
|
@ -545,10 +568,12 @@ test_bond_default (void)
|
|||
NMSettingIPConfig *s_ip6;
|
||||
NMSettingBond *s_bond;
|
||||
const char *master_uuid;
|
||||
gs_free char *hostname = NULL;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||
g_assert_cmpstr (hostname, ==, NULL);
|
||||
|
||||
connection = g_hash_table_lookup (connections, "bond0");
|
||||
|
||||
|
|
@ -598,7 +623,9 @@ static void
|
|||
test_bridge (void)
|
||||
{
|
||||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
const char *const*ARGV = NM_MAKE_STRV ("bridge=bridge0:eth0,eth1", "rd.route=192.0.2.53::bridge0");
|
||||
const char *const*ARGV = NM_MAKE_STRV ("bridge=bridge0:eth0,eth1",
|
||||
"rd.route=192.0.2.53::bridge0",
|
||||
"rd.net.timeout.dhcp=10");
|
||||
NMConnection *connection;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
|
|
@ -606,10 +633,12 @@ test_bridge (void)
|
|||
NMSettingBridge *s_bridge;
|
||||
NMIPRoute *ip_route;
|
||||
const char *master_uuid;
|
||||
gs_free char *hostname = NULL;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 3);
|
||||
g_assert_cmpstr (hostname, ==, NULL);
|
||||
|
||||
connection = g_hash_table_lookup (connections, "bridge0");
|
||||
g_assert (connection);
|
||||
|
|
@ -626,6 +655,7 @@ test_bridge (void)
|
|||
g_assert_cmpint (nm_setting_ip_config_get_num_dns (s_ip4), ==, 0);
|
||||
g_assert (!nm_setting_ip_config_get_gateway (s_ip4));
|
||||
g_assert_cmpint (nm_setting_ip_config_get_num_routes (s_ip4), ==, 1);
|
||||
g_assert_cmpint (nm_setting_ip_config_get_dhcp_timeout(s_ip4), ==, 10);
|
||||
ip_route = nm_setting_ip_config_get_route (s_ip4, 0);
|
||||
g_assert_cmpstr (nm_ip_route_get_dest (ip_route), ==, "192.0.2.53");
|
||||
g_assert_cmpint (nm_ip_route_get_family (ip_route), ==, AF_INET);
|
||||
|
|
@ -640,6 +670,8 @@ test_bridge (void)
|
|||
g_assert_cmpint (nm_setting_ip_config_get_num_dns (s_ip6), ==, 0);
|
||||
g_assert (!nm_setting_ip_config_get_gateway (s_ip6));
|
||||
g_assert_cmpint (nm_setting_ip_config_get_num_routes (s_ip6), ==, 0);
|
||||
g_assert_cmpint (nm_setting_ip_config_get_dhcp_timeout(s_ip6), ==, 10);
|
||||
|
||||
|
||||
s_bridge = nm_connection_get_setting_bridge (connection);
|
||||
g_assert (s_bridge);
|
||||
|
|
@ -682,10 +714,12 @@ test_bridge_default (void)
|
|||
NMSettingIPConfig *s_ip6;
|
||||
NMSettingBridge *s_bridge;
|
||||
const char *master_uuid;
|
||||
gs_free char *hostname = NULL;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||
g_assert_cmpstr (hostname, ==, NULL);
|
||||
|
||||
connection = g_hash_table_lookup (connections, "br0");
|
||||
|
||||
|
|
@ -740,10 +774,12 @@ test_team (void)
|
|||
NMSettingIPConfig *s_ip6;
|
||||
NMSettingTeam *s_team;
|
||||
const char *master_uuid;
|
||||
gs_free char *hostname = NULL;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 3);
|
||||
g_assert_cmpstr (hostname, ==, NULL);
|
||||
|
||||
connection = g_hash_table_lookup (connections, "team0");
|
||||
g_assert (connection);
|
||||
|
|
@ -806,10 +842,12 @@ test_ibft_ip_dev (void)
|
|||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
NMSettingConnection *s_con;
|
||||
NMConnection *connection;
|
||||
gs_free char *hostname = NULL;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
||||
g_assert_cmpstr (hostname, ==, NULL);
|
||||
|
||||
connection = g_hash_table_lookup (connections, "eth0");
|
||||
g_assert (connection);
|
||||
|
|
@ -825,10 +863,12 @@ _test_ibft_ip (const char *const*ARGV)
|
|||
{
|
||||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
NMConnection *connection;
|
||||
gs_free char *hostname = NULL;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||
g_assert_cmpstr (hostname, ==, NULL);
|
||||
|
||||
connection = g_hash_table_lookup (connections, "ibft0");
|
||||
g_assert (connection);
|
||||
|
|
@ -864,10 +904,12 @@ test_ignore_extra (void)
|
|||
{
|
||||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
const char *const*ARGV = NM_MAKE_STRV ("blabla", "extra", "lalala");
|
||||
gs_free char *hostname = NULL;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 0);
|
||||
g_assert_cmpstr (hostname, ==, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -886,10 +928,12 @@ test_rd_znet (void)
|
|||
{ .name = "portno", .value_str = "1" },
|
||||
};
|
||||
int i_s390_options_keys;
|
||||
gs_free char *hostname = NULL;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||
g_assert_cmpstr (hostname, ==, "foo.example.com");
|
||||
|
||||
connection = g_hash_table_lookup (connections, "enc800");
|
||||
g_assert (NM_IS_CONNECTION (connection));
|
||||
|
|
@ -963,10 +1007,12 @@ test_rd_znet_legacy (void)
|
|||
"net.ifnames=0");
|
||||
NMConnection *connection;
|
||||
NMSettingConnection *s_con;
|
||||
gs_free char *hostname = NULL;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||
g_assert_cmpstr (hostname, ==, "foo.example.com");
|
||||
|
||||
connection = g_hash_table_lookup (connections, "eth0");
|
||||
g_assert (NM_IS_CONNECTION (connection));
|
||||
|
|
@ -1001,10 +1047,12 @@ test_bootif (void)
|
|||
NMSettingWired *s_wired;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
gs_free char *hostname = NULL;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
||||
g_assert_cmpstr (hostname, ==, NULL);
|
||||
|
||||
connection = g_hash_table_lookup (connections, "default_connection");
|
||||
g_assert (connection);
|
||||
|
|
@ -1037,10 +1085,12 @@ test_bootif_hwtype (void)
|
|||
NMSettingWired *s_wired;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
gs_free char *hostname = NULL;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||
g_assert_cmpstr (hostname, ==, NULL);
|
||||
|
||||
connection = g_hash_table_lookup (connections, "eth0");
|
||||
g_assert (connection);
|
||||
|
|
@ -1100,10 +1150,12 @@ test_nameserver (void)
|
|||
"nameserver=[2606:4700:4700::1111]");
|
||||
NMConnection *connection;
|
||||
NMSettingIPConfig *s_ip;
|
||||
gs_free char *hostname = NULL;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 3);
|
||||
g_assert_cmpstr (hostname, ==, "foo.example.com");
|
||||
|
||||
connection = g_hash_table_lookup (connections, "eth0");
|
||||
g_assert (connection);
|
||||
|
|
@ -1140,10 +1192,12 @@ test_bootif_off (void)
|
|||
{
|
||||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
const char *const*ARGV = NM_MAKE_STRV ("BOOTIF=01-00-53-AB-cd-02-03", "rd.bootif=0");
|
||||
gs_free char *hostname = NULL;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 0);
|
||||
g_assert_cmpstr (hostname, ==, NULL);
|
||||
}
|
||||
|
||||
NMTST_DEFINE ();
|
||||
|
|
|
|||
|
|
@ -101,6 +101,8 @@ receive_ra (struct ndp *ndp, struct ndp_msg *msg, gpointer user_data)
|
|||
int offset;
|
||||
int hop_limit;
|
||||
guint32 val;
|
||||
guint32 clamp_pltime;
|
||||
guint32 clamp_vltime;
|
||||
|
||||
/* Router discovery is subject to the following RFC documents:
|
||||
*
|
||||
|
|
@ -165,7 +167,22 @@ receive_ra (struct ndp *ndp, struct ndp_msg *msg, gpointer user_data)
|
|||
changed |= NM_NDISC_CONFIG_GATEWAYS;
|
||||
}
|
||||
|
||||
/* Addresses & Routes */
|
||||
/* Addresses & Routes
|
||||
*
|
||||
* The Preferred Lifetime and Valid Lifetime of PIOs are capped to Router Lifetime
|
||||
* and NM_NDISC_VLTIME_MULT * Preferred Lifetime, respectively.
|
||||
*
|
||||
* The Lifetime of RIOs is capped to the Router Lifetime (there is no point in
|
||||
* maintaining a route if it employs a dead router).
|
||||
*
|
||||
* See draft-gont-6man-slaac-renum
|
||||
*/
|
||||
#define NM_NDISC_VLTIME_MULT ((guint32) 48)
|
||||
clamp_pltime = ndp_msgra_router_lifetime (msgra);
|
||||
|
||||
/* clamp_pltime has at most 16 bit set, and multiplication cannot overflow. */
|
||||
clamp_vltime = clamp_pltime * NM_NDISC_VLTIME_MULT;
|
||||
|
||||
ndp_msg_opt_for_each_offset (offset, msg, NDP_MSG_OPT_PREFIX) {
|
||||
guint8 r_plen;
|
||||
struct in6_addr r_network;
|
||||
|
|
@ -186,7 +203,7 @@ receive_ra (struct ndp *ndp, struct ndp_msg *msg, gpointer user_data)
|
|||
.network = r_network,
|
||||
.plen = r_plen,
|
||||
.timestamp = now,
|
||||
.lifetime = ndp_msg_opt_prefix_valid_time (msg, offset),
|
||||
.lifetime = NM_MIN (ndp_msg_opt_prefix_valid_time (msg, offset), clamp_vltime),
|
||||
};
|
||||
|
||||
if (nm_ndisc_add_route (ndisc, &route))
|
||||
|
|
@ -199,8 +216,8 @@ receive_ra (struct ndp *ndp, struct ndp_msg *msg, gpointer user_data)
|
|||
NMNDiscAddress address = {
|
||||
.address = r_network,
|
||||
.timestamp = now,
|
||||
.lifetime = ndp_msg_opt_prefix_valid_time (msg, offset),
|
||||
.preferred = ndp_msg_opt_prefix_preferred_time (msg, offset),
|
||||
.lifetime = NM_MIN (ndp_msg_opt_prefix_valid_time (msg, offset), clamp_vltime),
|
||||
.preferred = NM_MIN (ndp_msg_opt_prefix_preferred_time (msg, offset), clamp_pltime),
|
||||
};
|
||||
|
||||
if (address.preferred <= address.lifetime) {
|
||||
|
|
@ -214,7 +231,7 @@ receive_ra (struct ndp *ndp, struct ndp_msg *msg, gpointer user_data)
|
|||
.gateway = gateway_addr,
|
||||
.plen = ndp_msg_opt_route_prefix_len (msg, offset),
|
||||
.timestamp = now,
|
||||
.lifetime = ndp_msg_opt_route_lifetime (msg, offset),
|
||||
.lifetime = NM_MIN (ndp_msg_opt_route_lifetime (msg, offset), clamp_pltime),
|
||||
.preference = _route_preference_coerce (ndp_msg_opt_route_preference (msg, offset)),
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -442,8 +442,15 @@ nm_ndisc_add_address (NMNDisc *ndisc,
|
|||
}
|
||||
|
||||
if (existing) {
|
||||
/* A Valid Lifetime of 0 eliminates the corresponding address(es). This deviates
|
||||
* from RFC4862 Section 5.5.3, item e), as recommended in IETF draft draft-gont-6man-slaac-renum.
|
||||
*/
|
||||
if (new->lifetime == 0) {
|
||||
g_array_remove_index (rdata->addresses, i);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (from_ra) {
|
||||
const gint32 NM_NDISC_PREFIX_LFT_MIN = 7200; /* seconds, RFC4862 5.5.3.e */
|
||||
gint64 old_expiry_lifetime, old_expiry_preferred;
|
||||
|
||||
old_expiry_lifetime = get_expiry (existing);
|
||||
|
|
@ -452,25 +459,16 @@ nm_ndisc_add_address (NMNDisc *ndisc,
|
|||
if (new->lifetime == NM_NDISC_INFINITY)
|
||||
existing->lifetime = NM_NDISC_INFINITY;
|
||||
else {
|
||||
gint64 new_lifetime, remaining_lifetime;
|
||||
gint64 new_lifetime;
|
||||
|
||||
/* see RFC4862 5.5.3.e */
|
||||
if (existing->lifetime == NM_NDISC_INFINITY)
|
||||
remaining_lifetime = G_MAXINT64;
|
||||
else
|
||||
remaining_lifetime = ((gint64) existing->timestamp) + ((gint64) existing->lifetime) - ((gint64) now_s);
|
||||
/* Honor small valid lifetimes, as discussed in
|
||||
* draft-gont-6man-slaac-renum, to allow for more timelier
|
||||
* reaction to renumbering events. This deviates from
|
||||
* RFC4862 Section 5.5.3, item e).
|
||||
*/
|
||||
new_lifetime = ((gint64) new->timestamp) + ((gint64) new->lifetime) - ((gint64) now_s);
|
||||
|
||||
if ( new_lifetime > (gint64) NM_NDISC_PREFIX_LFT_MIN
|
||||
|| new_lifetime > remaining_lifetime) {
|
||||
existing->timestamp = now_s;
|
||||
existing->lifetime = CLAMP (new_lifetime, (gint64) 0, (gint64) (G_MAXUINT32 - 1));
|
||||
} else if (remaining_lifetime <= (gint64) NM_NDISC_PREFIX_LFT_MIN) {
|
||||
/* keep the current lifetime. */
|
||||
} else {
|
||||
existing->timestamp = now_s;
|
||||
existing->lifetime = NM_NDISC_PREFIX_LFT_MIN;
|
||||
}
|
||||
existing->timestamp = now_s;
|
||||
existing->lifetime = CLAMP (new_lifetime, (gint64) 0, (gint64) (G_MAXUINT32 - 1));
|
||||
}
|
||||
|
||||
if (new->preferred == NM_NDISC_INFINITY) {
|
||||
|
|
@ -487,11 +485,6 @@ nm_ndisc_add_address (NMNDisc *ndisc,
|
|||
|| old_expiry_preferred != get_expiry_preferred (existing);
|
||||
}
|
||||
|
||||
if (new->lifetime == 0) {
|
||||
g_array_remove_index (rdata->addresses, i);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ( get_expiry (existing) == get_expiry (new)
|
||||
&& get_expiry_preferred (existing) == get_expiry_preferred (new))
|
||||
return FALSE;
|
||||
|
|
|
|||
|
|
@ -217,9 +217,8 @@ test_everything_changed (NMNDisc *ndisc, const NMNDiscData *rdata, guint changed
|
|||
|
||||
g_assert_cmpint (rdata->gateways_n, ==, 1);
|
||||
match_gateway (rdata, 0, "fe80::2", data->timestamp1, 10, NM_ICMPV6_ROUTER_PREF_MEDIUM);
|
||||
g_assert_cmpint (rdata->addresses_n, ==, 2);
|
||||
match_address (rdata, 0, "2001:db8:a:a::1", data->timestamp1, 10, 0);
|
||||
match_address (rdata, 1, "2001:db8:a:b::1", data->timestamp1, 10, 10);
|
||||
g_assert_cmpint (rdata->addresses_n, ==, 1);
|
||||
match_address (rdata, 0, "2001:db8:a:b::1", data->timestamp1, 10, 10);
|
||||
g_assert_cmpint (rdata->routes_n, ==, 1);
|
||||
match_route (rdata, 0, "2001:db8:a:b::", 64, "fe80::2", data->timestamp1, 10, 10);
|
||||
g_assert_cmpint (rdata->dns_servers_n, ==, 1);
|
||||
|
|
|
|||
|
|
@ -37,11 +37,14 @@ static guint signals[LAST_SIGNAL] = {0};
|
|||
typedef struct {
|
||||
CList calls_lst_head;
|
||||
GDBusConnection *dbus_connection;
|
||||
GCancellable *shutdown_cancellable;
|
||||
GCancellable *main_cancellable;
|
||||
char *name_owner;
|
||||
guint64 call_numid_counter;
|
||||
guint changed_signal_id;
|
||||
guint changed_id;
|
||||
guint name_owner_changed_id;
|
||||
bool disposing:1;
|
||||
bool shutting_down:1;
|
||||
bool got_name_owner:1;
|
||||
NMAuthPolkitMode auth_polkit_mode:3;
|
||||
} NMAuthManagerPrivate;
|
||||
|
||||
|
|
@ -105,6 +108,12 @@ nm_auth_manager_get_polkit_enabled (NMAuthManager *self)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
_emit_changed_signal (NMAuthManager *self)
|
||||
{
|
||||
g_signal_emit (self, signals[CHANGED_SIGNAL], 0);
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE = 0,
|
||||
POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION = (1<<0),
|
||||
|
|
@ -204,17 +213,18 @@ _call_check_authorize_cb (GObject *proxy,
|
|||
priv = NM_AUTH_MANAGER_GET_PRIVATE (self);
|
||||
|
||||
value = g_dbus_connection_call_finish (G_DBUS_CONNECTION (proxy), res, &error);
|
||||
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
|
||||
|
||||
if (nm_utils_error_is_cancelled (error)) {
|
||||
/* call_id was cancelled externally, but _call_id_free() kept call_id
|
||||
* alive (and it has still the reference on @self. */
|
||||
|
||||
if (!priv->shutdown_cancellable) {
|
||||
if (!priv->main_cancellable) {
|
||||
/* we do a forced shutdown. There is no more time for cancelling... */
|
||||
_call_id_free (call_id);
|
||||
|
||||
/* this shouldn't really happen, because:
|
||||
* _call_check_authorize() only scheduled the D-Bus request at a time when
|
||||
* shutdown_cancellable was still set. It means, somebody called force-shutdown
|
||||
* nm_auth_manager_check_authorization() only scheduled the D-Bus request at a time when
|
||||
* main_cancellable was still set. It means, somebody called force-shutdown
|
||||
* after call-id was schedule.
|
||||
* force-shutdown should only be called after:
|
||||
* - cancel all pending requests
|
||||
|
|
@ -233,7 +243,7 @@ _call_check_authorize_cb (GObject *proxy,
|
|||
G_VARIANT_TYPE ("()"),
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
CANCELLATION_TIMEOUT_MS,
|
||||
priv->shutdown_cancellable,
|
||||
priv->main_cancellable,
|
||||
cancel_check_authorization_cb,
|
||||
call_id);
|
||||
return;
|
||||
|
|
@ -357,7 +367,7 @@ nm_auth_manager_check_authorization (NMAuthManager *self,
|
|||
|
||||
call_id->dbus_cancellable = g_cancellable_new ();
|
||||
|
||||
nm_assert (priv->shutdown_cancellable);
|
||||
nm_assert (priv->main_cancellable);
|
||||
|
||||
g_dbus_connection_call (priv->dbus_connection,
|
||||
POLKIT_SERVICE,
|
||||
|
|
@ -411,9 +421,95 @@ changed_signal_cb (GDBusConnection *connection,
|
|||
gpointer user_data)
|
||||
{
|
||||
NMAuthManager *self = user_data;
|
||||
NMAuthManagerPrivate *priv = NM_AUTH_MANAGER_GET_PRIVATE (self);
|
||||
gboolean valid_sender;
|
||||
|
||||
_LOGD ("dbus signal: \"Changed\"");
|
||||
g_signal_emit (self, signals[CHANGED_SIGNAL], 0);
|
||||
nm_assert (nm_streq0 (signal_name, "Changed"));
|
||||
|
||||
valid_sender = nm_streq0 (priv->name_owner, sender_name);
|
||||
|
||||
_LOGD ("dbus-signal: \"Changed\" notification%s", valid_sender ? "" : " (ignore)");
|
||||
|
||||
if (valid_sender)
|
||||
_emit_changed_signal (self);
|
||||
}
|
||||
|
||||
static void
|
||||
_name_owner_changed (NMAuthManager *self,
|
||||
const char *name_owner,
|
||||
gboolean is_initial)
|
||||
{
|
||||
NMAuthManagerPrivate *priv = NM_AUTH_MANAGER_GET_PRIVATE (self);
|
||||
gboolean is_changed;
|
||||
gs_free char *old_name_owner = NULL;
|
||||
|
||||
if (is_initial)
|
||||
priv->got_name_owner = TRUE;
|
||||
else {
|
||||
if (!priv->got_name_owner)
|
||||
return;
|
||||
}
|
||||
|
||||
name_owner = nm_str_not_empty (name_owner);
|
||||
|
||||
is_changed = !nm_streq0 (priv->name_owner, name_owner);
|
||||
if (is_changed) {
|
||||
old_name_owner = g_steal_pointer (&priv->name_owner);
|
||||
priv->name_owner = g_strdup (name_owner);
|
||||
} else {
|
||||
if (!is_initial)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!priv->name_owner) {
|
||||
if (is_initial)
|
||||
_LOGT ("name-owner: polkit not running");
|
||||
else
|
||||
_LOGT ("name-owner: polkit stopped (was %s)", old_name_owner);
|
||||
} else {
|
||||
if (is_initial)
|
||||
_LOGT ("name-owner: polkit is running (now %s)", priv->name_owner);
|
||||
else if (old_name_owner)
|
||||
_LOGT ("name-owner: polkit restarted (now %s, was %s)", priv->name_owner, old_name_owner);
|
||||
else
|
||||
_LOGT ("name-owner: polkit started (now %s)", priv->name_owner);
|
||||
}
|
||||
|
||||
if (priv->name_owner)
|
||||
_emit_changed_signal (self);
|
||||
}
|
||||
|
||||
static void
|
||||
_name_owner_changed_cb (GDBusConnection *connection,
|
||||
const char *sender_name,
|
||||
const char *object_path,
|
||||
const char *interface_name,
|
||||
const char *signal_name,
|
||||
GVariant *parameters,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMAuthManager *self = user_data;
|
||||
const char *new_owner;
|
||||
|
||||
if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(sss)")))
|
||||
return;
|
||||
|
||||
g_variant_get (parameters,
|
||||
"(&s&s&s)",
|
||||
NULL,
|
||||
NULL,
|
||||
&new_owner);
|
||||
|
||||
_name_owner_changed (self, new_owner, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
_name_owner_get_cb (const char *name_owner,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (!nm_utils_error_is_cancelled (error))
|
||||
_name_owner_changed (user_data, name_owner, TRUE);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -435,14 +531,17 @@ nm_auth_manager_force_shutdown (NMAuthManager *self)
|
|||
|
||||
priv = NM_AUTH_MANAGER_GET_PRIVATE (self);
|
||||
|
||||
/* FIXME(shutdown): ensure we properly call this API during shutdown as
|
||||
* described next. */
|
||||
|
||||
/* while we have pending requests (NMAuthManagerCallId), the instance
|
||||
* is kept alive.
|
||||
*
|
||||
* Even if the caller cancells all pending call-ids, we still need to keep
|
||||
* Even if the caller cancels all pending call-ids, we still need to keep
|
||||
* a reference to self, in order to handle pending CancelCheckAuthorization
|
||||
* requests.
|
||||
*
|
||||
* To do a corrdinated shutdown, do the following:
|
||||
* To do a coordinated shutdown, do the following:
|
||||
* - cancel all pending NMAuthManagerCallId requests.
|
||||
* - ensure everybody unrefs the NMAuthManager instance. If by that, the instance
|
||||
* gets destroyed, the shutdown already completed successfully.
|
||||
|
|
@ -457,7 +556,7 @@ nm_auth_manager_force_shutdown (NMAuthManager *self)
|
|||
*/
|
||||
|
||||
priv->shutting_down = TRUE;
|
||||
nm_clear_g_cancellable (&priv->shutdown_cancellable);
|
||||
nm_clear_g_cancellable (&priv->main_cancellable);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -523,18 +622,31 @@ constructed (GObject *object)
|
|||
goto out;
|
||||
}
|
||||
|
||||
priv->shutdown_cancellable = g_cancellable_new ();
|
||||
priv->main_cancellable = g_cancellable_new ();
|
||||
|
||||
priv->changed_signal_id = g_dbus_connection_signal_subscribe (priv->dbus_connection,
|
||||
POLKIT_SERVICE,
|
||||
POLKIT_INTERFACE,
|
||||
"Changed",
|
||||
POLKIT_OBJECT_PATH,
|
||||
NULL,
|
||||
G_DBUS_SIGNAL_FLAGS_NONE,
|
||||
changed_signal_cb,
|
||||
self,
|
||||
NULL);
|
||||
priv->name_owner_changed_id = nm_dbus_connection_signal_subscribe_name_owner_changed (priv->dbus_connection,
|
||||
POLKIT_SERVICE,
|
||||
_name_owner_changed_cb,
|
||||
self,
|
||||
NULL);
|
||||
|
||||
priv->changed_id = g_dbus_connection_signal_subscribe (priv->dbus_connection,
|
||||
POLKIT_SERVICE,
|
||||
POLKIT_INTERFACE,
|
||||
"Changed",
|
||||
POLKIT_OBJECT_PATH,
|
||||
NULL,
|
||||
G_DBUS_SIGNAL_FLAGS_NONE,
|
||||
changed_signal_cb,
|
||||
self,
|
||||
NULL);
|
||||
|
||||
nm_dbus_connection_call_get_name_owner (priv->dbus_connection,
|
||||
POLKIT_SERVICE,
|
||||
-1,
|
||||
priv->main_cancellable,
|
||||
_name_owner_get_cb,
|
||||
self);
|
||||
|
||||
create_message = "polkit enabled";
|
||||
|
||||
|
|
@ -578,14 +690,19 @@ dispose (GObject *object)
|
|||
|
||||
priv->disposing = TRUE;
|
||||
|
||||
nm_clear_g_cancellable (&priv->shutdown_cancellable);
|
||||
nm_clear_g_cancellable (&priv->main_cancellable);
|
||||
|
||||
nm_clear_g_dbus_connection_signal (priv->dbus_connection,
|
||||
&priv->changed_signal_id);
|
||||
&priv->name_owner_changed_id);
|
||||
|
||||
nm_clear_g_dbus_connection_signal (priv->dbus_connection,
|
||||
&priv->changed_id);
|
||||
|
||||
G_OBJECT_CLASS (nm_auth_manager_parent_class)->dispose (object);
|
||||
|
||||
g_clear_object (&priv->dbus_connection);
|
||||
|
||||
nm_clear_g_free (&priv->name_owner);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include "devices/nm-device.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-keyfile/nm-keyfile-internal.h"
|
||||
#include "nm-keyfile/nm-keyfile-utils.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
@ -116,14 +117,6 @@ G_DEFINE_TYPE (NMConfigData, nm_config_data, G_TYPE_OBJECT)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _HAS_PREFIX(str, prefix) \
|
||||
({ \
|
||||
const char *_str = (str); \
|
||||
g_str_has_prefix ( _str, ""prefix"") && _str[NM_STRLEN(prefix)] != '\0'; \
|
||||
})
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
const char *
|
||||
nm_config_data_get_config_main_file (const NMConfigData *self)
|
||||
{
|
||||
|
|
@ -215,6 +208,7 @@ nm_config_data_get_value_int64 (const NMConfigData *self, const char *group, con
|
|||
char **
|
||||
nm_config_data_get_plugins (const NMConfigData *self, gboolean allow_default)
|
||||
{
|
||||
gs_free_error GError *error = NULL;
|
||||
const NMConfigDataPrivate *priv;
|
||||
char **list;
|
||||
|
||||
|
|
@ -222,8 +216,9 @@ nm_config_data_get_plugins (const NMConfigData *self, gboolean allow_default)
|
|||
|
||||
priv = NM_CONFIG_DATA_GET_PRIVATE (self);
|
||||
|
||||
list = g_key_file_get_string_list (priv->keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "plugins", NULL, NULL);
|
||||
if (!list && allow_default) {
|
||||
list = g_key_file_get_string_list (priv->keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "plugins", NULL, &error);
|
||||
if ( nm_keyfile_error_is_not_found (error)
|
||||
&& allow_default) {
|
||||
gs_unref_keyfile GKeyFile *kf = nm_config_create_keyfile ();
|
||||
|
||||
/* let keyfile split the default string according to its own escaping rules. */
|
||||
|
|
@ -550,14 +545,14 @@ _merge_keyfiles (GKeyFile *keyfile_user, GKeyFile *keyfile_intern)
|
|||
continue;
|
||||
|
||||
if ( !is_intern && !is_atomic
|
||||
&& _HAS_PREFIX (key, NM_CONFIG_KEYFILE_KEYPREFIX_WAS)) {
|
||||
&& NM_STR_HAS_PREFIX_WITH_MORE (key, NM_CONFIG_KEYFILE_KEYPREFIX_WAS)) {
|
||||
const char *key_base = &key[NM_STRLEN (NM_CONFIG_KEYFILE_KEYPREFIX_WAS)];
|
||||
|
||||
if (!g_key_file_has_key (keyfile_intern, group, key_base, NULL))
|
||||
g_key_file_remove_key (keyfile, group, key_base, NULL);
|
||||
continue;
|
||||
}
|
||||
if (!is_intern && !is_atomic && _HAS_PREFIX (key, NM_CONFIG_KEYFILE_KEYPREFIX_SET))
|
||||
if (!is_intern && !is_atomic && NM_STR_HAS_PREFIX_WITH_MORE (key, NM_CONFIG_KEYFILE_KEYPREFIX_SET))
|
||||
continue;
|
||||
|
||||
value = g_key_file_get_value (keyfile_intern, group, key, NULL);
|
||||
|
|
|
|||
149
src/nm-config.c
149
src/nm-config.c
|
|
@ -15,6 +15,7 @@
|
|||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-keyfile/nm-keyfile-internal.h"
|
||||
#include "nm-keyfile/nm-keyfile-utils.h"
|
||||
|
||||
#define DEFAULT_CONFIG_MAIN_FILE NMCONFDIR "/NetworkManager.conf"
|
||||
#define DEFAULT_CONFIG_DIR NMCONFDIR "/conf.d"
|
||||
|
|
@ -144,14 +145,6 @@ static void _set_config_data (NMConfig *self, NMConfigData *new_data, NMConfigCh
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _HAS_PREFIX(str, prefix) \
|
||||
({ \
|
||||
const char *_str = (str); \
|
||||
g_str_has_prefix ( _str, ""prefix"") && _str[NM_STRLEN(prefix)] != '\0'; \
|
||||
})
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
int
|
||||
nm_config_parse_boolean (const char *str,
|
||||
int default_value)
|
||||
|
|
@ -548,7 +541,7 @@ string_to_configure_and_quit (const char *value, GError **error)
|
|||
if (value == NULL)
|
||||
return NM_CONFIG_CONFIGURE_AND_QUIT_DISABLED;
|
||||
|
||||
if (strcmp (value, "initrd") == 0)
|
||||
if (nm_streq (value, "initrd"))
|
||||
return NM_CONFIG_CONFIGURE_AND_QUIT_INITRD;
|
||||
|
||||
ret = nm_config_parse_boolean (value, NM_CONFIG_CONFIGURE_AND_QUIT_INVALID);
|
||||
|
|
@ -664,15 +657,13 @@ ignore_config_snippet (GKeyFile *keyfile, gboolean is_base_config)
|
|||
static int
|
||||
_sort_groups_cmp (const char **pa, const char **pb, gpointer dummy)
|
||||
{
|
||||
const char *a, *b;
|
||||
const char *a = *pa;
|
||||
const char *b = *pb;
|
||||
gboolean a_is_connection, b_is_connection;
|
||||
gboolean a_is_device, b_is_device;
|
||||
|
||||
a = *pa;
|
||||
b = *pb;
|
||||
|
||||
a_is_connection = g_str_has_prefix (a, NM_CONFIG_KEYFILE_GROUPPREFIX_CONNECTION);
|
||||
b_is_connection = g_str_has_prefix (b, NM_CONFIG_KEYFILE_GROUPPREFIX_CONNECTION);
|
||||
a_is_connection = NM_STR_HAS_PREFIX (a, NM_CONFIG_KEYFILE_GROUPPREFIX_CONNECTION);
|
||||
b_is_connection = NM_STR_HAS_PREFIX (b, NM_CONFIG_KEYFILE_GROUPPREFIX_CONNECTION);
|
||||
|
||||
if (a_is_connection != b_is_connection) {
|
||||
/* one is a [connection*] entry, the other not. We sort [connection*] entries
|
||||
|
|
@ -689,8 +680,8 @@ _sort_groups_cmp (const char **pa, const char **pb, gpointer dummy)
|
|||
return pa > pb ? -1 : 1;
|
||||
}
|
||||
|
||||
a_is_device = g_str_has_prefix (a, NM_CONFIG_KEYFILE_GROUPPREFIX_DEVICE);
|
||||
b_is_device = g_str_has_prefix (b, NM_CONFIG_KEYFILE_GROUPPREFIX_DEVICE);
|
||||
a_is_device = NM_STR_HAS_PREFIX (a, NM_CONFIG_KEYFILE_GROUPPREFIX_DEVICE);
|
||||
b_is_device = NM_STR_HAS_PREFIX (b, NM_CONFIG_KEYFILE_GROUPPREFIX_DEVICE);
|
||||
|
||||
if (a_is_device != b_is_device) {
|
||||
/* one is a [device*] entry, the other not. We sort [device*] entries
|
||||
|
|
@ -726,13 +717,13 @@ _nm_config_sort_groups (char **groups, gsize ngroups)
|
|||
static gboolean
|
||||
_setting_is_device_spec (const char *group, const char *key)
|
||||
{
|
||||
#define _IS(group_v, key_v) (strcmp (group, (""group_v)) == 0 && strcmp (key, (""key_v)) == 0)
|
||||
#define _IS(group_v, key_v) (nm_streq (group, ""group_v"") && nm_streq (key, ""key_v""))
|
||||
return _IS (NM_CONFIG_KEYFILE_GROUP_MAIN, NM_CONFIG_KEYFILE_KEY_MAIN_NO_AUTO_DEFAULT)
|
||||
|| _IS (NM_CONFIG_KEYFILE_GROUP_MAIN, NM_CONFIG_KEYFILE_KEY_MAIN_IGNORE_CARRIER)
|
||||
|| _IS (NM_CONFIG_KEYFILE_GROUP_MAIN, NM_CONFIG_KEYFILE_KEY_MAIN_ASSUME_IPV6LL_ONLY)
|
||||
|| _IS (NM_CONFIG_KEYFILE_GROUP_KEYFILE, NM_CONFIG_KEYFILE_KEY_KEYFILE_UNMANAGED_DEVICES)
|
||||
|| (g_str_has_prefix (group, NM_CONFIG_KEYFILE_GROUPPREFIX_CONNECTION) && !strcmp (key, NM_CONFIG_KEYFILE_KEY_MATCH_DEVICE))
|
||||
|| (g_str_has_prefix (group, NM_CONFIG_KEYFILE_GROUPPREFIX_DEVICE ) && !strcmp (key, NM_CONFIG_KEYFILE_KEY_MATCH_DEVICE));
|
||||
|| (NM_STR_HAS_PREFIX (group, NM_CONFIG_KEYFILE_GROUPPREFIX_CONNECTION) && nm_streq (key, NM_CONFIG_KEYFILE_KEY_MATCH_DEVICE))
|
||||
|| (NM_STR_HAS_PREFIX (group, NM_CONFIG_KEYFILE_GROUPPREFIX_DEVICE ) && nm_streq (key, NM_CONFIG_KEYFILE_KEY_MATCH_DEVICE));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -741,7 +732,7 @@ _setting_is_string_list (const char *group, const char *key)
|
|||
return _IS (NM_CONFIG_KEYFILE_GROUP_MAIN, NM_CONFIG_KEYFILE_KEY_MAIN_PLUGINS)
|
||||
|| _IS (NM_CONFIG_KEYFILE_GROUP_MAIN, NM_CONFIG_KEYFILE_KEY_MAIN_DEBUG)
|
||||
|| _IS (NM_CONFIG_KEYFILE_GROUP_LOGGING, NM_CONFIG_KEYFILE_KEY_LOGGING_DOMAINS)
|
||||
|| g_str_has_prefix (group, NM_CONFIG_KEYFILE_GROUPPREFIX_TEST_APPEND_STRINGLIST);
|
||||
|| NM_STR_HAS_PREFIX (group, NM_CONFIG_KEYFILE_GROUPPREFIX_TEST_APPEND_STRINGLIST);
|
||||
#undef _IS
|
||||
}
|
||||
|
||||
|
|
@ -902,15 +893,20 @@ check_config_key (const char *group, const char *key)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
read_config (GKeyFile *keyfile, gboolean is_base_config,
|
||||
const char *dirname, const char *path,
|
||||
GPtrArray *warnings, GError **error)
|
||||
read_config (GKeyFile *keyfile,
|
||||
gboolean is_base_config,
|
||||
const char *dirname,
|
||||
const char *path,
|
||||
GPtrArray *warnings,
|
||||
GError **error)
|
||||
{
|
||||
GKeyFile *kf;
|
||||
char **groups, **keys;
|
||||
gsize ngroups, nkeys;
|
||||
int g, k;
|
||||
gs_unref_keyfile GKeyFile *kf = NULL;
|
||||
gs_strfreev char **groups = NULL;
|
||||
gs_free char *path_free = NULL;
|
||||
gsize ngroups;
|
||||
gsize nkeys;
|
||||
int g;
|
||||
int k;
|
||||
|
||||
g_return_val_if_fail (keyfile, FALSE);
|
||||
g_return_val_if_fail (path, FALSE);
|
||||
|
|
@ -931,14 +927,11 @@ read_config (GKeyFile *keyfile, gboolean is_base_config,
|
|||
kf = nm_config_create_keyfile ();
|
||||
if (!g_key_file_load_from_file (kf, path, G_KEY_FILE_NONE, error)) {
|
||||
g_prefix_error (error, "%s: ", path);
|
||||
g_key_file_free (kf);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (ignore_config_snippet (kf, is_base_config)) {
|
||||
g_key_file_free (kf);
|
||||
if (ignore_config_snippet (kf, is_base_config))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* the config-group is internal to every configuration snippets. It doesn't make sense
|
||||
* to merge it into the global configuration, and it doesn't make sense to preserve the
|
||||
|
|
@ -962,8 +955,9 @@ read_config (GKeyFile *keyfile, gboolean is_base_config,
|
|||
|
||||
for (g = 0; groups && groups[g]; g++) {
|
||||
const char *group = groups[g];
|
||||
gs_strfreev char **keys = NULL;
|
||||
|
||||
if (g_str_has_prefix (group, NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN)) {
|
||||
if (NM_STR_HAS_PREFIX (group, NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN)) {
|
||||
/* internal groups cannot be set by user configuration. */
|
||||
continue;
|
||||
}
|
||||
|
|
@ -971,21 +965,21 @@ read_config (GKeyFile *keyfile, gboolean is_base_config,
|
|||
if (!keys)
|
||||
continue;
|
||||
for (k = 0; keys[k]; k++) {
|
||||
gs_free char *new_value = NULL;
|
||||
const char *key;
|
||||
char *new_value;
|
||||
char last_char;
|
||||
gsize key_len;
|
||||
|
||||
key = keys[k];
|
||||
g_assert (key && *key);
|
||||
nm_assert (key && *key);
|
||||
|
||||
if ( _HAS_PREFIX (key, NM_CONFIG_KEYFILE_KEYPREFIX_WAS)
|
||||
|| _HAS_PREFIX (key, NM_CONFIG_KEYFILE_KEYPREFIX_SET)) {
|
||||
if ( NM_STR_HAS_PREFIX_WITH_MORE (key, NM_CONFIG_KEYFILE_KEYPREFIX_WAS)
|
||||
|| NM_STR_HAS_PREFIX_WITH_MORE (key, NM_CONFIG_KEYFILE_KEYPREFIX_SET)) {
|
||||
/* these keys are protected. We ignore them if the user sets them. */
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcmp (key, NM_CONFIG_KEYFILE_KEY_ATOMIC_SECTION_WAS)) {
|
||||
if (nm_streq (key, NM_CONFIG_KEYFILE_KEY_ATOMIC_SECTION_WAS)) {
|
||||
/* the "was" key is protected and it cannot be set by user configuration. */
|
||||
continue;
|
||||
}
|
||||
|
|
@ -996,6 +990,7 @@ read_config (GKeyFile *keyfile, gboolean is_base_config,
|
|||
&& (last_char == '+' || last_char == '-')) {
|
||||
gs_free char *base_key = g_strndup (key, key_len - 1);
|
||||
gboolean is_string_list;
|
||||
gboolean old_val_was_set = FALSE;
|
||||
|
||||
is_string_list = _setting_is_string_list (group, base_key);
|
||||
|
||||
|
|
@ -1007,13 +1002,19 @@ read_config (GKeyFile *keyfile, gboolean is_base_config,
|
|||
gs_free char **new_val = NULL;
|
||||
|
||||
if (is_string_list) {
|
||||
old_val = g_key_file_get_string_list (keyfile, group, base_key, NULL, NULL);
|
||||
gs_free_error GError *old_error = NULL;
|
||||
|
||||
old_val = g_key_file_get_string_list (keyfile, group, base_key, NULL, &old_error);
|
||||
new_val = g_key_file_get_string_list (kf, group, key, NULL, NULL);
|
||||
if (!old_val && !g_key_file_has_key (keyfile, group, base_key, NULL)) {
|
||||
/* we must fill the unspecified value with the compile-time default. */
|
||||
if (nm_streq (group, NM_CONFIG_KEYFILE_GROUP_MAIN) && nm_streq (base_key, "plugins")) {
|
||||
if ( nm_streq (group, NM_CONFIG_KEYFILE_GROUP_MAIN)
|
||||
&& nm_streq (base_key, "plugins")) {
|
||||
old_val_was_set = !nm_keyfile_error_is_not_found (old_error);
|
||||
if ( !old_val
|
||||
&& !old_val_was_set) {
|
||||
/* we must fill the unspecified value with the compile-time default. */
|
||||
g_key_file_set_value (keyfile, group, base_key, NM_CONFIG_DEFAULT_MAIN_PLUGINS);
|
||||
old_val = g_key_file_get_string_list (keyfile, group, base_key, NULL, NULL);
|
||||
old_val_was_set = TRUE;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1059,7 +1060,7 @@ read_config (GKeyFile *keyfile, gboolean is_base_config,
|
|||
g_key_file_set_value (keyfile, group, base_key, specs_joined);
|
||||
}
|
||||
} else {
|
||||
if (is_string_list)
|
||||
if (is_string_list && !old_val_was_set)
|
||||
g_key_file_remove_key (keyfile, group, base_key, NULL);
|
||||
else
|
||||
g_key_file_set_value (keyfile, group, base_key, "");
|
||||
|
|
@ -1079,12 +1080,8 @@ read_config (GKeyFile *keyfile, gboolean is_base_config,
|
|||
g_strdup_printf ("unknown key '%s' in section [%s] of file '%s'",
|
||||
key, group, path));
|
||||
}
|
||||
g_free (new_value);
|
||||
}
|
||||
g_strfreev (keys);
|
||||
}
|
||||
g_strfreev (groups);
|
||||
g_key_file_free (kf);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -1174,7 +1171,7 @@ _get_config_dir_files (const char *config_dir)
|
|||
if (direnum) {
|
||||
while ((info = g_file_enumerator_next_file (direnum, NULL, NULL))) {
|
||||
name = g_file_info_get_name (info);
|
||||
if (g_str_has_suffix (name, ".conf"))
|
||||
if (NM_STR_HAS_SUFFIX (name, ".conf"))
|
||||
g_ptr_array_add (confs, g_strdup (name));
|
||||
g_object_unref (info);
|
||||
}
|
||||
|
|
@ -1472,14 +1469,14 @@ intern_config_read (const char *filename,
|
|||
const char *group = groups[g];
|
||||
gboolean is_intern, is_atomic;
|
||||
|
||||
if (!strcmp (group, NM_CONFIG_KEYFILE_GROUP_CONFIG))
|
||||
if (nm_streq (group, NM_CONFIG_KEYFILE_GROUP_CONFIG))
|
||||
continue;
|
||||
|
||||
keys = g_key_file_get_keys (keyfile, group, NULL, NULL);
|
||||
if (!keys)
|
||||
continue;
|
||||
|
||||
is_intern = g_str_has_prefix (group, NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN);
|
||||
is_intern = NM_STR_HAS_PREFIX (group, NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN);
|
||||
is_atomic = !is_intern && _is_atomic_section (atomic_section_prefixes, group);
|
||||
|
||||
if (is_atomic) {
|
||||
|
|
@ -1489,7 +1486,7 @@ intern_config_read (const char *filename,
|
|||
conf_section_is = _keyfile_serialize_section (keyfile_conf, group);
|
||||
conf_section_was = g_key_file_get_string (keyfile, group, NM_CONFIG_KEYFILE_KEY_ATOMIC_SECTION_WAS, NULL);
|
||||
|
||||
if (g_strcmp0 (conf_section_was, conf_section_is) != 0) {
|
||||
if (!nm_streq0 (conf_section_was, conf_section_is)) {
|
||||
/* the section no longer matches. Skip it entirely. */
|
||||
needs_rewrite = TRUE;
|
||||
continue;
|
||||
|
|
@ -1510,10 +1507,10 @@ intern_config_read (const char *filename,
|
|||
has_intern = TRUE;
|
||||
g_key_file_set_value (keyfile_intern, group, key, value_set);
|
||||
} else if (is_atomic) {
|
||||
if (strcmp (key, NM_CONFIG_KEYFILE_KEY_ATOMIC_SECTION_WAS) == 0)
|
||||
if (nm_streq (key, NM_CONFIG_KEYFILE_KEY_ATOMIC_SECTION_WAS))
|
||||
continue;
|
||||
g_key_file_set_value (keyfile_intern, group, key, value_set);
|
||||
} else if (_HAS_PREFIX (key, NM_CONFIG_KEYFILE_KEYPREFIX_SET)) {
|
||||
} else if (NM_STR_HAS_PREFIX_WITH_MORE (key, NM_CONFIG_KEYFILE_KEYPREFIX_SET)) {
|
||||
const char *key_base = &key[NM_STRLEN (NM_CONFIG_KEYFILE_KEYPREFIX_SET)];
|
||||
gs_free char *value_was = NULL;
|
||||
gs_free char *value_conf = NULL;
|
||||
|
|
@ -1523,7 +1520,7 @@ intern_config_read (const char *filename,
|
|||
value_conf = g_key_file_get_value (keyfile_conf, group, key_base, NULL);
|
||||
value_was = g_key_file_get_value (keyfile, group, key_was, NULL);
|
||||
|
||||
if (g_strcmp0 (value_conf, value_was) != 0) {
|
||||
if (!nm_streq0 (value_conf, value_was)) {
|
||||
/* if value_was is no longer the same as @value_conf, it means the user
|
||||
* changed the configuration since the last write. In this case, we
|
||||
* drop the value. It also means our file is out-of-date, and we should
|
||||
|
|
@ -1533,7 +1530,7 @@ intern_config_read (const char *filename,
|
|||
}
|
||||
has_intern = TRUE;
|
||||
g_key_file_set_value (keyfile_intern, group, key_base, value_set);
|
||||
} else if (_HAS_PREFIX (key, NM_CONFIG_KEYFILE_KEYPREFIX_WAS)) {
|
||||
} else if (NM_STR_HAS_PREFIX_WITH_MORE (key, NM_CONFIG_KEYFILE_KEYPREFIX_WAS)) {
|
||||
const char *key_base = &key[NM_STRLEN (NM_CONFIG_KEYFILE_KEYPREFIX_WAS)];
|
||||
gs_free char *key_set = g_strdup_printf (NM_CONFIG_KEYFILE_KEYPREFIX_SET"%s", key_base);
|
||||
gs_free char *value_was = NULL;
|
||||
|
|
@ -1548,7 +1545,7 @@ intern_config_read (const char *filename,
|
|||
value_conf = g_key_file_get_value (keyfile_conf, group, key_base, NULL);
|
||||
value_was = g_key_file_get_value (keyfile, group, key, NULL);
|
||||
|
||||
if (g_strcmp0 (value_conf, value_was) != 0) {
|
||||
if (!nm_streq0 (value_conf, value_was)) {
|
||||
/* if value_was is no longer the same as @value_conf, it means the user
|
||||
* changed the configuration since the last write. In this case, we
|
||||
* don't overwrite the user-provided value. It also means our file is
|
||||
|
|
@ -1577,7 +1574,7 @@ out:
|
|||
if (g_key_file_remove_group (keyfile_intern, NM_CONFIG_KEYFILE_GROUP_INTERN_GLOBAL_DNS, NULL))
|
||||
needs_rewrite = TRUE;
|
||||
for (g = 0; groups && groups[g]; g++) {
|
||||
if ( g_str_has_prefix (groups[g], NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN_GLOBAL_DNS_DOMAIN)
|
||||
if ( NM_STR_HAS_PREFIX (groups[g], NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN_GLOBAL_DNS_DOMAIN)
|
||||
&& groups[g][NM_STRLEN (NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN_GLOBAL_DNS_DOMAIN)]) {
|
||||
g_key_file_remove_group (keyfile_intern, groups[g], NULL);
|
||||
needs_rewrite = TRUE;
|
||||
|
|
@ -1602,12 +1599,12 @@ out:
|
|||
static int
|
||||
_intern_config_write_sort_fcn (const char **a, const char **b, const char *const*atomic_section_prefixes)
|
||||
{
|
||||
const char *g_a = (a ? *a : NULL);
|
||||
const char *g_b = (b ? *b : NULL);
|
||||
const char *g_a = *a;
|
||||
const char *g_b = *b;
|
||||
gboolean a_is, b_is;
|
||||
|
||||
a_is = g_str_has_prefix (g_a, NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN);
|
||||
b_is = g_str_has_prefix (g_b, NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN);
|
||||
a_is = NM_STR_HAS_PREFIX (g_a, NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN);
|
||||
b_is = NM_STR_HAS_PREFIX (g_b, NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN);
|
||||
|
||||
if (a_is != b_is) {
|
||||
if (a_is)
|
||||
|
|
@ -1668,7 +1665,7 @@ intern_config_write (const char *filename,
|
|||
if (!keys)
|
||||
continue;
|
||||
|
||||
is_intern = g_str_has_prefix (group, NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN);
|
||||
is_intern = NM_STR_HAS_PREFIX (group, NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN);
|
||||
is_atomic = !is_intern && _is_atomic_section (atomic_section_prefixes, group);
|
||||
|
||||
if (is_atomic) {
|
||||
|
|
@ -1707,16 +1704,16 @@ intern_config_write (const char *filename,
|
|||
else {
|
||||
gs_free char *value_was = NULL;
|
||||
|
||||
if (_HAS_PREFIX (key, NM_CONFIG_KEYFILE_KEYPREFIX_SET)) {
|
||||
if (NM_STR_HAS_PREFIX_WITH_MORE (key, NM_CONFIG_KEYFILE_KEYPREFIX_SET)) {
|
||||
/* Setting a key with .set prefix has no meaning, as these keys
|
||||
* are protected. Just set the value you want to set instead.
|
||||
* Why did this happen?? */
|
||||
g_warn_if_reached ();
|
||||
} else if (_HAS_PREFIX (key, NM_CONFIG_KEYFILE_KEYPREFIX_WAS)) {
|
||||
} else if (NM_STR_HAS_PREFIX_WITH_MORE (key, NM_CONFIG_KEYFILE_KEYPREFIX_WAS)) {
|
||||
const char *key_base = &key[NM_STRLEN (NM_CONFIG_KEYFILE_KEYPREFIX_WAS)];
|
||||
|
||||
if ( _HAS_PREFIX (key_base, NM_CONFIG_KEYFILE_KEYPREFIX_SET)
|
||||
|| _HAS_PREFIX (key_base, NM_CONFIG_KEYFILE_KEYPREFIX_WAS)) {
|
||||
if ( NM_STR_HAS_PREFIX_WITH_MORE (key_base, NM_CONFIG_KEYFILE_KEYPREFIX_SET)
|
||||
|| NM_STR_HAS_PREFIX_WITH_MORE (key_base, NM_CONFIG_KEYFILE_KEYPREFIX_WAS)) {
|
||||
g_warn_if_reached ();
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1735,7 +1732,7 @@ intern_config_write (const char *filename,
|
|||
} else {
|
||||
if (keyfile_conf) {
|
||||
value_was = g_key_file_get_value (keyfile_conf, group, key, NULL);
|
||||
if (g_strcmp0 (value_set, value_was) == 0) {
|
||||
if (nm_streq0 (value_set, value_was)) {
|
||||
/* there is no point in storing the identical value as we have via
|
||||
* user configuration. Skip it. */
|
||||
continue;
|
||||
|
|
@ -1837,7 +1834,7 @@ nm_config_set_global_dns (NMConfig *self, NMGlobalDnsConfig *global_dns, GError
|
|||
g_key_file_remove_group (keyfile, NM_CONFIG_KEYFILE_GROUP_INTERN_GLOBAL_DNS, NULL);
|
||||
groups = g_key_file_get_groups (keyfile, NULL);
|
||||
for (i = 0; groups[i]; i++) {
|
||||
if (g_str_has_prefix (groups[i], NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN_GLOBAL_DNS_DOMAIN))
|
||||
if (NM_STR_HAS_PREFIX (groups[i], NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN_GLOBAL_DNS_DOMAIN))
|
||||
g_key_file_remove_group (keyfile, groups[i], NULL);
|
||||
}
|
||||
g_strfreev (groups);
|
||||
|
|
@ -2210,7 +2207,7 @@ _config_device_state_data_new (int ifindex, GKeyFile *kf)
|
|||
gs_free char *perm_hw_addr_fake = NULL;
|
||||
gsize connection_uuid_len;
|
||||
gsize perm_hw_addr_fake_len;
|
||||
int nm_owned = -1;
|
||||
NMTernary nm_owned;
|
||||
char *p;
|
||||
guint32 route_metric_default_effective;
|
||||
guint32 route_metric_default_aspired;
|
||||
|
|
@ -2252,7 +2249,7 @@ _config_device_state_data_new (int ifindex, GKeyFile *kf)
|
|||
nm_owned = nm_config_keyfile_get_boolean (kf,
|
||||
DEVICE_RUN_STATE_KEYFILE_GROUP_DEVICE,
|
||||
DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_NM_OWNED,
|
||||
-1);
|
||||
NM_TERNARY_DEFAULT);
|
||||
|
||||
/* metric zero is not a valid metric. While zero valid for IPv4, for IPv6 it is an alias
|
||||
* for 1024. Since we handle here IPv4 and IPv6 the same, we cannot allow zero. */
|
||||
|
|
@ -2325,9 +2322,11 @@ nm_config_device_state_load (int ifindex)
|
|||
return NULL;
|
||||
|
||||
device_state = _config_device_state_data_new (ifindex, kf);
|
||||
nm_owned_str = device_state->nm_owned == TRUE ?
|
||||
", nm-owned=1" :
|
||||
(device_state->nm_owned == FALSE ? ", nm-owned=0" : "");
|
||||
nm_owned_str = device_state->nm_owned == NM_TERNARY_TRUE
|
||||
? ", nm-owned=1"
|
||||
: ( device_state->nm_owned == NM_TERNARY_FALSE
|
||||
? ", nm-owned=0"
|
||||
: "");
|
||||
|
||||
_LOGT ("device-state: %s #%d (%s); managed=%s%s%s%s%s%s%s%s, route-metric-default=%"G_GUINT32_FORMAT"-%"G_GUINT32_FORMAT"",
|
||||
kf ? "read" : "miss",
|
||||
|
|
@ -2390,7 +2389,7 @@ nm_config_device_state_write (int ifindex,
|
|||
NMConfigDeviceStateManagedType managed,
|
||||
const char *perm_hw_addr_fake,
|
||||
const char *connection_uuid,
|
||||
int nm_owned,
|
||||
NMTernary nm_owned,
|
||||
guint32 route_metric_default_aspired,
|
||||
guint32 route_metric_default_effective,
|
||||
const char *next_server,
|
||||
|
|
@ -2429,7 +2428,7 @@ nm_config_device_state_write (int ifindex,
|
|||
DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_CONNECTION_UUID,
|
||||
connection_uuid);
|
||||
}
|
||||
if (nm_owned >= 0) {
|
||||
if (nm_owned != NM_TERNARY_DEFAULT) {
|
||||
g_key_file_set_boolean (kf,
|
||||
DEVICE_RUN_STATE_KEYFILE_GROUP_DEVICE,
|
||||
DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_NM_OWNED,
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ struct _NMConfigDeviceStateData {
|
|||
|
||||
/* whether the device was nm-owned (0/1) or -1 for
|
||||
* non-software devices. */
|
||||
int nm_owned:3;
|
||||
NMTernary nm_owned:3;
|
||||
};
|
||||
|
||||
NMConfigDeviceStateData *nm_config_device_state_load (int ifindex);
|
||||
|
|
@ -252,7 +252,7 @@ gboolean nm_config_device_state_write (int ifindex,
|
|||
NMConfigDeviceStateManagedType managed,
|
||||
const char *perm_hw_addr_fake,
|
||||
const char *connection_uuid,
|
||||
int nm_owned,
|
||||
NMTernary nm_owned,
|
||||
guint32 route_metric_default_aspired,
|
||||
guint32 route_metric_default_effective,
|
||||
const char *next_server,
|
||||
|
|
|
|||
|
|
@ -1703,11 +1703,13 @@ nm_wildcard_match_check (const char *str,
|
|||
const char *const *patterns,
|
||||
guint num_patterns)
|
||||
{
|
||||
guint i, neg = 0;
|
||||
gsize i, neg = 0;
|
||||
|
||||
for (i = 0; i < num_patterns; i++) {
|
||||
if (patterns[i][0] == '!') {
|
||||
neg++;
|
||||
if (!str)
|
||||
continue;
|
||||
if (!fnmatch (patterns[i] + 1, str, 0))
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -1716,10 +1718,12 @@ nm_wildcard_match_check (const char *str,
|
|||
if (neg == num_patterns)
|
||||
return TRUE;
|
||||
|
||||
for (i = 0; i < num_patterns; i++) {
|
||||
if ( patterns[i][0] != '!'
|
||||
&& !fnmatch (patterns[i], str, 0))
|
||||
return TRUE;
|
||||
if (str) {
|
||||
for (i = 0; i < num_patterns; i++) {
|
||||
if ( patterns[i][0] != '!'
|
||||
&& !fnmatch (patterns[i], str, 0))
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
|
|
|||
|
|
@ -247,7 +247,9 @@ private_server_closed_connection (GDBusConnection *conn,
|
|||
CloseConnectionInfo *info;
|
||||
|
||||
/* Clean up after the connection */
|
||||
_LOGD ("(%s) closed connection %p on private socket", s->tag, conn);
|
||||
_LOGD ("(%s) closed connection "NM_HASH_OBFUSCATE_PTR_FMT" on private socket",
|
||||
s->tag,
|
||||
NM_HASH_OBFUSCATE_PTR (conn));
|
||||
|
||||
info = g_slice_new0 (CloseConnectionInfo);
|
||||
info->connection = conn;
|
||||
|
|
@ -285,7 +287,9 @@ private_server_new_connection (GDBusServer *server,
|
|||
obj_mgr_data->fake_sender = sender;
|
||||
c_list_link_tail (&s->object_mgr_lst_head, &obj_mgr_data->object_mgr_lst);
|
||||
|
||||
_LOGD ("(%s) accepted connection %p on private socket", s->tag, conn);
|
||||
_LOGD ("(%s) accepted connection "NM_HASH_OBFUSCATE_PTR_FMT" on private socket",
|
||||
s->tag,
|
||||
NM_HASH_OBFUSCATE_PTR (conn));
|
||||
|
||||
/* Emit this for the manager.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ static struct {
|
|||
char *dhcp4_clientid;
|
||||
char *dhcp4_hostname;
|
||||
char *dhcp4_fqdn;
|
||||
char *mud_url;
|
||||
char *iid_str;
|
||||
NMSettingIP6ConfigAddrGenMode addr_gen_mode;
|
||||
char *logging_backend;
|
||||
|
|
@ -523,6 +524,7 @@ main (int argc, char *argv[])
|
|||
global_opt.dhcp4_hostname,
|
||||
global_opt.dhcp4_fqdn,
|
||||
NM_DHCP_HOSTNAME_FLAGS_FQDN_DEFAULT_IP4,
|
||||
global_opt.mud_url,
|
||||
client_id,
|
||||
NM_DHCP_TIMEOUT_DEFAULT,
|
||||
NULL,
|
||||
|
|
|
|||
|
|
@ -6552,7 +6552,7 @@ nm_manager_write_device_state (NMManager *self, NMDevice *device, int *out_ifind
|
|||
gboolean perm_hw_addr_is_fake;
|
||||
guint32 route_metric_default_aspired;
|
||||
guint32 route_metric_default_effective;
|
||||
int nm_owned;
|
||||
NMTernary nm_owned;
|
||||
NMDhcpConfig *dhcp_config;
|
||||
const char *next_server = NULL;
|
||||
const char *root_path = NULL;
|
||||
|
|
@ -6588,7 +6588,9 @@ nm_manager_write_device_state (NMManager *self, NMDevice *device, int *out_ifind
|
|||
if (perm_hw_addr_fake && !perm_hw_addr_is_fake)
|
||||
perm_hw_addr_fake = NULL;
|
||||
|
||||
nm_owned = nm_device_is_software (device) ? nm_device_is_nm_owned (device) : -1;
|
||||
nm_owned = nm_device_is_software (device)
|
||||
? nm_device_is_nm_owned (device)
|
||||
: NM_TERNARY_DEFAULT;
|
||||
|
||||
route_metric_default_effective = _device_route_metric_get (self, ifindex, NM_DEVICE_TYPE_UNKNOWN,
|
||||
TRUE, &route_metric_default_aspired);
|
||||
|
|
|
|||
|
|
@ -2,150 +2,110 @@
|
|||
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||
<busconfig>
|
||||
<policy user="root">
|
||||
<allow own="org.freedesktop.NetworkManager"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"/>
|
||||
<policy user="root">
|
||||
<allow own="org.freedesktop.NetworkManager"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"/>
|
||||
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.PPP"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.PPP"/>
|
||||
|
||||
<allow send_interface="org.freedesktop.NetworkManager.SecretAgent"/>
|
||||
<!-- These are there because some broken policies do
|
||||
<deny send_interface="..." /> (see dbus-daemon(8) for details).
|
||||
This seems to override that for the known VPN plugins.
|
||||
-->
|
||||
<allow send_destination="org.freedesktop.NetworkManager.openconnect"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.openswan"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.openvpn"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.pptp"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.vpnc"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.ssh"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.iodine"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.l2tp"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.libreswan"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.fortisslvpn"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.strongswan"/>
|
||||
<allow send_interface="org.freedesktop.NetworkManager.VPN.Plugin"/>
|
||||
<allow send_interface="org.freedesktop.NetworkManager.SecretAgent"/>
|
||||
|
||||
<allow send_destination="org.fedoraproject.FirewallD1"/>
|
||||
<!-- These are there because some broken policies do
|
||||
<deny send_interface="..." /> (see dbus-daemon(8) for details).
|
||||
This seems to override that for the known VPN plugins.
|
||||
-->
|
||||
<allow send_destination="org.freedesktop.NetworkManager.openconnect"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.openswan"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.openvpn"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.pptp"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.vpnc"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.ssh"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.iodine"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.l2tp"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.libreswan"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.fortisslvpn"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.strongswan"/>
|
||||
<allow send_interface="org.freedesktop.NetworkManager.VPN.Plugin"/>
|
||||
|
||||
<!-- Allow the custom name for the dnsmasq instance spawned by NM
|
||||
from the dns dnsmasq plugin to own its dbus name, and for
|
||||
messages to be sent to it.
|
||||
-->
|
||||
<allow own="org.freedesktop.NetworkManager.dnsmasq"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.dnsmasq"/>
|
||||
</policy>
|
||||
<policy context="default">
|
||||
<deny own="org.freedesktop.NetworkManager"/>
|
||||
<allow send_destination="org.fedoraproject.FirewallD1"/>
|
||||
|
||||
<deny send_destination="org.freedesktop.NetworkManager"/>
|
||||
<!-- Allow the custom name for the dnsmasq instance spawned by NM
|
||||
from the dns dnsmasq plugin to own its dbus name, and for
|
||||
messages to be sent to it.
|
||||
-->
|
||||
<allow own="org.freedesktop.NetworkManager.dnsmasq"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.dnsmasq"/>
|
||||
</policy>
|
||||
<policy context="default">
|
||||
<deny own="org.freedesktop.NetworkManager"/>
|
||||
|
||||
<!-- Basic D-Bus API stuff -->
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.DBus.Introspectable"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.DBus.Properties"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.DBus.ObjectManager"/>
|
||||
<deny send_destination="org.freedesktop.NetworkManager"/>
|
||||
|
||||
<!-- Devices (read-only properties, no methods) -->
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.Device.Adsl"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.Device.Bond"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.Device.Bridge"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.Device.Bluetooth"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.Device.Wired"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.Device.Generic"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.Device.Gre"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.Device.Infiniband"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.Device.Macvlan"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.Device.Modem"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.Device.OlpcMesh"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.Device.Team"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.Device.Tun"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.Device.Veth"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.Device.Vlan"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.WiMax.Nsp"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.AccessPoint"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.WifiP2PPeer"/>
|
||||
<!-- Basic D-Bus API stuff -->
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.DBus.Introspectable"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.DBus.Properties"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.DBus.ObjectManager"/>
|
||||
|
||||
<!-- Devices (read-only, no security required) -->
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.Device.WiMax"/>
|
||||
<!-- Devices (read-only properties, no methods) -->
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.AccessPoint"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.Device.Adsl"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.Device.Bluetooth"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.Device.Bond"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.Device.Bridge"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.Device.Generic"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.Device.Gre"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.Device.Infiniband"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.Device.Macvlan"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.Device.Modem"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.Device.OlpcMesh"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.Device.Team"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.Device.Tun"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.Device.Veth"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.Device.Vlan"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.Device.Wired"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.WiMax.Nsp"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.WifiP2PPeer"/>
|
||||
|
||||
<!-- Devices (read/write, secured with PolicyKit) -->
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.Device.Wireless"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.Device.WifiP2P"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.Device"/>
|
||||
<!-- Devices (read-only, no security required) -->
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.Device.WiMax"/>
|
||||
|
||||
<!-- Core stuff (read-only properties, no methods) -->
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.Connection.Active"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.DHCP4Config"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.DHCP6Config"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.IP4Config"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.IP6Config"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.VPN.Connection"/>
|
||||
<!-- Devices (read/write, secured with PolicyKit) -->
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.Device.Wireless"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.Device.WifiP2P"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.Device"/>
|
||||
|
||||
<!-- Core stuff (read/write, secured with PolicyKit) -->
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.Settings"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.Settings.Connection"/>
|
||||
<!-- Core stuff (read-only properties, no methods) -->
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.Connection.Active"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.DHCP4Config"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.DHCP6Config"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.IP4Config"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.IP6Config"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.VPN.Connection"/>
|
||||
|
||||
<!-- Agents; secured with PolicyKit. Any process can talk to
|
||||
the AgentManager API, but only NetworkManager can talk
|
||||
to the agents themselves. -->
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.AgentManager"/>
|
||||
<!-- Core stuff (read/write, secured with PolicyKit) -->
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.Settings"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.Settings.Connection"/>
|
||||
|
||||
<!-- Root-only functions -->
|
||||
<deny send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager"
|
||||
send_member="SetLogging"/>
|
||||
<deny send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager"
|
||||
send_member="Sleep"/>
|
||||
<deny send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.Settings"
|
||||
send_member="LoadConnections"/>
|
||||
<deny send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.Settings"
|
||||
send_member="ReloadConnections"/>
|
||||
<!-- Agents; secured with PolicyKit. Any process can talk to
|
||||
the AgentManager API, but only NetworkManager can talk
|
||||
to the agents themselves. -->
|
||||
<allow send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.AgentManager"/>
|
||||
|
||||
<deny own="org.freedesktop.NetworkManager.dnsmasq"/>
|
||||
<deny send_destination="org.freedesktop.NetworkManager.dnsmasq"/>
|
||||
</policy>
|
||||
<!-- Root-only functions -->
|
||||
<deny send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager" send_member="SetLogging"/>
|
||||
<deny send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager" send_member="Sleep"/>
|
||||
<deny send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.Settings" send_member="LoadConnections"/>
|
||||
<deny send_destination="org.freedesktop.NetworkManager" send_interface="org.freedesktop.NetworkManager.Settings" send_member="ReloadConnections"/>
|
||||
|
||||
<limit name="max_replies_per_connection">1024</limit>
|
||||
<limit name="max_match_rules_per_connection">2048</limit>
|
||||
<deny own="org.freedesktop.NetworkManager.dnsmasq"/>
|
||||
<deny send_destination="org.freedesktop.NetworkManager.dnsmasq"/>
|
||||
</policy>
|
||||
|
||||
<limit name="max_replies_per_connection">1024</limit>
|
||||
<limit name="max_match_rules_per_connection">2048</limit>
|
||||
</busconfig>
|
||||
|
||||
|
|
|
|||
|
|
@ -77,17 +77,13 @@ struct nla_policy {
|
|||
/* static asserts that @tb and @policy are suitable arguments to nla_parse(). */
|
||||
#define _nl_static_assert_tb(tb, policy) \
|
||||
G_STMT_START { \
|
||||
\
|
||||
G_STATIC_ASSERT_EXPR (G_N_ELEMENTS (tb) > 0); \
|
||||
\
|
||||
/* we allow @policy to be either NULL or a C array. */ \
|
||||
G_STATIC_ASSERT_EXPR ( sizeof (policy) == sizeof (NULL) \
|
||||
|| G_N_ELEMENTS (tb) == (sizeof (policy) / sizeof (struct nla_policy))); \
|
||||
\
|
||||
/* For above check to work, we don't support policy being an array with same size as
|
||||
* sizeof(NULL), otherwise, the compile time check breaks down. */ \
|
||||
G_STATIC_ASSERT_EXPR (sizeof (NULL) != G_N_ELEMENTS (tb) * sizeof (struct nla_policy)); \
|
||||
\
|
||||
/* We allow @policy to be either a C array or NULL. The sizeof()
|
||||
* must either match the expected array size or the sizeof(NULL),
|
||||
* but not both. */ \
|
||||
G_STATIC_ASSERT_EXPR ( (sizeof (policy) == G_N_ELEMENTS (tb) * sizeof (struct nla_policy)) \
|
||||
^ (sizeof (policy) == sizeof (NULL))); \
|
||||
} G_STMT_END
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -2,11 +2,10 @@
|
|||
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||
<busconfig>
|
||||
<policy context="default">
|
||||
<allow send_destination="com.redhat.ifcfgrh1"/>
|
||||
</policy>
|
||||
<policy user="root">
|
||||
<allow own="com.redhat.ifcfgrh1"/>
|
||||
</policy>
|
||||
<policy context="default">
|
||||
<allow send_destination="com.redhat.ifcfgrh1"/>
|
||||
</policy>
|
||||
<policy user="root">
|
||||
<allow own="com.redhat.ifcfgrh1"/>
|
||||
</policy>
|
||||
</busconfig>
|
||||
|
||||
|
|
|
|||
|
|
@ -582,6 +582,11 @@ make_connection_setting (const char *file,
|
|||
g_object_set (s_con, NM_SETTING_CONNECTION_WAIT_DEVICE_TIMEOUT, (int) vint64, NULL);
|
||||
}
|
||||
|
||||
nm_clear_g_free (&value);
|
||||
v = svGetValue (ifcfg, "MUD_URL", &value);
|
||||
if (v)
|
||||
g_object_set (s_con, NM_SETTING_CONNECTION_MUD_URL, v, NULL);
|
||||
|
||||
i_val = NM_SETTING_CONNECTION_MDNS_DEFAULT;
|
||||
if (!svGetValueEnum (ifcfg, "MDNS",
|
||||
nm_setting_connection_mdns_get_type (),
|
||||
|
|
@ -1532,29 +1537,42 @@ make_user_setting (shvarFile *ifcfg)
|
|||
: NULL;
|
||||
}
|
||||
|
||||
static NMSetting *
|
||||
make_match_setting (shvarFile *ifcfg)
|
||||
{
|
||||
NMSettingMatch *s_match = NULL;
|
||||
gs_free const char **strv = NULL;
|
||||
gs_free char *value = NULL;
|
||||
const char *v;
|
||||
gsize i;
|
||||
|
||||
v = svGetValueStr (ifcfg, "MATCH_INTERFACE_NAME", &value);
|
||||
if (!v)
|
||||
return NULL;
|
||||
static void
|
||||
make_match_setting_prop (const char *v,
|
||||
NMSettingMatch **s_match,
|
||||
void (*add_fcn) (NMSettingMatch *s_match, const char *value))
|
||||
{
|
||||
gs_free const char **strv = NULL;
|
||||
gsize i;
|
||||
|
||||
strv = nm_utils_escaped_tokens_split (v, NM_ASCII_SPACES);
|
||||
if (strv) {
|
||||
for (i = 0; strv[i]; i++) {
|
||||
if (!s_match)
|
||||
s_match = (NMSettingMatch *) nm_setting_match_new ();
|
||||
nm_setting_match_add_interface_name (s_match, strv[i]);
|
||||
if (!(*s_match))
|
||||
*s_match = NM_SETTING_MATCH (nm_setting_match_new ());
|
||||
add_fcn (*s_match, strv[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (NMSetting *) s_match;
|
||||
static NMSetting *
|
||||
make_match_setting (shvarFile *ifcfg)
|
||||
{
|
||||
NMSettingMatch *s_match = NULL;
|
||||
gs_free char *value_ifn = NULL;
|
||||
gs_free char *value_kcl = NULL;
|
||||
gs_free char *value_d = NULL;
|
||||
const char *v;
|
||||
|
||||
v = svGetValueStr (ifcfg, "MATCH_INTERFACE_NAME", &value_ifn);
|
||||
make_match_setting_prop(v, &s_match, nm_setting_match_add_interface_name);
|
||||
v = svGetValueStr (ifcfg, "MATCH_KERNEL_COMMAND_LINE", &value_kcl);
|
||||
make_match_setting_prop(v, &s_match, nm_setting_match_add_kernel_command_line);
|
||||
v = svGetValueStr (ifcfg, "MATCH_DRIVER", &value_d);
|
||||
make_match_setting_prop(v, &s_match, nm_setting_match_add_driver);
|
||||
|
||||
return NM_SETTING (s_match);
|
||||
}
|
||||
|
||||
static NMSetting *
|
||||
|
|
@ -5152,24 +5170,33 @@ handle_bridge_option (NMSetting *setting,
|
|||
gboolean only_with_stp;
|
||||
gboolean extended_bool;
|
||||
} m/*etadata*/[] = {
|
||||
{ "DELAY", NM_SETTING_BRIDGE_FORWARD_DELAY, BRIDGE_OPT_TYPE_MAIN, .only_with_stp = TRUE },
|
||||
{ "priority", NM_SETTING_BRIDGE_PRIORITY, BRIDGE_OPT_TYPE_OPTION, .only_with_stp = TRUE },
|
||||
{ "hello_time", NM_SETTING_BRIDGE_HELLO_TIME, BRIDGE_OPT_TYPE_OPTION, .only_with_stp = TRUE },
|
||||
{ "max_age", NM_SETTING_BRIDGE_MAX_AGE, BRIDGE_OPT_TYPE_OPTION, .only_with_stp = TRUE },
|
||||
{ "ageing_time", NM_SETTING_BRIDGE_AGEING_TIME, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "multicast_querier", NM_SETTING_BRIDGE_MULTICAST_QUERIER, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "multicast_query_use_ifaddr", NM_SETTING_BRIDGE_MULTICAST_QUERY_USE_IFADDR, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "multicast_snooping", NM_SETTING_BRIDGE_MULTICAST_SNOOPING, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "multicast_router", NM_SETTING_BRIDGE_MULTICAST_ROUTER, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "vlan_filtering", NM_SETTING_BRIDGE_VLAN_FILTERING, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "default_pvid", NM_SETTING_BRIDGE_VLAN_DEFAULT_PVID, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "group_address", NM_SETTING_BRIDGE_GROUP_ADDRESS, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "group_fwd_mask", NM_SETTING_BRIDGE_GROUP_FORWARD_MASK, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "vlan_protocol", NM_SETTING_BRIDGE_VLAN_PROTOCOL, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "vlan_stats_enabled", NM_SETTING_BRIDGE_VLAN_STATS_ENABLED, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "priority", NM_SETTING_BRIDGE_PORT_PRIORITY, BRIDGE_OPT_TYPE_PORT_OPTION },
|
||||
{ "path_cost", NM_SETTING_BRIDGE_PORT_PATH_COST, BRIDGE_OPT_TYPE_PORT_OPTION },
|
||||
{ "hairpin_mode", NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE, BRIDGE_OPT_TYPE_PORT_OPTION, .extended_bool = TRUE, },
|
||||
{ "DELAY", NM_SETTING_BRIDGE_FORWARD_DELAY, BRIDGE_OPT_TYPE_MAIN, .only_with_stp = TRUE },
|
||||
{ "priority", NM_SETTING_BRIDGE_PRIORITY, BRIDGE_OPT_TYPE_OPTION, .only_with_stp = TRUE },
|
||||
{ "hello_time", NM_SETTING_BRIDGE_HELLO_TIME, BRIDGE_OPT_TYPE_OPTION, .only_with_stp = TRUE },
|
||||
{ "max_age", NM_SETTING_BRIDGE_MAX_AGE, BRIDGE_OPT_TYPE_OPTION, .only_with_stp = TRUE },
|
||||
{ "ageing_time", NM_SETTING_BRIDGE_AGEING_TIME, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "multicast_last_member_count", NM_SETTING_BRIDGE_MULTICAST_LAST_MEMBER_COUNT, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "multicast_last_member_interval", NM_SETTING_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "multicast_membership_interval", NM_SETTING_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "multicast_hash_max", NM_SETTING_BRIDGE_MULTICAST_HASH_MAX, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "multicast_querier", NM_SETTING_BRIDGE_MULTICAST_QUERIER, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "multicast_querier_interval", NM_SETTING_BRIDGE_MULTICAST_QUERIER_INTERVAL, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "multicast_query_interval", NM_SETTING_BRIDGE_MULTICAST_QUERY_INTERVAL, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "multicast_query_response_interval", NM_SETTING_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "multicast_query_use_ifaddr", NM_SETTING_BRIDGE_MULTICAST_QUERY_USE_IFADDR, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "multicast_snooping", NM_SETTING_BRIDGE_MULTICAST_SNOOPING, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "multicast_router", NM_SETTING_BRIDGE_MULTICAST_ROUTER, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "multicast_startup_query_count", NM_SETTING_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "multicast_startup_query_interval", NM_SETTING_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "vlan_filtering", NM_SETTING_BRIDGE_VLAN_FILTERING, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "default_pvid", NM_SETTING_BRIDGE_VLAN_DEFAULT_PVID, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "group_address", NM_SETTING_BRIDGE_GROUP_ADDRESS, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "group_fwd_mask", NM_SETTING_BRIDGE_GROUP_FORWARD_MASK, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "vlan_protocol", NM_SETTING_BRIDGE_VLAN_PROTOCOL, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "vlan_stats_enabled", NM_SETTING_BRIDGE_VLAN_STATS_ENABLED, BRIDGE_OPT_TYPE_OPTION },
|
||||
{ "priority", NM_SETTING_BRIDGE_PORT_PRIORITY, BRIDGE_OPT_TYPE_PORT_OPTION },
|
||||
{ "path_cost", NM_SETTING_BRIDGE_PORT_PATH_COST, BRIDGE_OPT_TYPE_PORT_OPTION },
|
||||
{ "hairpin_mode", NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE, BRIDGE_OPT_TYPE_PORT_OPTION, .extended_bool = TRUE, },
|
||||
};
|
||||
const char *error_message = NULL;
|
||||
int i;
|
||||
|
|
@ -5222,6 +5249,16 @@ handle_bridge_option (NMSetting *setting,
|
|||
goto warn;
|
||||
}
|
||||
return;
|
||||
case G_TYPE_UINT64: {
|
||||
guint64 vu64;
|
||||
|
||||
vu64 = _nm_utils_ascii_str_to_uint64 (value, 10, 0, G_MAXUINT64, 0);
|
||||
if (!nm_g_object_set_property_uint64 (G_OBJECT (setting), m[i].property_name, vu64, NULL)) {
|
||||
error_message = "number is out of range";
|
||||
goto warn;
|
||||
}
|
||||
}
|
||||
return;
|
||||
case G_TYPE_STRING:
|
||||
nm_g_object_set_property_string (G_OBJECT (setting), m[i].property_name, value, NULL);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -888,11 +888,14 @@ const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[] = {
|
|||
_KEY_TYPE ("MAC_ADDRESS_RANDOMIZATION", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
|
||||
_KEY_TYPE ("MASTER", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
|
||||
_KEY_TYPE ("MASTER_UUID", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
|
||||
_KEY_TYPE ("MATCH_DRIVER", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
|
||||
_KEY_TYPE ("MATCH_INTERFACE_NAME", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
|
||||
_KEY_TYPE ("MATCH_KERNEL_COMMAND_LINE", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
|
||||
_KEY_TYPE ("MDNS", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
|
||||
_KEY_TYPE ("METRIC", NMS_IFCFG_KEY_TYPE_IS_NUMBERED ),
|
||||
_KEY_TYPE ("MODE", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
|
||||
_KEY_TYPE ("MTU", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
|
||||
_KEY_TYPE ("MUD_URL", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
|
||||
_KEY_TYPE ("MULTI_CONNECT", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
|
||||
_KEY_TYPE ("MVRP", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
|
||||
_KEY_TYPE ("NAME", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue