Skip to contentSkip to conversation

gprs: Postpone attach decisions until netreg is finished

PATCH In review [email protected] 2 participants 3 messages Jul 24, 2019 – Aug 1, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gprs: Postpone attach decisions until netreg is finished

From: Richard Röjfors <[email protected]>

In case the gprs_netreg_update is called from somewhere else than the actual netreg update before any netreg updates have happened. It can not make proper decisions. For instance we might run on EUTRAN but it does not know yet. So check if the technology is known to netreg, if not just return since netreg will kick us when its finished initialising, which will be very soon.

---
 src/gprs.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
src/gprs.c +11 -2
index bdb8c8a2..4e79c528 100644
@@ -1660,6 +1660,16 @@ static void gprs_netreg_removed(struct ofono_gprs *gprs)
 static void gprs_netreg_update(struct ofono_gprs *gprs)
 {
 	ofono_bool_t attach;
+	int technology;
+
+	technology = ofono_netreg_get_technology(gprs->netreg);
+
+	/* If we are called before netreg has updated us, just return
+	 * we will get called again when the technology is available
+	 * and we can make better decisions
+	 */
+	if (technology == -1)
+		return;
 
 	attach = gprs->netreg_status == NETWORK_REGISTRATION_STATUS_REGISTERED;
 
@@ -1670,8 +1680,7 @@ static void gprs_netreg_update(struct ofono_gprs *gprs)
 
 	DBG("attach: %u, driver_attached: %u", attach, gprs->driver_attached);
 
-	if (ofono_netreg_get_technology(gprs->netreg) ==
-			ACCESS_TECHNOLOGY_EUTRAN && have_read_settings(gprs))
+	if (technology == ACCESS_TECHNOLOGY_EUTRAN && have_read_settings(gprs))
 		/*
 		 * For LTE we set attached status only on successful
 		 * context activation.
Signature · 1 line
2.20.1
#1 lore raw

Hi Richard,

Quoted 21 lines · richard.rojfors(a)gmail.com

From: Richard Röjfors <[email protected]>

In case the gprs_netreg_update is called from somewhere else than the actual netreg update before any netreg updates have happened. It can not make proper decisions. For instance we might run on EUTRAN but it does not know yet. So check if the technology is known to netreg, if not just return since netreg will kick us when its finished initialising, which will be very soon.

---
  src/gprs.c | 13 +++++++++++--
  1 file changed, 11 insertions(+), 2 deletions(-)
src/gprs.c +0 -0
index bdb8c8a2..4e79c528 100644
@@ -1660,6 +1660,16 @@ static void gprs_netreg_removed(struct ofono_gprs *gprs)
  static void gprs_netreg_update(struct ofono_gprs *gprs)
  {
  	ofono_bool_t attach;

src/gprs.c static void gprs_netreg_removed(struct ofono_gprs *gprs) · line 1672

Quoted 10 lines
src/gprs.c +10 -0
+	int technology;
+
+	technology = ofono_netreg_get_technology(gprs->netreg);
+
+	/* If we are called before netreg has updated us, just return
+	 * we will get called again when the technology is available
+	 * and we can make better decisions
+	 */
+	if (technology == -1)
+		return;

You have to be careful here, some modem drivers do not report technology at all, and it is an optional property in the API. So you are probably breaking such drivers with this change...

src/gprs.c static void gprs_netreg_removed(struct ofono_gprs *gprs) · line 1675

Quoted 3 lines
src/gprs.c +0 -0
  	attach = gprs->netreg_status == NETWORK_REGISTRATION_STATUS_REGISTERED;
 

<snip>

Regards,
-Denis

#2 lore raw

Hi Denis,

Den tors 25 juli 2019 kl 06:58 skrev Denis Kenzior <[email protected]>:

Quoted 9 lines

src/gprs.c static void gprs_netreg_removed(struct ofono_gprs *gprs) · line 1672

Quoted 8 lines
src/gprs.c +8 -0
+     technology = ofono_netreg_get_technology(gprs->netreg);
+
+     /* If we are called before netreg has updated us, just return
+      * we will get called again when the technology is available
+      * and we can make better decisions
+      */
+     if (technology == -1)
+             return;
Quoted 5 lines

You have to be careful here, some modem drivers do not report technology at all, and it is an optional property in the API. So you are probably breaking such drivers with this change...

Unfortunately you are completely correct ;-)
I send another spin. Where i instead set the netreg status to -1 in case the driver can fetch
the status during startup. This will work with both sms and gprs which seems to be the users of netreg.
The D-Bus interface will also return "unknown" during this time. ..And the users such as gprs can know if the status is valid or not.

--Richard