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

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">gprs_ns2: truncate the NS_STATUS to the MTU<br><br>A NS Status can contain the original NS message which might result<br>in a NS PDU which exceeds the MTU of the NS-VC.<br>Truncate the original message to the maximum possible.<br>Based on truncate BSSGP status message.<br><br>Related: OS#4889<br>Change-Id: I35d8f8bf0eae890f4db56423da0b23b638d24311<br>---<br>M src/gb/gprs_ns2_message.c<br>1 file changed, 7 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/gb/gprs_ns2_message.c b/src/gb/gprs_ns2_message.c</span><br><span>index bfb8781..7f52c4b 100644</span><br><span>--- a/src/gb/gprs_ns2_message.c</span><br><span>+++ b/src/gb/gprs_ns2_message.c</span><br><span>@@ -432,6 +432,7 @@</span><br><span>     struct msgb *msg = ns2_msgb_alloc();</span><br><span>         struct gprs_ns_hdr *nsh;</span><br><span>     uint16_t nsvci = osmo_htons(nsvc->nsvci);</span><br><span style="color: hsl(120, 100%, 40%);">+  unsigned int orig_len, max_orig_len;</span><br><span> </span><br><span>     log_set_context(LOG_CTX_GB_NSE, nsvc->nse);</span><br><span>       log_set_context(LOG_CTX_GB_NSVC, nsvc);</span><br><span>@@ -461,8 +462,12 @@</span><br><span>       case NS_CAUSE_PROTO_ERR_UNSPEC:</span><br><span>      case NS_CAUSE_INVAL_ESSENT_IE:</span><br><span>       case NS_CAUSE_MISSING_ESSENT_IE:</span><br><span style="color: hsl(0, 100%, 40%);">-                msgb_tvlv_put(msg, NS_IE_PDU, msgb_l2len(orig_msg),</span><br><span style="color: hsl(0, 100%, 40%);">-                           orig_msg->l2h);</span><br><span style="color: hsl(120, 100%, 40%);">+              /* ensure the PDU doesn't exceed the MTU */</span><br><span style="color: hsl(120, 100%, 40%);">+               orig_len = msgb_l2len(orig_msg);</span><br><span style="color: hsl(120, 100%, 40%);">+              max_orig_len = msgb_length(msg) + TVLV_GROSS_LEN(orig_len);</span><br><span style="color: hsl(120, 100%, 40%);">+           if (max_orig_len > nsvc->bind->mtu)</span><br><span style="color: hsl(120, 100%, 40%);">+                  orig_len -= max_orig_len - nsvc->bind->mtu;</span><br><span style="color: hsl(120, 100%, 40%);">+             msgb_tvlv_put(msg, NS_IE_PDU, orig_len, orig_msg->l2h);</span><br><span>           break;</span><br><span>       default:</span><br><span>             break;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/22910">change 22910</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/libosmocore/+/22910"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I35d8f8bf0eae890f4db56423da0b23b638d24311 </div>
<div style="display:none"> Gerrit-Change-Number: 22910 </div>
<div style="display:none"> Gerrit-PatchSet: 10 </div>
<div style="display:none"> Gerrit-Owner: lynxis lazus <lynxis@fe80.eu> </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: lynxis lazus <lynxis@fe80.eu> </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>