mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-15 16:10:33 +01:00
all: merge branch 'th/policy-routing-pt2-rh1436531' (part 1)
Merge an early part of the branch, with independent cleanups and refactoring. https://bugzilla.redhat.com/show_bug.cgi?id=1436531
This commit is contained in:
commit
3a81e20d76
23 changed files with 455 additions and 294 deletions
|
|
@ -107,7 +107,7 @@ ip_addresses_with_prefix_from_strv (GBinding *binding,
|
|||
GValue *target_value,
|
||||
gpointer user_data)
|
||||
{
|
||||
int family = GPOINTER_TO_INT (user_data);
|
||||
int addr_family = GPOINTER_TO_INT (user_data);
|
||||
char **strings;
|
||||
GPtrArray *addrs;
|
||||
NMIPAddress *addr;
|
||||
|
|
@ -123,7 +123,7 @@ ip_addresses_with_prefix_from_strv (GBinding *binding,
|
|||
|
||||
for (i = 0; strings[i]; i++) {
|
||||
if (i >= addrs->len) {
|
||||
if (family == AF_INET)
|
||||
if (addr_family == AF_INET)
|
||||
addr = nm_ip_address_new (AF_INET, "0.0.0.0", 32, NULL);
|
||||
else
|
||||
addr = nm_ip_address_new (AF_INET6, "::", 128, NULL);
|
||||
|
|
@ -131,16 +131,16 @@ ip_addresses_with_prefix_from_strv (GBinding *binding,
|
|||
} else
|
||||
addr = addrs->pdata[i];
|
||||
|
||||
if (!nm_utils_parse_inaddr_prefix (strings[i], family, &addrstr, &prefix)) {
|
||||
if (!nm_utils_parse_inaddr_prefix (addr_family, strings[i], &addrstr, &prefix)) {
|
||||
g_ptr_array_unref (addrs);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (prefix == -1) {
|
||||
if (family == AF_INET) {
|
||||
if (addr_family == AF_INET) {
|
||||
in_addr_t v4;
|
||||
|
||||
inet_pton (family, addrstr, &v4);
|
||||
inet_pton (addr_family, addrstr, &v4);
|
||||
if (nm_utils_ip_is_site_local (AF_INET, &v4))
|
||||
prefix = nm_utils_ip4_get_default_prefix (v4);
|
||||
else
|
||||
|
|
@ -161,7 +161,7 @@ ip_addresses_with_prefix_from_strv (GBinding *binding,
|
|||
|
||||
/**
|
||||
* nm_editor_bind_ip_addresses_with_prefix_to_strv:
|
||||
* @family: the IP address family
|
||||
* @addr_family: the IP address family
|
||||
* @source: the source object (eg, an #NMSettingIP4Config)
|
||||
* @source_property: the property on @source to bind (eg,
|
||||
* %NM_SETTING_IP4_CONFIG_ADDRESSES)
|
||||
|
|
@ -178,7 +178,7 @@ ip_addresses_with_prefix_from_strv (GBinding *binding,
|
|||
* vice versa if %G_BINDING_BIDIRECTIONAL) is specified.
|
||||
*/
|
||||
void
|
||||
nm_editor_bind_ip_addresses_with_prefix_to_strv (int family,
|
||||
nm_editor_bind_ip_addresses_with_prefix_to_strv (int addr_family,
|
||||
gpointer source,
|
||||
const gchar *source_property,
|
||||
gpointer target,
|
||||
|
|
@ -190,7 +190,7 @@ nm_editor_bind_ip_addresses_with_prefix_to_strv (int family,
|
|||
flags,
|
||||
ip_addresses_with_prefix_to_strv,
|
||||
ip_addresses_with_prefix_from_strv,
|
||||
GINT_TO_POINTER (family), NULL);
|
||||
GINT_TO_POINTER (addr_family), NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -199,14 +199,14 @@ ip_addresses_check_and_copy (GBinding *binding,
|
|||
GValue *target_value,
|
||||
gpointer user_data)
|
||||
{
|
||||
int family = GPOINTER_TO_INT (user_data);
|
||||
int addr_family = GPOINTER_TO_INT (user_data);
|
||||
char **strings;
|
||||
int i;
|
||||
|
||||
strings = g_value_get_boxed (source_value);
|
||||
|
||||
for (i = 0; strings[i]; i++) {
|
||||
if (!nm_utils_ipaddr_valid (family, strings[i]))
|
||||
if (!nm_utils_ipaddr_valid (addr_family, strings[i]))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -216,7 +216,7 @@ ip_addresses_check_and_copy (GBinding *binding,
|
|||
|
||||
/**
|
||||
* nm_editor_bind_ip_addresses_to_strv:
|
||||
* @family: the IP address family
|
||||
* @addr_family: the IP address family
|
||||
* @source: the source object (eg, an #NMSettingIP4Config)
|
||||
* @source_property: the property on @source to bind (eg,
|
||||
* %NM_SETTING_IP4_CONFIG_DNS)
|
||||
|
|
@ -227,10 +227,10 @@ ip_addresses_check_and_copy (GBinding *binding,
|
|||
*
|
||||
* Binds the %G_TYPE_STRV property @source_property on @source to the
|
||||
* %G_TYPE_STRV property @target_property on @target, verifying that
|
||||
* each string is a valid address of type @family when copying.
|
||||
* each string is a valid address of type @addr_family when copying.
|
||||
*/
|
||||
void
|
||||
nm_editor_bind_ip_addresses_to_strv (int family,
|
||||
nm_editor_bind_ip_addresses_to_strv (int addr_family,
|
||||
gpointer source,
|
||||
const gchar *source_property,
|
||||
gpointer target,
|
||||
|
|
@ -242,7 +242,7 @@ nm_editor_bind_ip_addresses_to_strv (int family,
|
|||
flags,
|
||||
ip_addresses_check_and_copy,
|
||||
ip_addresses_check_and_copy,
|
||||
GINT_TO_POINTER (family), NULL);
|
||||
GINT_TO_POINTER (addr_family), NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -261,11 +261,11 @@ ip_gateway_from_string (GBinding *binding,
|
|||
GValue *target_value,
|
||||
gpointer user_data)
|
||||
{
|
||||
int family = GPOINTER_TO_INT (user_data);
|
||||
int addr_family = GPOINTER_TO_INT (user_data);
|
||||
const char *gateway;
|
||||
|
||||
gateway = g_value_get_string (source_value);
|
||||
if (gateway && !nm_utils_ipaddr_valid (family, gateway))
|
||||
if (gateway && !nm_utils_ipaddr_valid (addr_family, gateway))
|
||||
gateway = NULL;
|
||||
|
||||
g_value_set_string (target_value, gateway);
|
||||
|
|
@ -303,7 +303,7 @@ ip_addresses_to_sensitivity (GBinding *binding,
|
|||
|
||||
/**
|
||||
* nm_editor_bind_ip_gateway_to_string:
|
||||
* @family: the IP address family
|
||||
* @addr_family: the IP address family
|
||||
* @source: the source #NMSettingIPConfig
|
||||
* @target: the target object (eg, an #NmtIPEntry)
|
||||
* @target_property: the property on @target to bind (eg, "text")
|
||||
|
|
@ -325,7 +325,7 @@ ip_addresses_to_sensitivity (GBinding *binding,
|
|||
* address.
|
||||
*/
|
||||
void
|
||||
nm_editor_bind_ip_gateway_to_string (int family,
|
||||
nm_editor_bind_ip_gateway_to_string (int addr_family,
|
||||
NMSettingIPConfig *source,
|
||||
gpointer target,
|
||||
const gchar *target_property,
|
||||
|
|
@ -337,7 +337,7 @@ nm_editor_bind_ip_gateway_to_string (int family,
|
|||
flags,
|
||||
ip_gateway_to_string,
|
||||
ip_gateway_from_string,
|
||||
GINT_TO_POINTER (family), NULL);
|
||||
GINT_TO_POINTER (addr_family), NULL);
|
||||
g_object_bind_property_full (source, "addresses",
|
||||
source, "gateway",
|
||||
(flags & G_BINDING_SYNC_CREATE),
|
||||
|
|
@ -421,14 +421,14 @@ ip_route_transform_from_dest_string (GBinding *binding,
|
|||
GValue *target_value,
|
||||
gpointer user_data)
|
||||
{
|
||||
int family = GPOINTER_TO_INT (user_data);
|
||||
int addr_family = GPOINTER_TO_INT (user_data);
|
||||
NMIPRoute *route;
|
||||
const char *text;
|
||||
char *addrstr;
|
||||
int prefix;
|
||||
|
||||
text = g_value_get_string (source_value);
|
||||
if (!nm_utils_parse_inaddr_prefix (text, family, &addrstr, &prefix))
|
||||
if (!nm_utils_parse_inaddr_prefix (addr_family, text, &addrstr, &prefix))
|
||||
return FALSE;
|
||||
|
||||
/* Fetch the original property value */
|
||||
|
|
@ -437,10 +437,10 @@ ip_route_transform_from_dest_string (GBinding *binding,
|
|||
NULL);
|
||||
|
||||
if (prefix == -1) {
|
||||
if (family == AF_INET) {
|
||||
if (addr_family == AF_INET) {
|
||||
in_addr_t v4;
|
||||
|
||||
inet_pton (family, addrstr, &v4);
|
||||
inet_pton (addr_family, addrstr, &v4);
|
||||
if (nm_utils_ip_is_site_local (AF_INET, &v4)) {
|
||||
prefix = nm_utils_ip4_get_default_prefix (v4);
|
||||
if (v4 & (~nm_utils_ip4_prefix_to_netmask (prefix)))
|
||||
|
|
@ -465,13 +465,13 @@ ip_route_transform_from_next_hop_string (GBinding *binding,
|
|||
GValue *target_value,
|
||||
gpointer user_data)
|
||||
{
|
||||
int family = GPOINTER_TO_INT (user_data);
|
||||
int addr_family = GPOINTER_TO_INT (user_data);
|
||||
NMIPRoute *route;
|
||||
const char *text;
|
||||
|
||||
text = g_value_get_string (source_value);
|
||||
if (*text) {
|
||||
if (!nm_utils_ipaddr_valid (family, text))
|
||||
if (!nm_utils_ipaddr_valid (addr_family, text))
|
||||
return FALSE;
|
||||
} else
|
||||
text = NULL;
|
||||
|
|
@ -513,7 +513,7 @@ ip_route_transform_from_metric_string (GBinding *binding,
|
|||
|
||||
/**
|
||||
* nm_editor_bind_ip_route_to_strings:
|
||||
* @family: the IP address family
|
||||
* @addr_family: the IP address family
|
||||
* @source: the source object
|
||||
* @source_property: the source property
|
||||
* @dest_target: the target object for the route's destionation
|
||||
|
|
@ -533,7 +533,7 @@ ip_route_transform_from_metric_string (GBinding *binding,
|
|||
* is a plain IP address, and @metric_target_property is a number.
|
||||
*/
|
||||
void
|
||||
nm_editor_bind_ip_route_to_strings (int family,
|
||||
nm_editor_bind_ip_route_to_strings (int addr_family,
|
||||
gpointer source,
|
||||
const gchar *source_property,
|
||||
gpointer dest_target,
|
||||
|
|
@ -549,19 +549,19 @@ nm_editor_bind_ip_route_to_strings (int family,
|
|||
flags,
|
||||
ip_route_transform_to_dest_string,
|
||||
ip_route_transform_from_dest_string,
|
||||
GINT_TO_POINTER (family), NULL);
|
||||
GINT_TO_POINTER (addr_family), NULL);
|
||||
g_object_bind_property_full (source, source_property,
|
||||
next_hop_target, next_hop_target_property,
|
||||
flags,
|
||||
ip_route_transform_to_next_hop_string,
|
||||
ip_route_transform_from_next_hop_string,
|
||||
GINT_TO_POINTER (family), NULL);
|
||||
GINT_TO_POINTER (addr_family), NULL);
|
||||
g_object_bind_property_full (source, source_property,
|
||||
metric_target, metric_target_property,
|
||||
flags,
|
||||
ip_route_transform_to_metric_string,
|
||||
ip_route_transform_from_metric_string,
|
||||
GINT_TO_POINTER (family), NULL);
|
||||
GINT_TO_POINTER (addr_family), NULL);
|
||||
}
|
||||
|
||||
/* Wireless security method binding */
|
||||
|
|
|
|||
|
|
@ -127,8 +127,8 @@ ip_entry_validate (NmtNewtEntry *entry,
|
|||
if (!*text)
|
||||
return priv->optional;
|
||||
if (priv->prefix)
|
||||
return nm_utils_parse_inaddr_prefix (text, priv->family, NULL, NULL);
|
||||
return nm_utils_parse_inaddr (text, priv->family, NULL);
|
||||
return nm_utils_parse_inaddr_prefix (priv->family, text, NULL, NULL);
|
||||
return nm_utils_parse_inaddr (priv->family, text, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -4852,6 +4852,88 @@ test_hexstr2bin (void)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
_do_strquote (const char *str, gsize buf_len, const char *expected)
|
||||
{
|
||||
char canary = (char) nmtst_get_rand_int ();
|
||||
gs_free char *buf_full = g_malloc (buf_len + 2);
|
||||
char *buf = &buf_full[1];
|
||||
const char *b;
|
||||
|
||||
buf[-1] = canary;
|
||||
buf[buf_len] = canary;
|
||||
|
||||
if (buf_len == 0) {
|
||||
b = nm_strquote (NULL, 0, str);
|
||||
g_assert (b == NULL);
|
||||
g_assert (expected == NULL);
|
||||
b = nm_strquote (buf, 0, str);
|
||||
g_assert (b == buf);
|
||||
} else {
|
||||
b = nm_strquote (buf, buf_len, str);
|
||||
g_assert (b == buf);
|
||||
g_assert (strlen (b) < buf_len);
|
||||
g_assert_cmpstr (expected, ==, b);
|
||||
}
|
||||
|
||||
g_assert (buf[-1] == canary);
|
||||
g_assert (buf[buf_len] == canary);
|
||||
}
|
||||
|
||||
static void
|
||||
test_nm_strquote (void)
|
||||
{
|
||||
_do_strquote (NULL, 0, NULL);
|
||||
_do_strquote ("", 0, NULL);
|
||||
_do_strquote ("a", 0, NULL);
|
||||
_do_strquote ("ab", 0, NULL);
|
||||
|
||||
_do_strquote (NULL, 1, "");
|
||||
_do_strquote (NULL, 2, "(");
|
||||
_do_strquote (NULL, 3, "(n");
|
||||
_do_strquote (NULL, 4, "(nu");
|
||||
_do_strquote (NULL, 5, "(nul");
|
||||
_do_strquote (NULL, 6, "(null");
|
||||
_do_strquote (NULL, 7, "(null)");
|
||||
_do_strquote (NULL, 8, "(null)");
|
||||
_do_strquote (NULL, 100, "(null)");
|
||||
|
||||
_do_strquote ("", 1, "");
|
||||
_do_strquote ("", 2, "^");
|
||||
_do_strquote ("", 3, "\"\"");
|
||||
_do_strquote ("", 4, "\"\"");
|
||||
_do_strquote ("", 5, "\"\"");
|
||||
_do_strquote ("", 100, "\"\"");
|
||||
|
||||
_do_strquote ("a", 1, "");
|
||||
_do_strquote ("a", 2, "^");
|
||||
_do_strquote ("a", 3, "\"^");
|
||||
_do_strquote ("a", 4, "\"a\"");
|
||||
_do_strquote ("a", 5, "\"a\"");
|
||||
_do_strquote ("a", 6, "\"a\"");
|
||||
_do_strquote ("a", 100, "\"a\"");
|
||||
|
||||
_do_strquote ("ab", 1, "");
|
||||
_do_strquote ("ab", 2, "^");
|
||||
_do_strquote ("ab", 3, "\"^");
|
||||
_do_strquote ("ab", 4, "\"a^");
|
||||
_do_strquote ("ab", 5, "\"ab\"");
|
||||
_do_strquote ("ab", 6, "\"ab\"");
|
||||
_do_strquote ("ab", 7, "\"ab\"");
|
||||
_do_strquote ("ab", 100, "\"ab\"");
|
||||
|
||||
_do_strquote ("abc", 1, "");
|
||||
_do_strquote ("abc", 2, "^");
|
||||
_do_strquote ("abc", 3, "\"^");
|
||||
_do_strquote ("abc", 4, "\"a^");
|
||||
_do_strquote ("abc", 5, "\"ab^");
|
||||
_do_strquote ("abc", 6, "\"abc\"");
|
||||
_do_strquote ("abc", 7, "\"abc\"");
|
||||
_do_strquote ("abc", 100, "\"abc\"");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define UUID_NIL "00000000-0000-0000-0000-000000000000"
|
||||
#define UUID_NS_DNS "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
|
||||
|
||||
|
|
@ -6366,6 +6448,7 @@ int main (int argc, char **argv)
|
|||
g_test_add_func ("/core/general/test_setting_user_data", test_setting_user_data);
|
||||
|
||||
g_test_add_func ("/core/general/hexstr2bin", test_hexstr2bin);
|
||||
g_test_add_func ("/core/general/nm_strquote", test_nm_strquote);
|
||||
g_test_add_func ("/core/general/test_nm_utils_uuid_generate_from_string", test_nm_utils_uuid_generate_from_string);
|
||||
g_test_add_func ("/core/general/_nm_utils_uuid_generate_from_strings", test_nm_utils_uuid_generate_from_strings);
|
||||
|
||||
|
|
|
|||
|
|
@ -115,6 +115,78 @@ nm_utils_strbuf_append (char **buf, gsize *len, const char *format, ...)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* nm_strquote:
|
||||
* @buf: the output buffer of where to write the quoted @str argument.
|
||||
* @buf_len: the size of @buf.
|
||||
* @str: (allow-none): the string to quote.
|
||||
*
|
||||
* Writes @str to @buf with quoting. The resulting buffer
|
||||
* is always NUL terminated, unless @buf_len is zero.
|
||||
* If @str is %NULL, it writes "(null)".
|
||||
*
|
||||
* If @str needs to be truncated, the closing quote is '^' instead
|
||||
* of '"'.
|
||||
*
|
||||
* This is similar to nm_strquote_a(), which however uses alloca()
|
||||
* to allocate a new buffer. Also, here @buf_len is the size of @buf,
|
||||
* while nm_strquote_a() has the number of characters to print. The latter
|
||||
* doesn't include the quoting.
|
||||
*
|
||||
* Returns: the input buffer with the quoted string. */
|
||||
const char *
|
||||
nm_strquote (char *buf, gsize buf_len, const char *str)
|
||||
{
|
||||
const char *const buf0 = buf;
|
||||
|
||||
if (!str) {
|
||||
nm_utils_strbuf_append_str (&buf, &buf_len, "(null)");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (G_UNLIKELY (buf_len <= 2)) {
|
||||
switch (buf_len) {
|
||||
case 2:
|
||||
*(buf++) = '^';
|
||||
/* fall-through*/
|
||||
case 1:
|
||||
*(buf++) = '\0';
|
||||
break;
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
|
||||
*(buf++) = '"';
|
||||
buf_len--;
|
||||
|
||||
nm_utils_strbuf_append_str (&buf, &buf_len, str);
|
||||
|
||||
/* if the string was too long we indicate truncation with a
|
||||
* '^' instead of a closing quote. */
|
||||
if (G_UNLIKELY (buf_len <= 1)) {
|
||||
switch (buf_len) {
|
||||
case 1:
|
||||
buf[-1] = '^';
|
||||
break;
|
||||
case 0:
|
||||
buf[-2] = '^';
|
||||
break;
|
||||
default:
|
||||
nm_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
nm_assert (buf_len >= 2);
|
||||
*(buf++) = '"';
|
||||
*(buf++) = '\0';
|
||||
}
|
||||
|
||||
out:
|
||||
return buf0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
char _nm_utils_to_string_buffer[];
|
||||
|
||||
void
|
||||
|
|
@ -257,41 +329,58 @@ nm_utils_ip_is_site_local (int addr_family,
|
|||
/*****************************************************************************/
|
||||
|
||||
gboolean
|
||||
nm_utils_parse_inaddr_bin (const char *text,
|
||||
int family,
|
||||
gpointer out_addr)
|
||||
nm_utils_parse_inaddr_bin (int addr_family,
|
||||
const char *text,
|
||||
gpointer out_addr)
|
||||
{
|
||||
NMIPAddr addrbin;
|
||||
|
||||
g_return_val_if_fail (text, FALSE);
|
||||
|
||||
if (family == AF_UNSPEC)
|
||||
family = strchr (text, ':') ? AF_INET6 : AF_INET;
|
||||
if (addr_family == AF_UNSPEC)
|
||||
addr_family = strchr (text, ':') ? AF_INET6 : AF_INET;
|
||||
else
|
||||
g_return_val_if_fail (NM_IN_SET (family, AF_INET, AF_INET6), FALSE);
|
||||
g_return_val_if_fail (NM_IN_SET (addr_family, AF_INET, AF_INET6), FALSE);
|
||||
|
||||
if (inet_pton (family, text, out_addr ?: &addrbin) != 1)
|
||||
/* use a temporary variable @addrbin, to guarantee that @out_addr
|
||||
* is only modified on success. */
|
||||
if (inet_pton (addr_family, text, &addrbin) != 1)
|
||||
return FALSE;
|
||||
|
||||
if (out_addr) {
|
||||
switch (addr_family) {
|
||||
case AF_INET:
|
||||
*((in_addr_t *) out_addr) = addrbin.addr4;
|
||||
break;
|
||||
case AF_INET6:
|
||||
*((struct in6_addr *) out_addr) = addrbin.addr6;
|
||||
break;
|
||||
default:
|
||||
nm_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_utils_parse_inaddr (const char *text,
|
||||
int family,
|
||||
nm_utils_parse_inaddr (int addr_family,
|
||||
const char *text,
|
||||
char **out_addr)
|
||||
{
|
||||
NMIPAddr addrbin;
|
||||
char addrstr_buf[MAX (INET_ADDRSTRLEN, INET6_ADDRSTRLEN)];
|
||||
|
||||
if (!nm_utils_parse_inaddr_bin (text, family, &addrbin))
|
||||
nm_assert (!out_addr || !*out_addr);
|
||||
|
||||
if (!nm_utils_parse_inaddr_bin (addr_family, text, &addrbin))
|
||||
return FALSE;
|
||||
NM_SET_OUT (out_addr, g_strdup (inet_ntop (family, &addrbin, addrstr_buf, sizeof (addrstr_buf))));
|
||||
NM_SET_OUT (out_addr, g_strdup (inet_ntop (addr_family, &addrbin, addrstr_buf, sizeof (addrstr_buf))));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_utils_parse_inaddr_prefix_bin (const char *text,
|
||||
int family,
|
||||
nm_utils_parse_inaddr_prefix_bin (int addr_family,
|
||||
const char *text,
|
||||
gpointer out_addr,
|
||||
int *out_prefix)
|
||||
{
|
||||
|
|
@ -304,12 +393,12 @@ nm_utils_parse_inaddr_prefix_bin (const char *text,
|
|||
|
||||
g_return_val_if_fail (text, FALSE);
|
||||
|
||||
if (family == AF_UNSPEC)
|
||||
family = strchr (text, ':') ? AF_INET6 : AF_INET;
|
||||
if (addr_family == AF_UNSPEC)
|
||||
addr_family = strchr (text, ':') ? AF_INET6 : AF_INET;
|
||||
|
||||
if (family == AF_INET)
|
||||
if (addr_family == AF_INET)
|
||||
addr_len = sizeof (in_addr_t);
|
||||
else if (family == AF_INET6)
|
||||
else if (addr_family == AF_INET6)
|
||||
addr_len = sizeof (struct in6_addr);
|
||||
else
|
||||
g_return_val_if_reached (FALSE);
|
||||
|
|
@ -320,13 +409,13 @@ nm_utils_parse_inaddr_prefix_bin (const char *text,
|
|||
else
|
||||
addrstr = text;
|
||||
|
||||
if (inet_pton (family, addrstr, &addrbin) != 1)
|
||||
if (inet_pton (addr_family, addrstr, &addrbin) != 1)
|
||||
return FALSE;
|
||||
|
||||
if (slash) {
|
||||
prefix = _nm_utils_ascii_str_to_int64 (slash + 1, 10,
|
||||
0,
|
||||
family == AF_INET ? 32 : 128,
|
||||
addr_family == AF_INET ? 32 : 128,
|
||||
-1);
|
||||
if (prefix == -1)
|
||||
return FALSE;
|
||||
|
|
@ -339,17 +428,17 @@ nm_utils_parse_inaddr_prefix_bin (const char *text,
|
|||
}
|
||||
|
||||
gboolean
|
||||
nm_utils_parse_inaddr_prefix (const char *text,
|
||||
int family,
|
||||
nm_utils_parse_inaddr_prefix (int addr_family,
|
||||
const char *text,
|
||||
char **out_addr,
|
||||
int *out_prefix)
|
||||
{
|
||||
NMIPAddr addrbin;
|
||||
char addrstr_buf[MAX (INET_ADDRSTRLEN, INET6_ADDRSTRLEN)];
|
||||
|
||||
if (!nm_utils_parse_inaddr_prefix_bin (text, family, &addrbin, out_prefix))
|
||||
if (!nm_utils_parse_inaddr_prefix_bin (addr_family, text, &addrbin, out_prefix))
|
||||
return FALSE;
|
||||
NM_SET_OUT (out_addr, g_strdup (inet_ntop (family, &addrbin, addrstr_buf, sizeof (addrstr_buf))));
|
||||
NM_SET_OUT (out_addr, g_strdup (inet_ntop (addr_family, &addrbin, addrstr_buf, sizeof (addrstr_buf))));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -166,6 +166,8 @@ void nm_utils_strbuf_append (char **buf, gsize *len, const char *format, ...) _n
|
|||
void nm_utils_strbuf_append_c (char **buf, gsize *len, char c);
|
||||
void nm_utils_strbuf_append_str (char **buf, gsize *len, const char *str);
|
||||
|
||||
const char *nm_strquote (char *buf, gsize buf_len, const char *str);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
const char **nm_utils_strsplit_set (const char *str, const char *delimiters);
|
||||
|
|
@ -187,21 +189,21 @@ gboolean nm_utils_ip_is_site_local (int addr_family,
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean nm_utils_parse_inaddr_bin (const char *text,
|
||||
int family,
|
||||
gboolean nm_utils_parse_inaddr_bin (int addr_family,
|
||||
const char *text,
|
||||
gpointer out_addr);
|
||||
|
||||
gboolean nm_utils_parse_inaddr (const char *text,
|
||||
int family,
|
||||
gboolean nm_utils_parse_inaddr (int addr_family,
|
||||
const char *text,
|
||||
char **out_addr);
|
||||
|
||||
gboolean nm_utils_parse_inaddr_prefix_bin (const char *text,
|
||||
int family,
|
||||
gboolean nm_utils_parse_inaddr_prefix_bin (int addr_family,
|
||||
const char *text,
|
||||
gpointer out_addr,
|
||||
int *out_prefix);
|
||||
|
||||
gboolean nm_utils_parse_inaddr_prefix (const char *text,
|
||||
int family,
|
||||
gboolean nm_utils_parse_inaddr_prefix (int addr_family,
|
||||
const char *text,
|
||||
char **out_addr,
|
||||
int *out_prefix);
|
||||
|
||||
|
|
|
|||
|
|
@ -504,7 +504,6 @@ static gboolean nm_device_set_ip4_config (NMDevice *self,
|
|||
gboolean commit,
|
||||
GPtrArray *ip4_dev_route_blacklist);
|
||||
static gboolean ip4_config_merge_and_apply (NMDevice *self,
|
||||
NMIP4Config *config,
|
||||
gboolean commit);
|
||||
|
||||
static gboolean nm_device_set_ip6_config (NMDevice *self,
|
||||
|
|
@ -1586,23 +1585,14 @@ nm_device_get_metered (NMDevice *self)
|
|||
return NM_DEVICE_GET_PRIVATE (self)->metered;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_device_get_priority():
|
||||
* @self: the #NMDevice
|
||||
*
|
||||
* Returns: the device's routing priority. Lower numbers means a "better"
|
||||
* device, eg higher priority.
|
||||
*/
|
||||
int
|
||||
nm_device_get_priority (NMDevice *self)
|
||||
static guint32
|
||||
_get_route_metric_default (NMDevice *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DEVICE (self), 1000);
|
||||
|
||||
/* Device 'priority' is used for the default route-metric and is based on
|
||||
* the device type. The settings ipv4.route-metric and ipv6.route-metric
|
||||
* can overwrite this default.
|
||||
*
|
||||
* Currently for both IPv4 and IPv6 we use the same default values.
|
||||
* For both IPv4 and IPv6 we use the same default values.
|
||||
*
|
||||
* The route-metric is used for the metric of the routes of device.
|
||||
* This also applies to the default route. Therefore it affects also
|
||||
|
|
@ -1689,8 +1679,8 @@ route_metric_with_penalty (NMDevice *self, guint32 metric)
|
|||
}
|
||||
|
||||
guint32
|
||||
nm_device_get_ip_route_metric (NMDevice *self,
|
||||
int addr_family)
|
||||
nm_device_get_route_metric (NMDevice *self,
|
||||
int addr_family)
|
||||
{
|
||||
char *value;
|
||||
gint64 route_metric;
|
||||
|
|
@ -1729,7 +1719,7 @@ nm_device_get_ip_route_metric (NMDevice *self,
|
|||
if (route_metric >= 0)
|
||||
goto out;
|
||||
}
|
||||
route_metric = nm_device_get_priority (self);
|
||||
route_metric = _get_route_metric_default (self);
|
||||
out:
|
||||
return nm_utils_ip_route_metric_normalize (addr_family, route_metric);
|
||||
}
|
||||
|
|
@ -1938,7 +1928,7 @@ update_connectivity_state (NMDevice *self, NMConnectivityState state)
|
|||
if ( priv->state == NM_DEVICE_STATE_ACTIVATED
|
||||
&& !nm_device_sys_iface_state_is_external (self)) {
|
||||
if ( nm_device_get_best_default_route (self, AF_INET)
|
||||
&& !ip4_config_merge_and_apply (self, NULL, TRUE))
|
||||
&& !ip4_config_merge_and_apply (self, TRUE))
|
||||
_LOGW (LOGD_IP4, "Failed to update IPv4 route metric");
|
||||
if ( nm_device_get_best_default_route (self, AF_INET6)
|
||||
&& !ip6_config_merge_and_apply (self, TRUE))
|
||||
|
|
@ -2742,7 +2732,7 @@ device_link_changed (NMDevice *self)
|
|||
/* the link was down and just came up. That happens for example, while changing MTU.
|
||||
* We must restore IP configuration. */
|
||||
if (priv->ip4_state == IP_DONE) {
|
||||
if (!ip4_config_merge_and_apply (self, NULL, TRUE))
|
||||
if (!ip4_config_merge_and_apply (self, TRUE))
|
||||
_LOGW (LOGD_IP4, "failed applying IP4 config after link comes up again");
|
||||
}
|
||||
if (priv->ip6_state == IP_DONE) {
|
||||
|
|
@ -5501,7 +5491,7 @@ ipv4ll_get_ip4_config (NMDevice *self, guint32 lla)
|
|||
route.network = htonl (0xE0000000L);
|
||||
route.plen = 4;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_IP4LL;
|
||||
route.metric = nm_device_get_ip4_route_metric (self);
|
||||
route.metric = nm_device_get_route_metric (self, AF_INET);
|
||||
nm_ip4_config_add_route (config, &route, NULL);
|
||||
|
||||
return config;
|
||||
|
|
@ -5558,7 +5548,9 @@ nm_device_handle_ipv4ll_event (sd_ipv4ll *ll, int event, void *data)
|
|||
nm_clear_g_source (&priv->ipv4ll_timeout);
|
||||
nm_device_activate_schedule_ip4_config_result (self, config);
|
||||
} else if (priv->ip4_state == IP_DONE) {
|
||||
if (!ip4_config_merge_and_apply (self, config, TRUE)) {
|
||||
g_clear_object (&priv->dev_ip4_config);
|
||||
priv->dev_ip4_config = g_object_ref (config);
|
||||
if (!ip4_config_merge_and_apply (self, TRUE)) {
|
||||
_LOGE (LOGD_AUTOIP4, "failed to update IP4 config for autoip change.");
|
||||
nm_device_ip_method_failed (self, AF_INET, NM_DEVICE_STATE_REASON_AUTOIP_FAILED);
|
||||
}
|
||||
|
|
@ -5669,7 +5661,7 @@ ensure_con_ip4_config (NMDevice *self)
|
|||
priv->con_ip4_config = _ip4_config_new (self);
|
||||
nm_ip4_config_merge_setting (priv->con_ip4_config,
|
||||
nm_connection_get_setting_ip4_config (connection),
|
||||
nm_device_get_ip4_route_metric (self));
|
||||
nm_device_get_route_metric (self, AF_INET));
|
||||
|
||||
if (nm_device_sys_iface_state_is_external_or_assume (self)) {
|
||||
/* For assumed connections ignore all addresses and routes. */
|
||||
|
|
@ -5694,7 +5686,7 @@ ensure_con_ip6_config (NMDevice *self)
|
|||
priv->con_ip6_config = _ip6_config_new (self);
|
||||
nm_ip6_config_merge_setting (priv->con_ip6_config,
|
||||
nm_connection_get_setting_ip6_config (connection),
|
||||
nm_device_get_ip6_route_metric (self));
|
||||
nm_device_get_route_metric (self, AF_INET6));
|
||||
|
||||
if (nm_device_sys_iface_state_is_external_or_assume (self)) {
|
||||
/* For assumed connections ignore all addresses and routes. */
|
||||
|
|
@ -5735,14 +5727,13 @@ dhcp4_cleanup (NMDevice *self, CleanupType cleanup_type, gboolean release)
|
|||
|
||||
static gboolean
|
||||
ip4_config_merge_and_apply (NMDevice *self,
|
||||
NMIP4Config *config,
|
||||
gboolean commit)
|
||||
{
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
NMConnection *connection;
|
||||
gboolean success;
|
||||
NMIP4Config *composite;
|
||||
const guint32 default_route_metric = nm_device_get_ip4_route_metric (self);
|
||||
const guint32 default_route_metric = nm_device_get_route_metric (self, AF_INET);
|
||||
guint32 gateway;
|
||||
gboolean connection_has_default_route, connection_is_never_default;
|
||||
gboolean ignore_auto_routes = FALSE;
|
||||
|
|
@ -5752,12 +5743,6 @@ ip4_config_merge_and_apply (NMDevice *self,
|
|||
gs_unref_ptrarray GPtrArray *ip4_dev_route_blacklist = NULL;
|
||||
gboolean add_default_route = TRUE;
|
||||
|
||||
/* Merge all the configs into the composite config */
|
||||
if (config) {
|
||||
g_clear_object (&priv->dev_ip4_config);
|
||||
priv->dev_ip4_config = g_object_ref (config);
|
||||
}
|
||||
|
||||
/* Apply ignore-auto-routes and ignore-auto-dns settings */
|
||||
connection = nm_device_get_applied_connection (self);
|
||||
if (connection) {
|
||||
|
|
@ -5894,9 +5879,14 @@ END_ADD_DEFAULT_ROUTE:
|
|||
static gboolean
|
||||
dhcp4_lease_change (NMDevice *self, NMIP4Config *config)
|
||||
{
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
|
||||
g_return_val_if_fail (config, FALSE);
|
||||
|
||||
if (!ip4_config_merge_and_apply (self, config, TRUE)) {
|
||||
g_clear_object (&priv->dev_ip4_config);
|
||||
priv->dev_ip4_config = g_object_ref (config);
|
||||
|
||||
if (!ip4_config_merge_and_apply (self, TRUE)) {
|
||||
_LOGW (LOGD_DHCP4, "failed to update IPv4 config for DHCP change.");
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -6017,7 +6007,7 @@ dhcp4_state_changed (NMDhcpClient *client,
|
|||
manual = _ip4_config_new (self);
|
||||
nm_ip4_config_merge_setting (manual,
|
||||
nm_connection_get_setting_ip4_config (connection),
|
||||
nm_device_get_ip4_route_metric (self));
|
||||
nm_device_get_route_metric (self, AF_INET));
|
||||
|
||||
configs = g_new0 (NMIP4Config *, 3);
|
||||
configs[0] = manual;
|
||||
|
|
@ -6124,7 +6114,7 @@ dhcp4_start (NMDevice *self)
|
|||
nm_device_get_ip_ifindex (self),
|
||||
tmp,
|
||||
nm_connection_get_uuid (connection),
|
||||
nm_device_get_ip4_route_metric (self),
|
||||
nm_device_get_route_metric (self, AF_INET),
|
||||
nm_setting_ip_config_get_dhcp_send_hostname (s_ip4),
|
||||
nm_setting_ip_config_get_dhcp_hostname (s_ip4),
|
||||
nm_setting_ip4_config_get_dhcp_fqdn (NM_SETTING_IP4_CONFIG (s_ip4)),
|
||||
|
|
@ -6387,7 +6377,7 @@ act_stage3_ip4_config_start (NMDevice *self,
|
|||
config = _ip4_config_new (self);
|
||||
nm_ip4_config_merge_setting (config,
|
||||
nm_connection_get_setting_ip4_config (connection),
|
||||
nm_device_get_ip4_route_metric (self));
|
||||
nm_device_get_route_metric (self, AF_INET));
|
||||
|
||||
configs = g_new0 (NMIP4Config *, 2);
|
||||
configs[0] = config;
|
||||
|
|
@ -6453,7 +6443,7 @@ ip6_config_merge_and_apply (NMDevice *self,
|
|||
NMConnection *connection;
|
||||
gboolean success;
|
||||
NMIP6Config *composite;
|
||||
const guint32 default_route_metric = nm_device_get_ip6_route_metric (self);
|
||||
const guint32 default_route_metric = nm_device_get_route_metric (self, AF_INET6);
|
||||
const struct in6_addr *gateway;
|
||||
gboolean connection_has_default_route, connection_is_never_default;
|
||||
gboolean ignore_auto_routes = FALSE;
|
||||
|
|
@ -6890,7 +6880,7 @@ dhcp6_start_with_link_ready (NMDevice *self, NMConnection *connection)
|
|||
tmp,
|
||||
&ll_addr->address,
|
||||
nm_connection_get_uuid (connection),
|
||||
nm_device_get_ip6_route_metric (self),
|
||||
nm_device_get_route_metric (self, AF_INET6),
|
||||
nm_setting_ip_config_get_dhcp_send_hostname (s_ip6),
|
||||
nm_setting_ip_config_get_dhcp_hostname (s_ip6),
|
||||
get_dhcp_timeout (self, AF_INET6),
|
||||
|
|
@ -7484,7 +7474,7 @@ ndisc_config_changed (NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_in
|
|||
nm_ip6_config_reset_routes_ndisc (priv->ac_ip6_config,
|
||||
rdata->routes,
|
||||
rdata->routes_n,
|
||||
nm_device_get_ip6_route_metric (self));
|
||||
nm_device_get_route_metric (self, AF_INET6));
|
||||
}
|
||||
|
||||
if (changed & NM_NDISC_CONFIG_DNS_SERVERS) {
|
||||
|
|
@ -8560,7 +8550,7 @@ activate_stage5_ip4_config_result (NMDevice *self)
|
|||
}
|
||||
|
||||
/* NULL to use the existing priv->dev_ip4_config */
|
||||
if (!ip4_config_merge_and_apply (self, NULL, TRUE)) {
|
||||
if (!ip4_config_merge_and_apply (self, TRUE)) {
|
||||
_LOGD (LOGD_DEVICE | LOGD_IP4, "Activation: Stage 5 of 5 (IPv4 Commit) failed");
|
||||
nm_device_ip_method_failed (self, AF_INET, NM_DEVICE_STATE_REASON_CONFIG_FAILED);
|
||||
return;
|
||||
|
|
@ -9094,7 +9084,7 @@ nm_device_reactivate_ip4_config (NMDevice *self,
|
|||
priv->con_ip4_config = _ip4_config_new (self);
|
||||
nm_ip4_config_merge_setting (priv->con_ip4_config,
|
||||
s_ip4_new,
|
||||
nm_device_get_ip4_route_metric (self));
|
||||
nm_device_get_route_metric (self, AF_INET));
|
||||
|
||||
if (!force_restart) {
|
||||
method_old = s_ip4_old
|
||||
|
|
@ -9112,7 +9102,7 @@ nm_device_reactivate_ip4_config (NMDevice *self,
|
|||
if (!nm_device_activate_stage3_ip4_start (self))
|
||||
_LOGW (LOGD_IP4, "Failed to apply IPv4 configuration");
|
||||
} else {
|
||||
if (!ip4_config_merge_and_apply (self, NULL, TRUE))
|
||||
if (!ip4_config_merge_and_apply (self, TRUE))
|
||||
_LOGW (LOGD_IP4, "Failed to reapply IPv4 configuration");
|
||||
}
|
||||
}
|
||||
|
|
@ -9136,7 +9126,7 @@ nm_device_reactivate_ip6_config (NMDevice *self,
|
|||
priv->con_ip6_config = _ip6_config_new (self);
|
||||
nm_ip6_config_merge_setting (priv->con_ip6_config,
|
||||
s_ip6_new,
|
||||
nm_device_get_ip6_route_metric (self));
|
||||
nm_device_get_route_metric (self, AF_INET6));
|
||||
|
||||
if (!force_restart) {
|
||||
method_old = s_ip6_old
|
||||
|
|
@ -10193,7 +10183,7 @@ nm_device_replace_vpn4_config (NMDevice *self, NMIP4Config *old, NMIP4Config *co
|
|||
return;
|
||||
|
||||
/* NULL to use existing configs */
|
||||
if (!ip4_config_merge_and_apply (self, NULL, TRUE))
|
||||
if (!ip4_config_merge_and_apply (self, TRUE))
|
||||
_LOGW (LOGD_IP4, "failed to set VPN routes for device");
|
||||
}
|
||||
|
||||
|
|
@ -10210,7 +10200,7 @@ nm_device_set_wwan_ip4_config (NMDevice *self, NMIP4Config *config)
|
|||
priv->wwan_ip4_config = g_object_ref (config);
|
||||
|
||||
/* NULL to use existing configs */
|
||||
if (!ip4_config_merge_and_apply (self, NULL, TRUE))
|
||||
if (!ip4_config_merge_and_apply (self, TRUE))
|
||||
_LOGW (LOGD_IP4, "failed to set WWAN IPv4 configuration");
|
||||
}
|
||||
|
||||
|
|
@ -10734,7 +10724,7 @@ nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware)
|
|||
|
||||
/* when the link comes up, we must restore IP configuration if necessary. */
|
||||
if (priv->ip4_state == IP_DONE) {
|
||||
if (!ip4_config_merge_and_apply (self, NULL, TRUE))
|
||||
if (!ip4_config_merge_and_apply (self, TRUE))
|
||||
_LOGW (LOGD_IP4, "failed applying IP4 config after bringing link up");
|
||||
}
|
||||
if (priv->ip6_state == IP_DONE) {
|
||||
|
|
@ -10822,7 +10812,7 @@ find_ip4_lease_config (NMDevice *self,
|
|||
ip_iface,
|
||||
ip_ifindex,
|
||||
nm_connection_get_uuid (connection),
|
||||
nm_device_get_ip4_route_metric (self));
|
||||
nm_device_get_route_metric (self, AF_INET));
|
||||
for (liter = leases; liter && !found; liter = liter->next) {
|
||||
NMIP4Config *lease_config = liter->data;
|
||||
const NMPlatformIP4Address *address = nm_ip4_config_get_first_address (lease_config);
|
||||
|
|
@ -11044,7 +11034,7 @@ update_ip_config (NMDevice *self, int addr_family, gboolean initial)
|
|||
if (update_ext_ip_config (self, addr_family, initial, TRUE)) {
|
||||
if (addr_family == AF_INET) {
|
||||
if (priv->ext_ip4_config)
|
||||
ip4_config_merge_and_apply (self, NULL, FALSE);
|
||||
ip4_config_merge_and_apply (self, FALSE);
|
||||
} else {
|
||||
if (priv->ext_ip6_config_captured)
|
||||
ip6_config_merge_and_apply (self, FALSE);
|
||||
|
|
@ -12597,7 +12587,7 @@ nm_device_spawn_iface_helper (NMDevice *self)
|
|||
g_assert (s_ip4);
|
||||
|
||||
g_ptr_array_add (argv, g_strdup ("--priority4"));
|
||||
g_ptr_array_add (argv, g_strdup_printf ("%u", nm_device_get_ip4_route_metric (self)));
|
||||
g_ptr_array_add (argv, g_strdup_printf ("%u", nm_device_get_route_metric (self, AF_INET)));
|
||||
|
||||
g_ptr_array_add (argv, g_strdup ("--dhcp4"));
|
||||
g_ptr_array_add (argv, g_strdup (dhcp4_address));
|
||||
|
|
@ -12639,7 +12629,7 @@ nm_device_spawn_iface_helper (NMDevice *self)
|
|||
g_assert (s_ip6);
|
||||
|
||||
g_ptr_array_add (argv, g_strdup ("--priority6"));
|
||||
g_ptr_array_add (argv, g_strdup_printf ("%u", nm_device_get_ip6_route_metric (self)));
|
||||
g_ptr_array_add (argv, g_strdup_printf ("%u", nm_device_get_route_metric (self, AF_INET6)));
|
||||
|
||||
g_ptr_array_add (argv, g_strdup ("--slaac"));
|
||||
|
||||
|
|
|
|||
|
|
@ -447,21 +447,7 @@ NMDeviceType nm_device_get_device_type (NMDevice *dev);
|
|||
NMLinkType nm_device_get_link_type (NMDevice *dev);
|
||||
NMMetered nm_device_get_metered (NMDevice *dev);
|
||||
|
||||
int nm_device_get_priority (NMDevice *dev);
|
||||
|
||||
guint32 nm_device_get_ip_route_metric (NMDevice *dev, int addr_family);
|
||||
|
||||
static inline guint32
|
||||
nm_device_get_ip4_route_metric (NMDevice *self)
|
||||
{
|
||||
return nm_device_get_ip_route_metric (self, AF_INET);
|
||||
}
|
||||
|
||||
static inline guint32
|
||||
nm_device_get_ip6_route_metric (NMDevice *self)
|
||||
{
|
||||
return nm_device_get_ip_route_metric (self, AF_INET6);
|
||||
}
|
||||
guint32 nm_device_get_route_metric (NMDevice *dev, int addr_family);
|
||||
|
||||
const char * nm_device_get_hw_address (NMDevice *dev);
|
||||
const char * nm_device_get_permanent_hw_address (NMDevice *self);
|
||||
|
|
|
|||
|
|
@ -90,6 +90,9 @@ typedef struct {
|
|||
MMBearerIpConfig *ipv4_config;
|
||||
MMBearerIpConfig *ipv6_config;
|
||||
|
||||
guint idle_id_ip4;
|
||||
guint idle_id_ip6;
|
||||
|
||||
guint32 pin_tries;
|
||||
} NMModemBroadbandPrivate;
|
||||
|
||||
|
|
@ -859,21 +862,6 @@ set_mm_enabled (NMModem *_self,
|
|||
/*****************************************************************************/
|
||||
/* IPv4 method static */
|
||||
|
||||
static gboolean
|
||||
ip4_string_to_num (const gchar *str, guint32 *out)
|
||||
{
|
||||
guint32 addr = 0;
|
||||
gboolean success = FALSE;
|
||||
|
||||
if (!str || inet_pton (AF_INET, str, &addr) != 1)
|
||||
addr = 0;
|
||||
else
|
||||
success = TRUE;
|
||||
|
||||
*out = (guint32)addr;
|
||||
return success;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static_stage3_ip4_done (NMModemBroadband *self)
|
||||
{
|
||||
|
|
@ -883,7 +871,7 @@ static_stage3_ip4_done (NMModemBroadband *self)
|
|||
const gchar *address_string;
|
||||
const gchar *gw_string;
|
||||
guint32 address_network;
|
||||
guint32 gw;
|
||||
guint32 gw = 0;
|
||||
NMPlatformIP4Address address;
|
||||
const gchar **dns;
|
||||
guint i;
|
||||
|
|
@ -895,7 +883,7 @@ static_stage3_ip4_done (NMModemBroadband *self)
|
|||
|
||||
/* Fully fail if invalid IP address retrieved */
|
||||
address_string = mm_bearer_ip_config_get_address (self->_priv.ipv4_config);
|
||||
if (!ip4_string_to_num (address_string, &address_network)) {
|
||||
if (!nm_utils_parse_inaddr_bin (AF_INET, address_string, &address_network)) {
|
||||
error = g_error_new (NM_DEVICE_ERROR,
|
||||
NM_DEVICE_ERROR_INVALID_CONNECTION,
|
||||
"(%s) retrieving IP4 configuration failed: invalid address given '%s'",
|
||||
|
|
@ -906,7 +894,7 @@ static_stage3_ip4_done (NMModemBroadband *self)
|
|||
|
||||
/* Missing gateway not a hard failure */
|
||||
gw_string = mm_bearer_ip_config_get_gateway (self->_priv.ipv4_config);
|
||||
ip4_string_to_num (gw_string, &gw);
|
||||
nm_utils_parse_inaddr_bin (AF_INET, gw_string, &gw);
|
||||
|
||||
data_port = mm_bearer_get_interface (self->_priv.bearer);
|
||||
g_assert (data_port);
|
||||
|
|
@ -931,7 +919,7 @@ static_stage3_ip4_done (NMModemBroadband *self)
|
|||
/* DNS servers */
|
||||
dns = mm_bearer_ip_config_get_dns (self->_priv.ipv4_config);
|
||||
for (i = 0; dns && dns[i]; i++) {
|
||||
if ( ip4_string_to_num (dns[i], &address_network)
|
||||
if ( nm_utils_parse_inaddr_bin (AF_INET, dns[i], &address_network)
|
||||
&& address_network > 0) {
|
||||
nm_ip4_config_add_nameserver (config, address_network);
|
||||
_LOGI (" DNS %s", dns[i]);
|
||||
|
|
@ -945,15 +933,17 @@ out:
|
|||
}
|
||||
|
||||
static NMActStageReturn
|
||||
static_stage3_ip4_config_start (NMModem *_self,
|
||||
static_stage3_ip4_config_start (NMModem *modem,
|
||||
NMActRequest *req,
|
||||
NMDeviceStateReason *out_failure_reason)
|
||||
{
|
||||
NMModemBroadband *self = NM_MODEM_BROADBAND (_self);
|
||||
NMModemBroadband *self = NM_MODEM_BROADBAND (modem);
|
||||
NMModemBroadbandPrivate *priv = NM_MODEM_BROADBAND_GET_PRIVATE (self);
|
||||
|
||||
/* We schedule it in an idle just to follow the same logic as in the
|
||||
* generic modem implementation. */
|
||||
g_idle_add ((GSourceFunc) static_stage3_ip4_done, self);
|
||||
nm_clear_g_source (&priv->idle_id_ip4);
|
||||
priv->idle_id_ip4 = g_idle_add ((GSourceFunc) static_stage3_ip4_done, self);
|
||||
|
||||
return NM_ACT_STAGE_RETURN_POSTPONE;
|
||||
}
|
||||
|
|
@ -1054,13 +1044,15 @@ out:
|
|||
}
|
||||
|
||||
static NMActStageReturn
|
||||
stage3_ip6_config_request (NMModem *_self, NMDeviceStateReason *out_failure_reason)
|
||||
stage3_ip6_config_request (NMModem *modem, NMDeviceStateReason *out_failure_reason)
|
||||
{
|
||||
NMModemBroadband *self = NM_MODEM_BROADBAND (_self);
|
||||
NMModemBroadband *self = NM_MODEM_BROADBAND (modem);
|
||||
NMModemBroadbandPrivate *priv = NM_MODEM_BROADBAND_GET_PRIVATE (self);
|
||||
|
||||
/* We schedule it in an idle just to follow the same logic as in the
|
||||
* generic modem implementation. */
|
||||
g_idle_add ((GSourceFunc) stage3_ip6_done, self);
|
||||
nm_clear_g_source (&priv->idle_id_ip6);
|
||||
priv->idle_id_ip6 = g_idle_add ((GSourceFunc) stage3_ip6_done, self);
|
||||
|
||||
return NM_ACT_STAGE_RETURN_POSTPONE;
|
||||
}
|
||||
|
|
@ -1411,6 +1403,10 @@ static void
|
|||
dispose (GObject *object)
|
||||
{
|
||||
NMModemBroadband *self = NM_MODEM_BROADBAND (object);
|
||||
NMModemBroadbandPrivate *priv = NM_MODEM_BROADBAND_GET_PRIVATE (self);
|
||||
|
||||
nm_clear_g_source (&priv->idle_id_ip4);
|
||||
nm_clear_g_source (&priv->idle_id_ip6);
|
||||
|
||||
connect_context_clear (self);
|
||||
g_clear_object (&self->_priv.ipv4_config);
|
||||
|
|
|
|||
|
|
@ -104,22 +104,6 @@ G_DEFINE_TYPE (NMModemOfono, nm_modem_ofono, NM_TYPE_MODEM)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
ip_string_to_network_address (const gchar *str,
|
||||
guint32 *out)
|
||||
{
|
||||
guint32 addr = 0;
|
||||
gboolean success = FALSE;
|
||||
|
||||
if (!str || inet_pton (AF_INET, str, &addr) != 1)
|
||||
addr = 0;
|
||||
else
|
||||
success = TRUE;
|
||||
|
||||
*out = (guint32)addr;
|
||||
return success;
|
||||
}
|
||||
|
||||
static void
|
||||
get_capabilities (NMModem *_self,
|
||||
NMDeviceModemCapabilities *modem_caps,
|
||||
|
|
@ -907,6 +891,9 @@ context_property_changed (GDBusProxy *proxy,
|
|||
* 'Interface'.
|
||||
*
|
||||
* This needs discussion with upstream.
|
||||
*
|
||||
* FIXME: it is no longer allowed to omit the ifindex for NMIP4Config instances.
|
||||
* This is broken.
|
||||
*/
|
||||
priv->ip4_config = nm_ip4_config_new (nm_platform_get_multi_idx (NM_PLATFORM_GET),
|
||||
0);
|
||||
|
|
@ -916,7 +903,8 @@ context_property_changed (GDBusProxy *proxy,
|
|||
if (g_variant_lookup (v_dict, "Address", "&s", &addr_s)) {
|
||||
_LOGD ("Address: %s", addr_s);
|
||||
|
||||
if (ip_string_to_network_address (addr_s, &address_network)) {
|
||||
if ( addr_s
|
||||
&& nm_utils_parse_inaddr_bin (AF_INET, addr_s, &address_network)) {
|
||||
addr.address = address_network;
|
||||
addr.addr_source = NM_IP_CONFIG_SOURCE_WWAN;
|
||||
} else {
|
||||
|
|
@ -932,7 +920,8 @@ context_property_changed (GDBusProxy *proxy,
|
|||
if (g_variant_lookup (v_dict, "Netmask", "&s", &s)) {
|
||||
_LOGD ("Netmask: %s", s);
|
||||
|
||||
if (s && ip_string_to_network_address (s, &address_network)) {
|
||||
if ( s
|
||||
&& nm_utils_parse_inaddr_bin (AF_INET, s, &address_network)) {
|
||||
prefix = nm_utils_ip4_netmask_to_prefix (address_network);
|
||||
if (prefix > 0)
|
||||
addr.plen = prefix;
|
||||
|
|
@ -950,7 +939,8 @@ context_property_changed (GDBusProxy *proxy,
|
|||
nm_ip4_config_add_address (priv->ip4_config, &addr);
|
||||
|
||||
if (g_variant_lookup (v_dict, "Gateway", "&s", &s)) {
|
||||
if (s && ip_string_to_network_address (s, &gateway_network)) {
|
||||
if ( s
|
||||
&& nm_utils_parse_inaddr_bin (AF_INET, s, &gateway_network)) {
|
||||
_LOGI ("Gateway: %s", s);
|
||||
nm_ip4_config_set_gateway (priv->ip4_config, gateway_network);
|
||||
} else {
|
||||
|
|
@ -966,7 +956,8 @@ context_property_changed (GDBusProxy *proxy,
|
|||
if (g_variant_lookup (v_dict, "DomainNameServers", "^a&s", &array)) {
|
||||
if (array) {
|
||||
for (iter = array; *iter; iter++) {
|
||||
if (ip_string_to_network_address (*iter, &address_network) && address_network > 0) {
|
||||
if ( nm_utils_parse_inaddr_bin (AF_INET, *iter, &address_network)
|
||||
&& address_network) {
|
||||
_LOGI ("DNS: %s", *iter);
|
||||
nm_ip4_config_add_nameserver (priv->ip4_config, address_network);
|
||||
} else {
|
||||
|
|
@ -988,7 +979,8 @@ context_property_changed (GDBusProxy *proxy,
|
|||
|
||||
if (g_variant_lookup (v_dict, "MessageProxy", "&s", &s)) {
|
||||
_LOGI ("MessageProxy: %s", s);
|
||||
if (s && ip_string_to_network_address (s, &address_network)) {
|
||||
if ( s
|
||||
&& nm_utils_parse_inaddr_bin (AF_INET, s, &address_network)) {
|
||||
NMPlatformIP4Route mms_route;
|
||||
|
||||
mms_route.network = address_network;
|
||||
|
|
|
|||
|
|
@ -106,6 +106,46 @@ G_DEFINE_TYPE (NMModem, nm_modem, G_TYPE_OBJECT)
|
|||
|
||||
#define NM_MODEM_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR (self, NMModem, NM_IS_MODEM)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _NMLOG_PREFIX_BUFLEN 64
|
||||
#define _NMLOG_PREFIX_NAME "modem"
|
||||
#define _NMLOG_DOMAIN LOGD_MB
|
||||
|
||||
static const char *
|
||||
_nmlog_prefix (char *prefix, NMModem *self)
|
||||
{
|
||||
const char *uuid;
|
||||
int c;
|
||||
|
||||
if (!self)
|
||||
return "";
|
||||
|
||||
uuid = nm_modem_get_uid (self);
|
||||
|
||||
if (uuid) {
|
||||
char pp[_NMLOG_PREFIX_BUFLEN - 5];
|
||||
|
||||
c = g_snprintf (prefix, _NMLOG_PREFIX_BUFLEN, "[%s]",
|
||||
nm_strquote (pp, sizeof (pp), uuid));
|
||||
} else
|
||||
c = g_snprintf (prefix, _NMLOG_PREFIX_BUFLEN, "[%p]", self);
|
||||
nm_assert (c < _NMLOG_PREFIX_BUFLEN);
|
||||
|
||||
return prefix;
|
||||
}
|
||||
|
||||
#define _NMLOG(level, ...) \
|
||||
G_STMT_START { \
|
||||
char _prefix[_NMLOG_PREFIX_BUFLEN]; \
|
||||
\
|
||||
nm_log ((level), _NMLOG_DOMAIN, NULL, NULL, \
|
||||
"%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
|
||||
_NMLOG_PREFIX_NAME, \
|
||||
_nmlog_prefix (_prefix, (self)) \
|
||||
_NM_UTILS_MACRO_REST (__VA_ARGS__)); \
|
||||
} G_STMT_END
|
||||
|
||||
/*****************************************************************************/
|
||||
/* State/enabled/connected */
|
||||
|
||||
|
|
@ -150,11 +190,10 @@ nm_modem_set_state (NMModem *self,
|
|||
priv->prev_state = NM_MODEM_STATE_UNKNOWN;
|
||||
|
||||
if (new_state != old_state) {
|
||||
nm_log_info (LOGD_MB, "(%s): modem state changed, '%s' --> '%s' (reason: %s)\n",
|
||||
nm_modem_get_uid (self),
|
||||
nm_modem_state_to_string (old_state),
|
||||
nm_modem_state_to_string (new_state),
|
||||
reason ? reason : "none");
|
||||
_LOGI ("modem state changed, '%s' --> '%s' (reason: %s)",
|
||||
nm_modem_state_to_string (old_state),
|
||||
nm_modem_state_to_string (new_state),
|
||||
reason ? reason : "none");
|
||||
|
||||
priv->state = new_state;
|
||||
_notify (self, PROP_STATE);
|
||||
|
|
@ -180,24 +219,20 @@ nm_modem_set_mm_enabled (NMModem *self,
|
|||
NMModemState prev_state = priv->state;
|
||||
|
||||
if (enabled && priv->state >= NM_MODEM_STATE_ENABLING) {
|
||||
nm_log_dbg (LOGD_MB, "(%s): cannot enable modem: already enabled",
|
||||
nm_modem_get_uid (self));
|
||||
_LOGD ("cannot enable modem: already enabled");
|
||||
return;
|
||||
}
|
||||
if (!enabled && priv->state <= NM_MODEM_STATE_DISABLING) {
|
||||
nm_log_dbg (LOGD_MB, "(%s): cannot disable modem: already disabled",
|
||||
nm_modem_get_uid (self));
|
||||
_LOGD ("cannot disable modem: already disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
if (priv->state <= NM_MODEM_STATE_INITIALIZING) {
|
||||
nm_log_dbg (LOGD_MB, "(%s): cannot enable/disable modem: initializing or failed",
|
||||
nm_modem_get_uid (self));
|
||||
_LOGD ("cannot enable/disable modem: initializing or failed");
|
||||
return;
|
||||
} else if (priv->state == NM_MODEM_STATE_LOCKED) {
|
||||
/* Don't try to enable if the modem is locked since that will fail */
|
||||
nm_log_warn (LOGD_MB, "(%s): cannot enable/disable modem: locked",
|
||||
nm_modem_get_uid (self));
|
||||
_LOGW ("cannot enable/disable modem: locked");
|
||||
|
||||
/* Try to unlock the modem if it's being enabled */
|
||||
if (enabled)
|
||||
|
|
@ -467,7 +502,7 @@ ppp_ip4_config (NMPPPManager *ppp_manager,
|
|||
}
|
||||
|
||||
if (!num || dns_workaround) {
|
||||
nm_log_warn (LOGD_PPP, "compensating for invalid PPP-provided nameservers");
|
||||
_LOGW ("compensating for invalid PPP-provided nameservers");
|
||||
nm_ip4_config_reset_nameservers (config);
|
||||
nm_ip4_config_add_nameserver (config, good_dns1);
|
||||
nm_ip4_config_add_nameserver (config, good_dns2);
|
||||
|
|
@ -560,9 +595,8 @@ ppp_stage3_ip_config_start (NMModem *self,
|
|||
/* Check if ModemManager requested a specific IP timeout to be used. If 0 reported,
|
||||
* use the default one (30s) */
|
||||
if (priv->mm_ip_timeout > 0) {
|
||||
nm_log_info (LOGD_PPP, "(%s): using modem-specified IP timeout: %u seconds",
|
||||
nm_modem_get_uid (self),
|
||||
priv->mm_ip_timeout);
|
||||
_LOGI ("using modem-specified IP timeout: %u seconds",
|
||||
priv->mm_ip_timeout);
|
||||
ip_timeout = priv->mm_ip_timeout;
|
||||
}
|
||||
|
||||
|
|
@ -579,9 +613,7 @@ ppp_stage3_ip_config_start (NMModem *self,
|
|||
if ( !priv->ppp_manager
|
||||
|| !nm_ppp_manager_start (priv->ppp_manager, req, ppp_name,
|
||||
ip_timeout, baud_override, &error)) {
|
||||
nm_log_err (LOGD_PPP, "(%s): error starting PPP: %s",
|
||||
nm_modem_get_uid (self),
|
||||
error->message);
|
||||
_LOGE ("error starting PPP: %s", error->message);
|
||||
g_error_free (error);
|
||||
|
||||
g_clear_object (&priv->ppp_manager);
|
||||
|
|
@ -620,7 +652,7 @@ nm_modem_stage3_ip4_config_start (NMModem *self,
|
|||
const char *method;
|
||||
NMActStageReturn ret;
|
||||
|
||||
nm_log_dbg (LOGD_MB, "ip4_config_start");
|
||||
_LOGD ("ip4_config_start");
|
||||
|
||||
g_return_val_if_fail (NM_IS_MODEM (self), NM_ACT_STAGE_RETURN_FAILURE);
|
||||
g_return_val_if_fail (NM_IS_DEVICE (device), NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
|
@ -639,9 +671,8 @@ nm_modem_stage3_ip4_config_start (NMModem *self,
|
|||
return NM_ACT_STAGE_RETURN_SUCCESS;
|
||||
|
||||
if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) != 0) {
|
||||
nm_log_warn (LOGD_MB | LOGD_IP4,
|
||||
"(%s): unhandled WWAN IPv4 method '%s'; will fail",
|
||||
nm_modem_get_uid (self), method);
|
||||
_LOGW ("unhandled WWAN IPv4 method '%s'; will fail",
|
||||
method);
|
||||
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
|
||||
return NM_ACT_STAGE_RETURN_FAILURE;
|
||||
}
|
||||
|
|
@ -652,15 +683,15 @@ nm_modem_stage3_ip4_config_start (NMModem *self,
|
|||
ret = ppp_stage3_ip_config_start (self, req, out_failure_reason);
|
||||
break;
|
||||
case NM_MODEM_IP_METHOD_STATIC:
|
||||
nm_log_dbg (LOGD_MB, "MODEM_IP_METHOD_STATIC");
|
||||
_LOGD ("MODEM_IP_METHOD_STATIC");
|
||||
ret = NM_MODEM_GET_CLASS (self)->static_stage3_ip4_config_start (self, req, out_failure_reason);
|
||||
break;
|
||||
case NM_MODEM_IP_METHOD_AUTO:
|
||||
nm_log_dbg (LOGD_MB, "MODEM_IP_METHOD_AUTO");
|
||||
_LOGD ("MODEM_IP_METHOD_AUTO");
|
||||
ret = device_class->act_stage3_ip4_config_start (device, NULL, out_failure_reason);
|
||||
break;
|
||||
default:
|
||||
nm_log_info (LOGD_MB, "(%s): IPv4 configuration disabled", nm_modem_get_uid (self));
|
||||
_LOGI ("IPv4 configuration disabled");
|
||||
ret = NM_ACT_STAGE_RETURN_IP_FAIL;
|
||||
break;
|
||||
}
|
||||
|
|
@ -753,9 +784,8 @@ nm_modem_stage3_ip6_config_start (NMModem *self,
|
|||
return NM_ACT_STAGE_RETURN_IP_DONE;
|
||||
|
||||
if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) != 0) {
|
||||
nm_log_warn (LOGD_MB | LOGD_IP6,
|
||||
"(%s): unhandled WWAN IPv6 method '%s'; will fail",
|
||||
nm_modem_get_uid (self), method);
|
||||
_LOGW ("unhandled WWAN IPv6 method '%s'; will fail",
|
||||
method);
|
||||
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
|
||||
return NM_ACT_STAGE_RETURN_FAILURE;
|
||||
}
|
||||
|
|
@ -774,7 +804,7 @@ nm_modem_stage3_ip6_config_start (NMModem *self,
|
|||
ret = NM_MODEM_GET_CLASS (self)->stage3_ip6_config_request (self, out_failure_reason);
|
||||
break;
|
||||
default:
|
||||
nm_log_info (LOGD_MB, "(%s): IPv6 configuration disabled", nm_modem_get_uid (self));
|
||||
_LOGI ("IPv6 configuration disabled");
|
||||
ret = NM_ACT_STAGE_RETURN_IP_FAIL;
|
||||
break;
|
||||
}
|
||||
|
|
@ -850,7 +880,7 @@ modem_secrets_cb (NMActRequest *req,
|
|||
return;
|
||||
|
||||
if (error)
|
||||
nm_log_warn (LOGD_MB, "(%s): %s", nm_modem_get_uid (self), error->message);
|
||||
_LOGW ("modem-secrets: %s", error->message);
|
||||
|
||||
g_signal_emit (self, signals[AUTH_RESULT], 0, error);
|
||||
}
|
||||
|
|
@ -971,17 +1001,15 @@ nm_modem_check_connection_compatible (NMModem *self, NMConnection *connection)
|
|||
str = nm_setting_gsm_get_device_id (s_gsm);
|
||||
if (str) {
|
||||
if (!priv->device_id) {
|
||||
nm_log_dbg (LOGD_MB, "(%s): %s/%s has device-id, device does not",
|
||||
priv->uid,
|
||||
nm_connection_get_uuid (connection),
|
||||
nm_connection_get_id (connection));
|
||||
_LOGD ("%s/%s has device-id, device does not",
|
||||
nm_connection_get_uuid (connection),
|
||||
nm_connection_get_id (connection));
|
||||
return FALSE;
|
||||
}
|
||||
if (strcmp (str, priv->device_id)) {
|
||||
nm_log_dbg (LOGD_MB, "(%s): %s/%s device-id mismatch",
|
||||
priv->uid,
|
||||
nm_connection_get_uuid (connection),
|
||||
nm_connection_get_id (connection));
|
||||
_LOGD ("%s/%s device-id mismatch",
|
||||
nm_connection_get_uuid (connection),
|
||||
nm_connection_get_id (connection));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
@ -994,10 +1022,9 @@ nm_modem_check_connection_compatible (NMModem *self, NMConnection *connection)
|
|||
str = nm_setting_gsm_get_sim_id (s_gsm);
|
||||
if (str && priv->sim_id) {
|
||||
if (strcmp (str, priv->sim_id)) {
|
||||
nm_log_dbg (LOGD_MB, "(%s): %s/%s sim-id mismatch",
|
||||
priv->uid,
|
||||
nm_connection_get_uuid (connection),
|
||||
nm_connection_get_id (connection));
|
||||
_LOGD ("%s/%s sim-id mismatch",
|
||||
nm_connection_get_uuid (connection),
|
||||
nm_connection_get_id (connection));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
@ -1005,10 +1032,9 @@ nm_modem_check_connection_compatible (NMModem *self, NMConnection *connection)
|
|||
str = nm_setting_gsm_get_sim_operator_id (s_gsm);
|
||||
if (str && priv->sim_operator_id) {
|
||||
if (strcmp (str, priv->sim_operator_id)) {
|
||||
nm_log_dbg (LOGD_MB, "(%s): %s/%s sim-operator-id mismatch",
|
||||
priv->uid,
|
||||
nm_connection_get_uuid (connection),
|
||||
nm_connection_get_id (connection));
|
||||
_LOGD ("%s/%s sim-operator-id mismatch",
|
||||
nm_connection_get_uuid (connection),
|
||||
nm_connection_get_id (connection));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
@ -1146,12 +1172,12 @@ ppp_manager_stop_ready (NMPPPManager *ppp_manager,
|
|||
GAsyncResult *res,
|
||||
DeactivateContext *ctx)
|
||||
{
|
||||
NMModem *self = ctx->self;
|
||||
GError *error = NULL;
|
||||
|
||||
if (!nm_ppp_manager_stop_finish (ppp_manager, res, &error)) {
|
||||
nm_log_warn (LOGD_MB, "(%s): cannot stop PPP manager: %s",
|
||||
nm_modem_get_uid (ctx->self),
|
||||
error->message);
|
||||
_LOGW ("cannot stop PPP manager: %s",
|
||||
error->message);
|
||||
g_simple_async_result_take_error (ctx->result, error);
|
||||
deactivate_context_complete (ctx);
|
||||
return;
|
||||
|
|
@ -1165,7 +1191,8 @@ ppp_manager_stop_ready (NMPPPManager *ppp_manager,
|
|||
static void
|
||||
deactivate_step (DeactivateContext *ctx)
|
||||
{
|
||||
NMModemPrivate *priv = NM_MODEM_GET_PRIVATE (ctx->self);
|
||||
NMModem *self = ctx->self;
|
||||
NMModemPrivate *priv = NM_MODEM_GET_PRIVATE (self);
|
||||
GError *error = NULL;
|
||||
|
||||
/* Check cancellable in each step */
|
||||
|
|
@ -1184,7 +1211,7 @@ deactivate_step (DeactivateContext *ctx)
|
|||
if (priv->ppp_manager)
|
||||
ctx->ppp_manager = g_object_ref (priv->ppp_manager);
|
||||
/* Run cleanup */
|
||||
NM_MODEM_GET_CLASS (ctx->self)->deactivate_cleanup (ctx->self, ctx->device);
|
||||
NM_MODEM_GET_CLASS (self)->deactivate_cleanup (self, ctx->device);
|
||||
ctx->step++;
|
||||
/* fall through */
|
||||
case DEACTIVATE_CONTEXT_STEP_PPP_MANAGER_STOP:
|
||||
|
|
@ -1200,16 +1227,15 @@ deactivate_step (DeactivateContext *ctx)
|
|||
/* fall through */
|
||||
case DEACTIVATE_CONTEXT_STEP_MM_DISCONNECT:
|
||||
/* Disconnect asynchronously */
|
||||
NM_MODEM_GET_CLASS (ctx->self)->disconnect (ctx->self,
|
||||
FALSE,
|
||||
ctx->cancellable,
|
||||
(GAsyncReadyCallback) disconnect_ready,
|
||||
ctx);
|
||||
NM_MODEM_GET_CLASS (self)->disconnect (self,
|
||||
FALSE,
|
||||
ctx->cancellable,
|
||||
(GAsyncReadyCallback) disconnect_ready,
|
||||
ctx);
|
||||
return;
|
||||
|
||||
case DEACTIVATE_CONTEXT_STEP_LAST:
|
||||
nm_log_dbg (LOGD_MB, "(%s): modem deactivation finished",
|
||||
nm_modem_get_uid (ctx->self));
|
||||
_LOGD ("modem deactivation finished");
|
||||
deactivate_context_complete (ctx);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE (
|
|||
PROP_IFINDEX,
|
||||
PROP_HWADDR,
|
||||
PROP_UUID,
|
||||
PROP_PRIORITY,
|
||||
PROP_ROUTE_METRIC,
|
||||
PROP_TIMEOUT,
|
||||
);
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ typedef struct _NMDhcpClientPrivate {
|
|||
guint watch_id;
|
||||
int addr_family;
|
||||
int ifindex;
|
||||
guint32 priority;
|
||||
guint32 route_metric;
|
||||
guint32 timeout;
|
||||
NMDhcpState state;
|
||||
bool info_only:1;
|
||||
|
|
@ -151,11 +151,11 @@ nm_dhcp_client_get_hw_addr (NMDhcpClient *self)
|
|||
}
|
||||
|
||||
guint32
|
||||
nm_dhcp_client_get_priority (NMDhcpClient *self)
|
||||
nm_dhcp_client_get_route_metric (NMDhcpClient *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), G_MAXUINT32);
|
||||
|
||||
return NM_DHCP_CLIENT_GET_PRIVATE (self)->priority;
|
||||
return NM_DHCP_CLIENT_GET_PRIVATE (self)->route_metric;
|
||||
}
|
||||
|
||||
guint32
|
||||
|
|
@ -789,14 +789,13 @@ nm_dhcp_client_handle_event (gpointer unused,
|
|||
priv->ifindex,
|
||||
priv->iface,
|
||||
str_options,
|
||||
priv->priority);
|
||||
priv->route_metric);
|
||||
} else {
|
||||
prefix = nm_dhcp_utils_ip6_prefix_from_options (str_options);
|
||||
ip_config = (GObject *) nm_dhcp_utils_ip6_config_from_options (nm_dhcp_client_get_multi_idx (self),
|
||||
priv->ifindex,
|
||||
priv->iface,
|
||||
str_options,
|
||||
priv->priority,
|
||||
priv->info_only);
|
||||
}
|
||||
}
|
||||
|
|
@ -851,8 +850,8 @@ get_property (GObject *object, guint prop_id,
|
|||
case PROP_UUID:
|
||||
g_value_set_string (value, priv->uuid);
|
||||
break;
|
||||
case PROP_PRIORITY:
|
||||
g_value_set_uint (value, priv->priority);
|
||||
case PROP_ROUTE_METRIC:
|
||||
g_value_set_uint (value, priv->route_metric);
|
||||
break;
|
||||
case PROP_TIMEOUT:
|
||||
g_value_set_uint (value, priv->timeout);
|
||||
|
|
@ -900,9 +899,9 @@ set_property (GObject *object, guint prop_id,
|
|||
/* construct-only */
|
||||
priv->uuid = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_PRIORITY:
|
||||
case PROP_ROUTE_METRIC:
|
||||
/* construct-only */
|
||||
priv->priority = g_value_get_uint (value);
|
||||
priv->route_metric = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_TIMEOUT:
|
||||
/* construct-only */
|
||||
|
|
@ -1011,8 +1010,8 @@ nm_dhcp_client_class_init (NMDhcpClientClass *client_class)
|
|||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
obj_properties[PROP_PRIORITY] =
|
||||
g_param_spec_uint (NM_DHCP_CLIENT_PRIORITY, "", "",
|
||||
obj_properties[PROP_ROUTE_METRIC] =
|
||||
g_param_spec_uint (NM_DHCP_CLIENT_ROUTE_METRIC, "", "",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
#define NM_DHCP_CLIENT_IFINDEX "ifindex"
|
||||
#define NM_DHCP_CLIENT_HWADDR "hwaddr"
|
||||
#define NM_DHCP_CLIENT_UUID "uuid"
|
||||
#define NM_DHCP_CLIENT_PRIORITY "priority"
|
||||
#define NM_DHCP_CLIENT_ROUTE_METRIC "route-metric"
|
||||
#define NM_DHCP_CLIENT_TIMEOUT "timeout"
|
||||
#define NM_DHCP_CLIENT_MULTI_IDX "multi-idx"
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ const GByteArray *nm_dhcp_client_get_duid (NMDhcpClient *self);
|
|||
|
||||
const GByteArray *nm_dhcp_client_get_hw_addr (NMDhcpClient *self);
|
||||
|
||||
guint32 nm_dhcp_client_get_priority (NMDhcpClient *self);
|
||||
guint32 nm_dhcp_client_get_route_metric (NMDhcpClient *self);
|
||||
|
||||
guint32 nm_dhcp_client_get_timeout (NMDhcpClient *self);
|
||||
|
||||
|
|
@ -185,7 +185,7 @@ typedef struct {
|
|||
const char *iface,
|
||||
int ifindex,
|
||||
const char *uuid,
|
||||
guint32 default_route_metric);
|
||||
guint32 route_metric);
|
||||
} NMDhcpClientFactory;
|
||||
|
||||
extern const NMDhcpClientFactory _nm_dhcp_client_factory_dhclient;
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ nm_dhcp_dhclient_get_lease_ip_configs (NMDedupMultiIndex *multi_idx,
|
|||
const char *iface,
|
||||
int ifindex,
|
||||
const char *uuid,
|
||||
guint32 default_route_metric)
|
||||
guint32 route_metric)
|
||||
{
|
||||
char *contents = NULL;
|
||||
char *leasefile;
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ client_start (NMDhcpManager *self,
|
|||
int ifindex,
|
||||
const GByteArray *hwaddr,
|
||||
const char *uuid,
|
||||
guint32 priority,
|
||||
guint32 route_metric,
|
||||
const struct in6_addr *ipv6_ll_addr,
|
||||
const char *dhcp_client_id,
|
||||
guint32 timeout,
|
||||
|
|
@ -202,7 +202,7 @@ client_start (NMDhcpManager *self,
|
|||
NM_DHCP_CLIENT_IFINDEX, ifindex,
|
||||
NM_DHCP_CLIENT_HWADDR, hwaddr,
|
||||
NM_DHCP_CLIENT_UUID, uuid,
|
||||
NM_DHCP_CLIENT_PRIORITY, priority,
|
||||
NM_DHCP_CLIENT_ROUTE_METRIC, route_metric,
|
||||
NM_DHCP_CLIENT_TIMEOUT, (guint) timeout,
|
||||
NULL);
|
||||
g_hash_table_insert (NM_DHCP_MANAGER_GET_PRIVATE (self)->clients, client, g_object_ref (client));
|
||||
|
|
@ -229,7 +229,7 @@ nm_dhcp_manager_start_ip4 (NMDhcpManager *self,
|
|||
int ifindex,
|
||||
const GByteArray *hwaddr,
|
||||
const char *uuid,
|
||||
guint32 priority,
|
||||
guint32 route_metric,
|
||||
gboolean send_hostname,
|
||||
const char *dhcp_hostname,
|
||||
const char *dhcp_fqdn,
|
||||
|
|
@ -270,7 +270,7 @@ nm_dhcp_manager_start_ip4 (NMDhcpManager *self,
|
|||
}
|
||||
}
|
||||
|
||||
return client_start (self, AF_INET, multi_idx, iface, ifindex, hwaddr, uuid, priority, NULL,
|
||||
return client_start (self, AF_INET, multi_idx, iface, ifindex, hwaddr, uuid, route_metric, NULL,
|
||||
dhcp_client_id, timeout, dhcp_anycast_addr, hostname,
|
||||
use_fqdn, FALSE, 0, last_ip_address, 0);
|
||||
}
|
||||
|
|
@ -284,7 +284,7 @@ nm_dhcp_manager_start_ip6 (NMDhcpManager *self,
|
|||
const GByteArray *hwaddr,
|
||||
const struct in6_addr *ll_addr,
|
||||
const char *uuid,
|
||||
guint32 priority,
|
||||
guint32 route_metric,
|
||||
gboolean send_hostname,
|
||||
const char *dhcp_hostname,
|
||||
guint32 timeout,
|
||||
|
|
@ -303,7 +303,7 @@ nm_dhcp_manager_start_ip6 (NMDhcpManager *self,
|
|||
/* Always prefer the explicit dhcp-hostname if given */
|
||||
hostname = dhcp_hostname ? dhcp_hostname : priv->default_hostname;
|
||||
}
|
||||
return client_start (self, AF_INET6, multi_idx, iface, ifindex, hwaddr, uuid, priority,
|
||||
return client_start (self, AF_INET6, multi_idx, iface, ifindex, hwaddr, uuid, route_metric,
|
||||
ll_addr, NULL, timeout, dhcp_anycast_addr, hostname, TRUE, info_only,
|
||||
privacy, NULL, needed_prefixes);
|
||||
}
|
||||
|
|
@ -329,7 +329,7 @@ nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self,
|
|||
const char *iface,
|
||||
int ifindex,
|
||||
const char *uuid,
|
||||
guint32 default_route_metric)
|
||||
guint32 route_metric)
|
||||
{
|
||||
NMDhcpManagerPrivate *priv;
|
||||
|
||||
|
|
@ -342,7 +342,7 @@ nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self,
|
|||
priv = NM_DHCP_MANAGER_GET_PRIVATE (self);
|
||||
if ( priv->client_factory
|
||||
&& priv->client_factory->get_lease_ip_configs)
|
||||
return priv->client_factory->get_lease_ip_configs (multi_idx, addr_family, iface, ifindex, uuid, default_route_metric);
|
||||
return priv->client_factory->get_lease_ip_configs (multi_idx, addr_family, iface, ifindex, uuid, route_metric);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ NMDhcpClient * nm_dhcp_manager_start_ip4 (NMDhcpManager *manager,
|
|||
int ifindex,
|
||||
const GByteArray *hwaddr,
|
||||
const char *uuid,
|
||||
guint32 priority,
|
||||
guint32 route_metric,
|
||||
gboolean send_hostname,
|
||||
const char *dhcp_hostname,
|
||||
const char *dhcp_fqdn,
|
||||
|
|
@ -67,7 +67,7 @@ NMDhcpClient * nm_dhcp_manager_start_ip6 (NMDhcpManager *manager,
|
|||
const GByteArray *hwaddr,
|
||||
const struct in6_addr *ll_addr,
|
||||
const char *uuid,
|
||||
guint32 priority,
|
||||
guint32 route_metric,
|
||||
gboolean send_hostname,
|
||||
const char *dhcp_hostname,
|
||||
guint32 timeout,
|
||||
|
|
@ -82,7 +82,7 @@ GSList * nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self,
|
|||
const char *iface,
|
||||
int ifindex,
|
||||
const char *uuid,
|
||||
guint32 default_route_metric);
|
||||
guint32 route_metric);
|
||||
|
||||
/* For testing only */
|
||||
extern const char* nm_dhcp_helper_path;
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ lease_to_ip4_config (NMDedupMultiIndex *multi_idx,
|
|||
int ifindex,
|
||||
sd_dhcp_lease *lease,
|
||||
GHashTable *options,
|
||||
guint32 default_priority,
|
||||
guint32 route_metric,
|
||||
gboolean log_lease,
|
||||
GError **error)
|
||||
{
|
||||
|
|
@ -356,7 +356,7 @@ lease_to_ip4_config (NMDedupMultiIndex *multi_idx,
|
|||
|
||||
if (route.plen) {
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
route.metric = default_priority;
|
||||
route.metric = route_metric;
|
||||
nm_ip4_config_add_route (ip4_config, &route, NULL);
|
||||
|
||||
s = nm_utils_inet4_ntop (route.network, buf);
|
||||
|
|
@ -440,7 +440,7 @@ nm_dhcp_systemd_get_lease_ip_configs (NMDedupMultiIndex *multi_idx,
|
|||
const char *iface,
|
||||
int ifindex,
|
||||
const char *uuid,
|
||||
guint32 default_route_metric)
|
||||
guint32 route_metric)
|
||||
{
|
||||
GSList *leases = NULL;
|
||||
gs_free char *path = NULL;
|
||||
|
|
@ -454,7 +454,7 @@ nm_dhcp_systemd_get_lease_ip_configs (NMDedupMultiIndex *multi_idx,
|
|||
path = get_leasefile_path (addr_family, iface, uuid);
|
||||
r = dhcp_lease_load (&lease, path);
|
||||
if (r == 0 && lease) {
|
||||
ip4_config = lease_to_ip4_config (multi_idx, iface, ifindex, lease, NULL, default_route_metric, FALSE, NULL);
|
||||
ip4_config = lease_to_ip4_config (multi_idx, iface, ifindex, lease, NULL, route_metric, FALSE, NULL);
|
||||
if (ip4_config)
|
||||
leases = g_slist_append (leases, ip4_config);
|
||||
sd_dhcp_lease_unref (lease);
|
||||
|
|
@ -513,7 +513,7 @@ bound4_handle (NMDhcpSystemd *self)
|
|||
nm_dhcp_client_get_ifindex (NM_DHCP_CLIENT (self)),
|
||||
lease,
|
||||
options,
|
||||
nm_dhcp_client_get_priority (NM_DHCP_CLIENT (self)),
|
||||
nm_dhcp_client_get_route_metric (NM_DHCP_CLIENT (self)),
|
||||
TRUE,
|
||||
&error);
|
||||
if (ip4_config) {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
static gboolean
|
||||
ip4_process_dhcpcd_rfc3442_routes (const char *iface,
|
||||
const char *str,
|
||||
guint32 priority,
|
||||
guint32 route_metric,
|
||||
NMIP4Config *ip4_config,
|
||||
guint32 *gwaddr)
|
||||
{
|
||||
|
|
@ -90,7 +90,7 @@ ip4_process_dhcpcd_rfc3442_routes (const char *iface,
|
|||
route.plen = rt_cidr;
|
||||
route.gateway = rt_route;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
route.metric = priority;
|
||||
route.metric = route_metric;
|
||||
nm_ip4_config_add_route (ip4_config, &route, NULL);
|
||||
}
|
||||
}
|
||||
|
|
@ -166,7 +166,7 @@ error:
|
|||
static gboolean
|
||||
ip4_process_dhclient_rfc3442_routes (const char *iface,
|
||||
const char *str,
|
||||
guint32 priority,
|
||||
guint32 route_metric,
|
||||
NMIP4Config *ip4_config,
|
||||
guint32 *gwaddr)
|
||||
{
|
||||
|
|
@ -198,7 +198,7 @@ ip4_process_dhclient_rfc3442_routes (const char *iface,
|
|||
|
||||
/* normal route */
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
route.metric = priority;
|
||||
route.metric = route_metric;
|
||||
nm_ip4_config_add_route (ip4_config, &route, NULL);
|
||||
|
||||
_LOG2I (LOGD_DHCP4, iface, " classless static route %s/%d gw %s",
|
||||
|
|
@ -215,7 +215,7 @@ out:
|
|||
static gboolean
|
||||
ip4_process_classless_routes (const char *iface,
|
||||
GHashTable *options,
|
||||
guint32 priority,
|
||||
guint32 route_metric,
|
||||
NMIP4Config *ip4_config,
|
||||
guint32 *gwaddr)
|
||||
{
|
||||
|
|
@ -271,16 +271,16 @@ ip4_process_classless_routes (const char *iface,
|
|||
|
||||
if (strchr (str, '/')) {
|
||||
/* dhcpcd format */
|
||||
return ip4_process_dhcpcd_rfc3442_routes (iface, str, priority, ip4_config, gwaddr);
|
||||
return ip4_process_dhcpcd_rfc3442_routes (iface, str, route_metric, ip4_config, gwaddr);
|
||||
}
|
||||
|
||||
return ip4_process_dhclient_rfc3442_routes (iface, str, priority, ip4_config, gwaddr);
|
||||
return ip4_process_dhclient_rfc3442_routes (iface, str, route_metric, ip4_config, gwaddr);
|
||||
}
|
||||
|
||||
static void
|
||||
process_classful_routes (const char *iface,
|
||||
GHashTable *options,
|
||||
guint32 priority,
|
||||
guint32 route_metric,
|
||||
NMIP4Config *ip4_config)
|
||||
{
|
||||
const char *str;
|
||||
|
|
@ -324,7 +324,7 @@ process_classful_routes (const char *iface,
|
|||
}
|
||||
route.gateway = rt_route;
|
||||
route.rt_source = NM_IP_CONFIG_SOURCE_DHCP;
|
||||
route.metric = priority;
|
||||
route.metric = route_metric;
|
||||
|
||||
route.network = nm_utils_ip4_address_clear_host_address (route.network, route.plen);
|
||||
|
||||
|
|
@ -390,7 +390,7 @@ nm_dhcp_utils_ip4_config_from_options (NMDedupMultiIndex *multi_idx,
|
|||
int ifindex,
|
||||
const char *iface,
|
||||
GHashTable *options,
|
||||
guint32 priority)
|
||||
guint32 route_metric)
|
||||
{
|
||||
NMIP4Config *ip4_config = NULL;
|
||||
guint32 tmp_addr;
|
||||
|
|
@ -426,8 +426,8 @@ nm_dhcp_utils_ip4_config_from_options (NMDedupMultiIndex *multi_idx,
|
|||
/* Routes: if the server returns classless static routes, we MUST ignore
|
||||
* the 'static_routes' option.
|
||||
*/
|
||||
if (!ip4_process_classless_routes (iface, options, priority, ip4_config, &gwaddr))
|
||||
process_classful_routes (iface, options, priority, ip4_config);
|
||||
if (!ip4_process_classless_routes (iface, options, route_metric, ip4_config, &gwaddr))
|
||||
process_classful_routes (iface, options, route_metric, ip4_config);
|
||||
|
||||
if (gwaddr) {
|
||||
_LOG2I (LOGD_DHCP4, iface, " gateway %s", nm_utils_inet4_ntop (gwaddr, NULL));
|
||||
|
|
@ -624,7 +624,6 @@ nm_dhcp_utils_ip6_config_from_options (NMDedupMultiIndex *multi_idx,
|
|||
int ifindex,
|
||||
const char *iface,
|
||||
GHashTable *options,
|
||||
guint32 priority,
|
||||
gboolean info_only)
|
||||
{
|
||||
NMIP6Config *ip6_config = NULL;
|
||||
|
|
|
|||
|
|
@ -28,13 +28,12 @@ NMIP4Config *nm_dhcp_utils_ip4_config_from_options (struct _NMDedupMultiIndex *m
|
|||
int ifindex,
|
||||
const char *iface,
|
||||
GHashTable *options,
|
||||
guint priority);
|
||||
guint32 route_metric);
|
||||
|
||||
NMIP6Config *nm_dhcp_utils_ip6_config_from_options (struct _NMDedupMultiIndex *multi_idx,
|
||||
int ifindex,
|
||||
const char *iface,
|
||||
GHashTable *options,
|
||||
guint priority,
|
||||
gboolean info_only);
|
||||
|
||||
NMPlatformIP6Address nm_dhcp_utils_ip6_prefix_from_options (GHashTable *options);
|
||||
|
|
|
|||
|
|
@ -35,12 +35,12 @@ static NMIP4Config *
|
|||
_ip4_config_from_options (int ifindex,
|
||||
const char *iface,
|
||||
GHashTable *options,
|
||||
guint32 priority)
|
||||
guint32 route_metric)
|
||||
{
|
||||
nm_auto_unref_dedup_multi_index NMDedupMultiIndex *multi_idx = nm_dedup_multi_index_new ();
|
||||
NMIP4Config *config;
|
||||
|
||||
config = nm_dhcp_utils_ip4_config_from_options (multi_idx, ifindex, iface, options, priority);
|
||||
config = nm_dhcp_utils_ip4_config_from_options (multi_idx, ifindex, iface, options, route_metric);
|
||||
g_assert (config);
|
||||
return config;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1845,8 +1845,8 @@ get_existing_connection (NMManager *self,
|
|||
matched = NM_SETTINGS_CONNECTION (nm_utils_match_connection (connections,
|
||||
connection,
|
||||
nm_device_has_carrier (device),
|
||||
nm_device_get_ip4_route_metric (device),
|
||||
nm_device_get_ip6_route_metric (device),
|
||||
nm_device_get_route_metric (device, AF_INET),
|
||||
nm_device_get_route_metric (device, AF_INET6),
|
||||
NULL, NULL));
|
||||
} else
|
||||
matched = NULL;
|
||||
|
|
@ -1874,8 +1874,8 @@ get_existing_connection (NMManager *self,
|
|||
matched = NM_SETTINGS_CONNECTION (nm_utils_match_connection ((NMConnection *const*) connections,
|
||||
connection,
|
||||
nm_device_has_carrier (device),
|
||||
nm_device_get_ip4_route_metric (device),
|
||||
nm_device_get_ip6_route_metric (device),
|
||||
nm_device_get_route_metric (device, AF_INET),
|
||||
nm_device_get_route_metric (device, AF_INET6),
|
||||
NULL, NULL));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -426,7 +426,7 @@ get_best_ip_device (NMPolicy *self,
|
|||
&& (connection = nm_device_get_applied_connection (device))
|
||||
&& nm_utils_connection_has_default_route (connection, addr_family, NULL)) {
|
||||
metric = nm_utils_ip_route_metric_normalize (addr_family,
|
||||
nm_device_get_ip_route_metric (device, addr_family));
|
||||
nm_device_get_route_metric (device, addr_family));
|
||||
is_fully_activated = FALSE;
|
||||
} else
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -711,8 +711,8 @@ parse_line_type_addr_with_prefix:
|
|||
int prefix = -1;
|
||||
|
||||
if (info->type == PARSE_LINE_TYPE_ADDR) {
|
||||
if (!nm_utils_parse_inaddr_bin (s,
|
||||
addr_family,
|
||||
if (!nm_utils_parse_inaddr_bin (addr_family,
|
||||
s,
|
||||
&info->v.addr.addr)) {
|
||||
if ( info == &infos[PARSE_LINE_ATTR_ROUTE_VIA]
|
||||
&& nm_streq (s, "(null)")) {
|
||||
|
|
@ -738,10 +738,10 @@ parse_line_type_addr_with_prefix:
|
|||
&& nm_streq (s, "default")) {
|
||||
memset (&info->v.addr.addr, 0, sizeof (info->v.addr.addr));
|
||||
prefix = 0;
|
||||
} else if (!nm_utils_parse_inaddr_prefix_bin (s,
|
||||
addr_family,
|
||||
&info->v.addr.addr,
|
||||
&prefix)) {
|
||||
} else if (!nm_utils_parse_inaddr_prefix_bin (addr_family,
|
||||
s,
|
||||
&info->v.addr.addr,
|
||||
&prefix)) {
|
||||
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
||||
"Argument for \"%s\" is not ADDR/PREFIX format", w);
|
||||
return -EINVAL;
|
||||
|
|
|
|||
|
|
@ -751,7 +751,7 @@ add_ip4_vpn_gateway_route (NMIP4Config *config,
|
|||
if (!has_parent_gw)
|
||||
return;
|
||||
|
||||
route_metric = nm_device_get_ip4_route_metric (parent_device);
|
||||
route_metric = nm_device_get_route_metric (parent_device, AF_INET);
|
||||
|
||||
memset (&route, 0, sizeof (route));
|
||||
route.ifindex = ifindex;
|
||||
|
|
@ -824,7 +824,7 @@ add_ip6_vpn_gateway_route (NMIP6Config *config,
|
|||
if (!has_parent_gw)
|
||||
return;
|
||||
|
||||
route_metric = nm_device_get_ip6_route_metric (parent_device);
|
||||
route_metric = nm_device_get_route_metric (parent_device, AF_INET6);
|
||||
|
||||
memset (&route, 0, sizeof (route));
|
||||
route.ifindex = ifindex;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue