Blame SOURCES/0007-wwan-default-device-route-rh1527934.patch

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