<p>neels has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-bsc/+/18783">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">MSC pooling: LU: ignore TMSI NRI from a different PLMN<br><br>Change-Id: Iac1158cff022b6365ce22bb70feaaff93e39172a<br>---<br>M src/osmo-bsc/gsm_08_08.c<br>1 file changed, 49 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/83/18783/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/osmo-bsc/gsm_08_08.c b/src/osmo-bsc/gsm_08_08.c</span><br><span>index 0707c65..46ef9af 100644</span><br><span>--- a/src/osmo-bsc/gsm_08_08.c</span><br><span>+++ b/src/osmo-bsc/gsm_08_08.c</span><br><span>@@ -123,6 +123,48 @@</span><br><span>       return cm->cm_service_type == GSM48_CMSERV_EMERGENCY;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static bool is_lu_from_other_plmn(struct msgb *msg)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+     const struct gsm48_hdr *gh;</span><br><span style="color: hsl(120, 100%, 40%);">+   int8_t pdisc;</span><br><span style="color: hsl(120, 100%, 40%);">+ uint8_t mtype;</span><br><span style="color: hsl(120, 100%, 40%);">+        const struct gsm48_loc_upd_req *lu;</span><br><span style="color: hsl(120, 100%, 40%);">+   struct osmo_location_area_id old_lai;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       if (msgb_l3len(msg) < sizeof(*gh))</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%);">+       gh = msgb_l3(msg);</span><br><span style="color: hsl(120, 100%, 40%);">+    pdisc = gsm48_hdr_pdisc(gh);</span><br><span style="color: hsl(120, 100%, 40%);">+  mtype = gsm48_hdr_msg_type(gh);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     switch (pdisc) {</span><br><span style="color: hsl(120, 100%, 40%);">+      case GSM48_PDISC_MM:</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+                switch (mtype) {</span><br><span style="color: hsl(120, 100%, 40%);">+              case GSM48_MT_MM_LOC_UPD_REQUEST:</span><br><span style="color: hsl(120, 100%, 40%);">+                     /* First make sure that lu-> can be dereferenced */</span><br><span style="color: hsl(120, 100%, 40%);">+                        if (msgb_l3len(msg) < sizeof(*gh) + sizeof(*lu))</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%);">+                       lu = (struct gsm48_loc_upd_req*)gh->data;</span><br><span style="color: hsl(120, 100%, 40%);">+                  gsm48_decode_lai2(&lu->lai, &old_lai);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+                   if (osmo_plmn_cmp(&old_lai.plmn, &bsc_gsmnet->plmn) != 0)</span><br><span style="color: hsl(120, 100%, 40%);">+                          return true;</span><br><span style="color: hsl(120, 100%, 40%);">+                  break;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+              default:</span><br><span style="color: hsl(120, 100%, 40%);">+                      break;</span><br><span style="color: hsl(120, 100%, 40%);">+                }</span><br><span style="color: hsl(120, 100%, 40%);">+             break;</span><br><span style="color: hsl(120, 100%, 40%);">+        default:</span><br><span style="color: hsl(120, 100%, 40%);">+              break;</span><br><span style="color: hsl(120, 100%, 40%);">+        }</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> static bool is_msc_usable(struct bsc_msc_data *msc, bool is_emerg)</span><br><span> {</span><br><span>        if (is_emerg && !msc->allow_emerg)</span><br><span>@@ -198,6 +240,13 @@</span><br><span>                 if (osmo_tmsi_nri_v_get(&nri_v, mi.tmsi, net->nri_bitlen)) {</span><br><span>                  LOGP(DMSC, LOGL_ERROR, "Unable to retrieve NRI from TMSI, nri_bitlen == %u\n", net->nri_bitlen);</span><br><span>                        nri_v = -1;</span><br><span style="color: hsl(120, 100%, 40%);">+           } else if (is_lu_from_other_plmn(msg)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                      /* If a subscriber was previously attached to a different PLMN, it might still send the other</span><br><span style="color: hsl(120, 100%, 40%);">+                  * PLMN's TMSI identity in an IMSI Attach. The LU sends a LAI indicating the previous PLMN. If</span><br><span style="color: hsl(120, 100%, 40%);">+                     * it mismatches our PLMN, ignore the NRI. */</span><br><span style="color: hsl(120, 100%, 40%);">+                 LOG_NRI(LOGL_DEBUG,</span><br><span style="color: hsl(120, 100%, 40%);">+                           "This LU Request indicates a switch from another PLMN. Ignoring the TMSI's NRI.\n");</span><br><span style="color: hsl(120, 100%, 40%);">+                    nri_v = -1;</span><br><span>          } else {</span><br><span>                     is_null_nri = osmo_nri_v_matches_ranges(nri_v, net->null_nri_ranges);</span><br><span>                     if (is_null_nri)</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-bsc/+/18783">change 18783</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/c/osmo-bsc/+/18783"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-bsc </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Iac1158cff022b6365ce22bb70feaaff93e39172a </div>
<div style="display:none"> Gerrit-Change-Number: 18783 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>