From 19ba1a19f4d3261e47420deb2882d8533bdbc5d8 Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Wed, 20 Dec 2017 13:53:56 +0100
Subject: [PATCH 1/3] wwan: fix checks on IP configuration
Don't call nm_utils_parse_inaddr_bin() if the string returned by
mm_bearer_ip_config_get_address() and mm_bearer_ip_config_get_gateway()
is NULL, as the function requires a valid pointer. Throw an error if the
address is NULL, but allow an empty gateway.
Fixes: 7837afe87f0f269c0cc4de1c9c217529d760e83b
(cherry picked from commit 8ddc6caf98e2c4f1e796f50cdbeee567aba9be9d)
(cherry picked from commit f4dc5bd782e709c541174aac3fd3a160ca5f53ba)
---
src/devices/wwan/nm-modem-broadband.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/devices/wwan/nm-modem-broadband.c b/src/devices/wwan/nm-modem-broadband.c
index 6e5f10a06..9fc147da9 100644
--- a/src/devices/wwan/nm-modem-broadband.c
+++ b/src/devices/wwan/nm-modem-broadband.c
@@ -883,24 +883,25 @@ 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 (!nm_utils_parse_inaddr_bin (AF_INET, address_string, &address_network)) {
+ if ( !address_string
+ || !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'",
+ "(%s) retrieving IP4 configuration failed: invalid address given %s%s%s",
nm_modem_get_uid (NM_MODEM (self)),
- address_string);
+ NM_PRINT_FMT_QUOTE_STRING (address_string));
goto out;
}
/* Missing gateway not a hard failure */
gw_string = mm_bearer_ip_config_get_gateway (self->_priv.ipv4_config);
- if ( !gw_string
- || !nm_utils_parse_inaddr_bin (AF_INET, gw_string, &gw)) {
+ if ( gw_string
+ && !nm_utils_parse_inaddr_bin (AF_INET, gw_string, &gw)) {
error = g_error_new (NM_DEVICE_ERROR,
NM_DEVICE_ERROR_INVALID_CONNECTION,
- "(%s) retrieving IP4 configuration failed: invalid gateway address %s%s%s",
+ "(%s) retrieving IP4 configuration failed: invalid gateway address \"%s\"",
nm_modem_get_uid (NM_MODEM (self)),
- NM_PRINT_FMT_QUOTE_STRING (gw_string));
+ gw_string);
goto out;
}
--
2.14.3
From 0be2bf3ca528a02237665b3c34ac00e6a6a89d7b Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Wed, 20 Dec 2017 14:26:57 +0100
Subject: [PATCH 2/3] wwan: add default route even if modem didn't return a
gateway
If the modem didn't return a gateway, add a device route.
Fixes: 5c299454b49b165f645c25fd3e083c0bb747ad91
(cherry picked from commit ec32edb21f7b34064731c737594643a3b9bda337)
(cherry picked from commit d9512bc807f103fe891409629d1b17ff4594d9c4)
---
src/devices/wwan/nm-modem-broadband.c | 34 +++++++++++++++-------------------
1 file changed, 15 insertions(+), 19 deletions(-)
diff --git a/src/devices/wwan/nm-modem-broadband.c b/src/devices/wwan/nm-modem-broadband.c
index 9fc147da9..cd7c48ef3 100644
--- a/src/devices/wwan/nm-modem-broadband.c
+++ b/src/devices/wwan/nm-modem-broadband.c
@@ -875,6 +875,8 @@ static_stage3_ip4_done (NMModemBroadband *self)
NMPlatformIP4Address address;
const gchar **dns;
guint i;
+ guint32 ip4_route_table, ip4_route_metric;
+ NMPlatformIP4Route *r;
g_assert (self->_priv.ipv4_config);
g_assert (self->_priv.bearer);
@@ -920,26 +922,20 @@ static_stage3_ip4_done (NMModemBroadband *self)
_LOGI (" address %s/%d", address_string, address.plen);
- if (gw) {
- guint32 ip4_route_table, ip4_route_metric;
- nm_modem_get_route_parameters (NM_MODEM (self),
- &ip4_route_table,
- &ip4_route_metric,
- NULL,
- NULL);
- {
- const NMPlatformIP4Route r = {
- .rt_source = NM_IP_CONFIG_SOURCE_WWAN,
- .gateway = gw,
- .table_coerced = nm_platform_route_table_coerce (ip4_route_table),
- .metric = ip4_route_metric,
- };
-
- _LOGI (" gateway %s", gw_string);
- nm_ip4_config_add_route (config, &r, NULL);
- }
- }
+ nm_modem_get_route_parameters (NM_MODEM (self),
+ &ip4_route_table,
+ &ip4_route_metric,
+ NULL,
+ NULL);
+ r = &(NMPlatformIP4Route) {
+ .rt_source = NM_IP_CONFIG_SOURCE_WWAN,
+ .gateway = gw,
+ .table_coerced = nm_platform_route_table_coerce (ip4_route_table),
+ .metric = ip4_route_metric,
+ };
+ nm_ip4_config_add_route (config, r, NULL);
+ _LOGI (" gateway %s", gw_string);
/* DNS servers */
dns = mm_bearer_ip_config_get_dns (self->_priv.ipv4_config);
--
2.14.3
From 345d3abb0ae2a322bc1a19c59c2a229a06657ce6 Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Wed, 20 Dec 2017 14:28:05 +0100
Subject: [PATCH 3/3] wwan: clear idle source id when the callback runs
Fixes: f0996d0eb82254ea794cf9607e4a9b4e2dc3d029
(cherry picked from commit 5d372fd30ea71e8f3e6bb8b77c1e7a680165a3ce)
(cherry picked from commit 4ca7e3d0cfb6a75b02e183b369bf2d35c38ca6a6)
---
src/devices/wwan/nm-modem-broadband.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/devices/wwan/nm-modem-broadband.c b/src/devices/wwan/nm-modem-broadband.c
index cd7c48ef3..dc0ce303c 100644
--- a/src/devices/wwan/nm-modem-broadband.c
+++ b/src/devices/wwan/nm-modem-broadband.c
@@ -881,6 +881,8 @@ static_stage3_ip4_done (NMModemBroadband *self)
g_assert (self->_priv.ipv4_config);
g_assert (self->_priv.bearer);
+ self->_priv.idle_id_ip4 = 0;
+
_LOGI ("IPv4 static configuration:");
/* Fully fail if invalid IP address retrieved */
@@ -986,6 +988,7 @@ stage3_ip6_done (NMModemBroadband *self)
g_assert (self->_priv.ipv6_config);
+ self->_priv.idle_id_ip6 = 0;
memset (&address, 0, sizeof (address));
ip_method = get_bearer_ip_method (self->_priv.ipv6_config);
--
2.14.3