<p>laforge <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/libosmo-sccp/+/18818">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved
  neels: Looks good to me, but someone else must approve

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">M3UA: Accept DATA without routing context IE if only a single AS in ASP<br><br>There are some M3UA implementations out there who use a routing context<br>during the ASPAC procedure, but who then don't use it in subsequent DATA<br>transmission.<br><br>This behavior seems to be at the edge of what's possible within the<br>spec; if you don't configure a routing context, The RCTX IE it is not<br>required to be sent. And if you have multiple routing contexts/AS within<br>one ASP, it *must* be sent. But the situation where a routing context<br>has been configured (but not multiple) is not explicitly covered.<br><br>Change-Id: I59f47a999f40411aadc88b8f362d8d2b89a66332<br>Closes: OS#4594<br>---<br>M src/m3ua.c<br>1 file changed, 49 insertions(+), 20 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/m3ua.c b/src/m3ua.c</span><br><span>index 5ab3e79..08a89b5 100644</span><br><span>--- a/src/m3ua.c</span><br><span>+++ b/src/m3ua.c</span><br><span>@@ -532,9 +532,26 @@</span><br><span>        return data_hdr;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* if given ASP only has one AS, return that AS */</span><br><span style="color: hsl(120, 100%, 40%);">+static struct osmo_ss7_as *find_single_as_for_asp(struct osmo_ss7_asp *asp)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ struct osmo_ss7_as *as, *as_found = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   llist_for_each_entry(as, &asp->inst->as_list, list) {</span><br><span style="color: hsl(120, 100%, 40%);">+               if (!osmo_ss7_as_has_asp(as, asp))</span><br><span style="color: hsl(120, 100%, 40%);">+                    continue;</span><br><span style="color: hsl(120, 100%, 40%);">+             /* check if we already had found another AS within this ASP -> not unique */</span><br><span style="color: hsl(120, 100%, 40%);">+               if (as_found)</span><br><span style="color: hsl(120, 100%, 40%);">+                 return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+          as_found = as;</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 as_found;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> static int m3ua_rx_xfer(struct osmo_ss7_asp *asp, struct xua_msg *xua)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-    uint32_t rctx = xua_msg_get_u32(xua, M3UA_IEI_ROUTE_CTX);</span><br><span style="color: hsl(120, 100%, 40%);">+     struct xua_msg_part *rctx_ie = xua_msg_find_tag(xua, M3UA_IEI_ROUTE_CTX);</span><br><span>    struct m3ua_data_hdr *dh;</span><br><span>    struct osmo_ss7_as *as;</span><br><span> </span><br><span>@@ -548,23 +565,33 @@</span><br><span>          return M3UA_ERR_UNSUPP_MSG_TYPE;</span><br><span>     }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   /* Use routing context IE to look up the AS for which the</span><br><span style="color: hsl(0, 100%, 40%);">-        * message was received. */</span><br><span style="color: hsl(0, 100%, 40%);">-     as = osmo_ss7_as_find_by_rctx(asp->inst, rctx);</span><br><span style="color: hsl(0, 100%, 40%);">-      if (!as) {</span><br><span style="color: hsl(0, 100%, 40%);">-              LOGPASP(asp, DLM3UA, LOGL_ERROR,</span><br><span style="color: hsl(0, 100%, 40%);">-                        "%s(): invalid routing context: %u\n",</span><br><span style="color: hsl(0, 100%, 40%);">-                        __func__, rctx);</span><br><span style="color: hsl(0, 100%, 40%);">-                return M3UA_ERR_INVAL_ROUT_CTX;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(120, 100%, 40%);">+     if (rctx_ie) {</span><br><span style="color: hsl(120, 100%, 40%);">+                uint32_t rctx = xua_msg_part_get_u32(rctx_ie);</span><br><span style="color: hsl(120, 100%, 40%);">+                /* Use routing context IE to look up the AS for which the</span><br><span style="color: hsl(120, 100%, 40%);">+              * message was received. */</span><br><span style="color: hsl(120, 100%, 40%);">+           as = osmo_ss7_as_find_by_rctx(asp->inst, rctx);</span><br><span style="color: hsl(120, 100%, 40%);">+            if (!as) {</span><br><span style="color: hsl(120, 100%, 40%);">+                    LOGPASP(asp, DLM3UA, LOGL_ERROR, "%s(): invalid routing context: %u\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                             __func__, rctx);</span><br><span style="color: hsl(120, 100%, 40%);">+                      return M3UA_ERR_INVAL_ROUT_CTX;</span><br><span style="color: hsl(120, 100%, 40%);">+               }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   /* Verify that this ASP is part of the AS. */</span><br><span style="color: hsl(0, 100%, 40%);">-   if (!osmo_ss7_as_has_asp(as, asp)) {</span><br><span style="color: hsl(0, 100%, 40%);">-            LOGPASP(asp, DLM3UA, LOGL_ERROR,</span><br><span style="color: hsl(0, 100%, 40%);">-                        "%s(): This Application Server Process is not part of the AS %s resolved by"</span><br><span style="color: hsl(0, 100%, 40%);">-                  " routing context %u\n",</span><br><span style="color: hsl(0, 100%, 40%);">-                      __func__, (as)->cfg.name, rctx);</span><br><span style="color: hsl(0, 100%, 40%);">-             return M3UA_ERR_NO_CONFGD_AS_FOR_ASP;</span><br><span style="color: hsl(120, 100%, 40%);">+         /* Verify that this ASP is part of the AS. */</span><br><span style="color: hsl(120, 100%, 40%);">+         if (!osmo_ss7_as_has_asp(as, asp)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                  LOGPASP(asp, DLM3UA, LOGL_ERROR,</span><br><span style="color: hsl(120, 100%, 40%);">+                              "%s(): This Application Server Process is not part of the AS %s "</span><br><span style="color: hsl(120, 100%, 40%);">+                           "resolved by routing context %u\n", __func__, (as)->cfg.name, rctx);</span><br><span style="color: hsl(120, 100%, 40%);">+                     return M3UA_ERR_NO_CONFGD_AS_FOR_ASP;</span><br><span style="color: hsl(120, 100%, 40%);">+         }</span><br><span style="color: hsl(120, 100%, 40%);">+     } else {</span><br><span style="color: hsl(120, 100%, 40%);">+              /* no explicit routing context; this only works if there is only one AS in the ASP */</span><br><span style="color: hsl(120, 100%, 40%);">+         as = find_single_as_for_asp(asp);</span><br><span style="color: hsl(120, 100%, 40%);">+             if (!as) {</span><br><span style="color: hsl(120, 100%, 40%);">+                    LOGPASP(asp, DLM3UA, LOGL_ERROR,</span><br><span style="color: hsl(120, 100%, 40%);">+                              "%s(): ASP sent M3UA without Routing Context IE but unable to uniquely "</span><br><span style="color: hsl(120, 100%, 40%);">+                            "identify the AS for this message\n", __func__);</span><br><span style="color: hsl(120, 100%, 40%);">+                    return M3UA_ERR_INVAL_ROUT_CTX;</span><br><span style="color: hsl(120, 100%, 40%);">+               }</span><br><span>    }</span><br><span> </span><br><span>        /* FIXME: check for AS state == ACTIVE */</span><br><span>@@ -579,9 +606,11 @@</span><br><span>             __func__, xua->mtp.opc, osmo_ss7_pointcode_print(asp->inst, xua->mtp.opc),</span><br><span>          xua->mtp.dpc, osmo_ss7_pointcode_print2(asp->inst, xua->mtp.dpc));</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- /* remove ROUTE_CTX as in the routing case we want to add a new</span><br><span style="color: hsl(0, 100%, 40%);">-  * routing context on the outbound side */</span><br><span style="color: hsl(0, 100%, 40%);">-      xua_msg_free_tag(xua, M3UA_IEI_ROUTE_CTX);</span><br><span style="color: hsl(120, 100%, 40%);">+    if (rctx_ie) {</span><br><span style="color: hsl(120, 100%, 40%);">+                /* remove ROUTE_CTX as in the routing case we want to add a new</span><br><span style="color: hsl(120, 100%, 40%);">+                * routing context on the outbound side */</span><br><span style="color: hsl(120, 100%, 40%);">+            xua_msg_free_tag(xua, M3UA_IEI_ROUTE_CTX);</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span> </span><br><span>        return m3ua_hmdc_rx_from_l2(asp->inst, xua);</span><br><span>      /* xua will be freed by caller m3ua_rx_msg() */</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmo-sccp/+/18818">change 18818</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/libosmo-sccp/+/18818"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmo-sccp </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I59f47a999f40411aadc88b8f362d8d2b89a66332 </div>
<div style="display:none"> Gerrit-Change-Number: 18818 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-CC: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>