<p>Mykola Shchetinin <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/13744">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  lynxis lazus: Looks good to me, approved
  Mykola Shchetinin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">gprs_gmm: send Service Reject when no PDP ctxs are available.<br><br>Look at PDP Context Status IE: if there are any PDP contexts which are<br>ACTIVE on MS side and there are no PDP contexts which are ACTIVE on the<br>network side, then send Service Reject with the cause "NO PDP<br>ACTIVATED". This forces MS to reactivate the PDP contexts.<br><br>3GPP TS 24.008 Section 4.7.13.4 Service request procedure not accepted<br>by the network. Cause # 40.<br><br>Fixes: OS#3937<br>Change-Id: If610cbef17c25ec44e65d4f1b2340d102c560437<br>---<br>M src/gprs/gprs_gmm.c<br>M tests/sgsn/sgsn_test.c<br>M tests/sgsn/sgsn_test.ok<br>3 files changed, 43 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/gprs/gprs_gmm.c b/src/gprs/gprs_gmm.c</span><br><span>index 358bff9..a18a54e 100644</span><br><span>--- a/src/gprs/gprs_gmm.c</span><br><span>+++ b/src/gprs/gprs_gmm.c</span><br><span>@@ -1616,6 +1616,19 @@</span><br><span>   }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* 3GPP TS 24.008 Section 4.7.13.4 Service request procedure not accepted by the</span><br><span style="color: hsl(120, 100%, 40%);">+ * network. Returns true if MS has active PDP contexts in pdp_status */</span><br><span style="color: hsl(120, 100%, 40%);">+bool pdp_status_has_active_nsapis(const uint8_t *pdp_status, const size_t pdp_status_len)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   size_t i;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   for (i = 0; i < pdp_status_len; i++)</span><br><span style="color: hsl(120, 100%, 40%);">+               if (pdp_status[i] != 0)</span><br><span style="color: hsl(120, 100%, 40%);">+                       return true;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        return false;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* Chapter 9.4.14: Routing area update request */</span><br><span> static int gsm48_rx_gmm_ra_upd_req(struct sgsn_mm_ctx *mmctx, struct msgb *msg,</span><br><span>                              struct gprs_llc_llme *llme)</span><br><span>@@ -1896,12 +1909,23 @@</span><br><span> </span><br><span>         ctx->iu.service.type = service_type;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-     /* TODO: Handle those only in case of accept? */</span><br><span>     /* Look at PDP Context Status IE and see if MS's view of</span><br><span>          * activated/deactivated NSAPIs agrees with our view */</span><br><span>      if (TLVP_PRESENT(&tp, GSM48_IE_GMM_PDP_CTX_STATUS)) {</span><br><span>            const uint8_t *pdp_status = TLVP_VAL(&tp, GSM48_IE_GMM_PDP_CTX_STATUS);</span><br><span style="color: hsl(120, 100%, 40%);">+           const size_t pdp_status_len = TLVP_LEN(&tp, GSM48_IE_GMM_PDP_CTX_STATUS);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>              process_ms_ctx_status(ctx, pdp_status);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+             /* 3GPP TS 24.008 Section 4.7.13.4 Service request procedure not</span><br><span style="color: hsl(120, 100%, 40%);">+               * accepted by the network. Cause #40. If MS has PDP Contexts in</span><br><span style="color: hsl(120, 100%, 40%);">+               * Active state in pdp_status but there is no PDP contexts on</span><br><span style="color: hsl(120, 100%, 40%);">+          * SGSN side then Reject with the cause will force the mobile to</span><br><span style="color: hsl(120, 100%, 40%);">+               * reset PDP contexts */</span><br><span style="color: hsl(120, 100%, 40%);">+              if (llist_empty(&ctx->pdp_list) && pdp_status_has_active_nsapis(pdp_status, pdp_status_len)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                 reject_cause = GMM_CAUSE_NO_PDP_ACTIVATED;</span><br><span style="color: hsl(120, 100%, 40%);">+                    goto rejected;</span><br><span style="color: hsl(120, 100%, 40%);">+                }</span><br><span>    }</span><br><span> </span><br><span> </span><br><span>diff --git a/tests/sgsn/sgsn_test.c b/tests/sgsn/sgsn_test.c</span><br><span>index 6145206..23cb4fb 100644</span><br><span>--- a/tests/sgsn/sgsn_test.c</span><br><span>+++ b/tests/sgsn/sgsn_test.c</span><br><span>@@ -1575,6 +1575,22 @@</span><br><span>      cleanup_test();</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+bool pdp_status_has_active_nsapis(const uint8_t *pdp_status, const size_t pdp_status_len);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static void test_pdp_status_has_active_nsapis(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+        const size_t pdp_status_len = 2;</span><br><span style="color: hsl(120, 100%, 40%);">+      const uint8_t pdp_status1[] = { 0b00100000, 0b00000000 }; /* PDP NSAPI 5 active */</span><br><span style="color: hsl(120, 100%, 40%);">+    const uint8_t pdp_status2[] = { 0b00000000, 0b00000000 }; /* no active PDP NSAPI */</span><br><span style="color: hsl(120, 100%, 40%);">+   const uint8_t pdp_status3[] = { 0b00000000, 0b00000001 }; /* PDP NSAPI 8 active */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  printf("Testing pdp_status_has_active_nsapis\n");</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ OSMO_ASSERT(pdp_status_has_active_nsapis(pdp_status1, pdp_status_len));</span><br><span style="color: hsl(120, 100%, 40%);">+       OSMO_ASSERT(!pdp_status_has_active_nsapis(pdp_status2, pdp_status_len));</span><br><span style="color: hsl(120, 100%, 40%);">+      OSMO_ASSERT(pdp_status_has_active_nsapis(pdp_status3, pdp_status_len));</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> static struct log_info_cat gprs_categories[] = {</span><br><span>     [DMM] = {</span><br><span>            .name = "DMM",</span><br><span>@@ -1657,6 +1673,7 @@</span><br><span>     test_gmm_cancel();</span><br><span>   test_apn_matching();</span><br><span>         test_ggsn_selection();</span><br><span style="color: hsl(120, 100%, 40%);">+        test_pdp_status_has_active_nsapis();</span><br><span>         printf("Done\n");</span><br><span> </span><br><span>      talloc_report_full(osmo_sgsn_ctx, stderr);</span><br><span>diff --git a/tests/sgsn/sgsn_test.ok b/tests/sgsn/sgsn_test.ok</span><br><span>index e7e7cf6..35b1d7b 100644</span><br><span>--- a/tests/sgsn/sgsn_test.ok</span><br><span>+++ b/tests/sgsn/sgsn_test.ok</span><br><span>@@ -24,4 +24,5 @@</span><br><span> Testing cancellation</span><br><span> Testing APN matching</span><br><span> Testing GGSN selection</span><br><span style="color: hsl(120, 100%, 40%);">+Testing pdp_status_has_active_nsapis</span><br><span> Done</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/13744">change 13744</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/13744"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-sgsn </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: If610cbef17c25ec44e65d4f1b2340d102c560437 </div>
<div style="display:none"> Gerrit-Change-Number: 13744 </div>
<div style="display:none"> Gerrit-PatchSet: 10 </div>
<div style="display:none"> Gerrit-Owner: Mykola Shchetinin <mykola@pentonet.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>
<div style="display:none"> Gerrit-Reviewer: Mykola Shchetinin <mykola@pentonet.com> </div>
<div style="display:none"> Gerrit-Reviewer: Pau Espin Pedrol <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: lynxis lazus <lynxis@fe80.eu> </div>