<p>fixeria has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-pcu/+/17392">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">rlcmac: fix encode_gsm_*(): do not suspend encoding errors<br><br>Change-Id: Ieec8e6e0823c6f6985f9d343af6d503b8fe9e6ab<br>---<br>M src/gsm_rlcmac.cpp<br>M tests/rlcmac/RLCMACTest.cpp<br>M tests/rlcmac/RLCMACTest.err<br>M tests/rlcmac/RLCMACTest.ok<br>4 files changed, 10 insertions(+), 8 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/92/17392/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/gsm_rlcmac.cpp b/src/gsm_rlcmac.cpp</span><br><span>index e8ce2ef..781e273 100644</span><br><span>--- a/src/gsm_rlcmac.cpp</span><br><span>+++ b/src/gsm_rlcmac.cpp</span><br><span>@@ -5429,8 +5429,8 @@</span><br><span>   LOGPC(DCSN1, LOGL_INFO, "\n");</span><br><span> </span><br><span>   if (ret > 0) {</span><br><span style="color: hsl(0, 100%, 40%);">-    LOGP(DRLCMACDATA, LOGL_NOTICE, "Got %d remaining bits unhandled by encoder at the end of bitvec\n", ret);</span><br><span style="color: hsl(0, 100%, 40%);">-    ret = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+    LOGP(DRLCMACDATA, LOGL_ERROR, "Failed to encode an Uplink block: not enough bits "</span><br><span style="color: hsl(120, 100%, 40%);">+                                  "in the output buffer, need more %d\n", ret);</span><br><span>   }</span><br><span> </span><br><span>   return ret;</span><br><span>@@ -5635,8 +5635,8 @@</span><br><span>   LOGPC(DCSN1, LOGL_INFO, "\n");</span><br><span> </span><br><span>   if (ret > 0) {</span><br><span style="color: hsl(0, 100%, 40%);">-    LOGP(DRLCMACDATA, LOGL_NOTICE, "Got %d remaining bits unhandled by encoder at the end of bitvec\n", ret);</span><br><span style="color: hsl(0, 100%, 40%);">-    ret = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+    LOGP(DRLCMACDATA, LOGL_ERROR, "Failed to encode a Downlink block: not enough bits "</span><br><span style="color: hsl(120, 100%, 40%);">+                                  "in the output buffer, need more %d\n", ret);</span><br><span>   }</span><br><span> </span><br><span>   return ret;</span><br><span>@@ -5818,8 +5818,8 @@</span><br><span>   LOGPC(DCSN1, LOGL_INFO, "\n");</span><br><span> </span><br><span>   if (ret > 0) {</span><br><span style="color: hsl(0, 100%, 40%);">-    LOGP(DRLCMACDATA, LOGL_NOTICE, "Got %d remaining bits unhandled by encoder at the end of bitvec\n", ret);</span><br><span style="color: hsl(0, 100%, 40%);">-    ret = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+    LOGP(DRLCMACDATA, LOGL_ERROR, "Failed to encode MS RA Capability IE: not enough bits "</span><br><span style="color: hsl(120, 100%, 40%);">+                                  "in the output buffer, need more %d\n", ret);</span><br><span>   }</span><br><span> </span><br><span>   return ret;</span><br><span>diff --git a/tests/rlcmac/RLCMACTest.cpp b/tests/rlcmac/RLCMACTest.cpp</span><br><span>index a1dde77..63498ca 100644</span><br><span>--- a/tests/rlcmac/RLCMACTest.cpp</span><br><span>+++ b/tests/rlcmac/RLCMACTest.cpp</span><br><span>@@ -284,7 +284,7 @@</span><br><span> {</span><br><span>         void *ctx = talloc_named_const(NULL, 1, "RLCMACTest");</span><br><span>     osmo_init_logging2(ctx, &gprs_log_info);</span><br><span style="color: hsl(0, 100%, 40%);">-    log_parse_category_mask(osmo_stderr_target, "DPCU,3:DLGLOBAL,1:DCSN1,2:");</span><br><span style="color: hsl(120, 100%, 40%);">+  log_parse_category_mask(osmo_stderr_target, "DPCU,3:DLGLOBAL,1:DRLCMACDATA,2:DCSN1,2:");</span><br><span> </span><br><span>       log_set_print_filename2(osmo_stderr_target, LOG_FILENAME_NONE);</span><br><span>      log_set_print_category_hex(osmo_stderr_target, 0);</span><br><span>diff --git a/tests/rlcmac/RLCMACTest.err b/tests/rlcmac/RLCMACTest.err</span><br><span>index d7a438b..b52f0e8 100644</span><br><span>--- a/tests/rlcmac/RLCMACTest.err</span><br><span>+++ b/tests/rlcmac/RLCMACTest.err</span><br><span>@@ -32,5 +32,7 @@</span><br><span> DCSN1 INFO csnStreamEncoder (type=2): PayloadType = 1 | spare = 0 | R = 0 | MESSAGE_TYPE = 2 | DOWNLINK_TFI = 20 |  : Ack_Nack_Description | FINAL_ACK_INDICATION = 1 | STARTING_SEQUENCE_NUMBER = 1 | RECEIVED_BLOCK_BITMAP[0] = 0 | RECEIVED_BLOCK_BITMAP[1] = 0 | RECEIVED_BLOCK_BITMAP[2] = 0 | RECEIVED_BLOCK_BITMAP[3] = 0 | RECEIVED_BLOCK_BITMAP[4] = 0 | RECEIVED_BLOCK_BITMAP[5] = 0 | RECEIVED_BLOCK_BITMAP[6] = 0 | RECEIVED_BLOCK_BITMAP[7] = 1 |  : End Ack_Nack_Description | Exist_Channel_Request_Description = 1 |  : Channel_Request_Description | PEAK_THROUGHPUT_CLASS = 0 | RADIO_PRIORITY = 0 | RLC_MODE = 0 | LLC_PDU_TYPE = 1 | RLC_OCTET_COUNT = 18 |  : End Channel_Request_Description |  : Channel_Quality_Report | C_VALUE = 40 | RXQUAL = 1 | SIGN_VAR = 0 | Slot[0].Exist = 0 | Slot[1].Exist = 0 | Slot[2].Exist = 0 | Slot[3].Exist = 0 | Slot[4].Exist = 0 | Slot[5].Exist = 0 | Slot[6].Exist = 0 | Slot[7].Exist = 0 |  : End Channel_Quality_Report | Exist_AdditionsR99 = 1 |  : AdditionsR99 | Exist_PFI = 0 |  : End AdditionsR99 | Padding = 3|43|43|43|43|43|</span><br><span> DCSN1 INFO csnStreamDecoder (type=8): PayloadType = 1 | spare = 0 | R = 0 | MESSAGE_TYPE = 8 | DOWNLINK_TFI = 0 | MS_OUT_OF_MEMORY = 0 | Exist_EGPRS_ChannelQualityReport = 1 |  : EGPRS_ChannelQualityReport |  : EGPRS_BEP_LinkQualityMeasurements | Exist_MEAN_CV_BEP_GMSK = 0 | Exist_MEAN_CV_BEP_8PSK = 1 | MEAN_BEP_8PSK = 31 | CV_BEP_8PSK = 7 | : End EGPRS_BEP_LinkQualityMeasurements | C_VALUE = 58 |  : EGPRS_TimeslotLinkQualityMeasurements | Exist_BEP_MEASUREMENTS = 0 | Exist_INTERFERENCE_MEASUREMENTS = 0 | : End EGPRS_TimeslotLinkQualityMeasurements | : End EGPRS_ChannelQualityReport | Exist_ChannelRequestDescription = 1 |  : ChannelRequestDescription | PEAK_THROUGHPUT_CLASS = 6 | RADIO_PRIORITY = 0 | RLC_MODE = 0 | LLC_PDU_TYPE = 1 | RLC_OCTET_COUNT = 62 | : End ChannelRequestDescription | Exist_PFI = 0 | Exist_ExtensionBits = 0 |  : EGPRS_AckNack | Desc = 0 |  : Desc | FINAL_ACK_INDICATION = 0 | BEGINNING_OF_WINDOW = 1 | END_OF_WINDOW = 1 | STARTING_SEQUENCE_NUMBER = 1187 | Exist_CRBB = 0 | URBB = 127 | URBB = 255 | URBB = 255 | URBB = 238 | URBB = 0 | URBB = 0 | URBB = 0 | URBB = 0 | URBB = 0 | URBB = 0 | URBB = 0 | URBB = 0 | URBB = 0 |  : End Desc | : End EGPRS_AckNack | Padding = </span><br><span> DCSN1 INFO csnStreamDecoder (RAcap): MS_RA_capability_value { | Choice MS_RA_capability_value_Choice = 1 | u.Content length = 29 | offset = 4 | RF_Power_Capability = 1 | Exist_A5_bits = 0 | ES_IND = 1 | PS = 0 | VGCS = 0 | VBS = 0 | Exist_Multislot_capability = 1 |  : Multislot_capability | Exist_HSCSD_multislot_class = 0 | Exist_GPRS_multislot_class = 1 | GPRS_multislot_class = 3 | GPRS_Extended_Dynamic_Allocation_Capability = 0 | Exist_SM = 0 | Exist_ECSD_multislot_class = 0 | Exist_EGPRS_multislot_class = 1 | EGPRS_multislot_class = 0 | EGPRS_Extended_Dynamic_Allocation_Capability = 0 | Exist_DTM_GPRS_multislot_class = 0 | : End Multislot_capability | Exist_Eight_PSK_Power_Capability = 0 | COMPACT_Interference_Measurement_Capability = 0 | Revision_Level_Indicator = NULL | UMTS_FDD_Radio_Access_Technology_Capability = NULL | UMTS_384_TDD_Radio_Access_Technology_Capability = NULL | CDMA2000_Radio_Access_Technology_Capability = NULL | UMTS_128_TDD_Radio_Access_Technology_Capability = NULL | GERAN_Feature_Package_1 = NULL | Modulation_based_multislot_class_support = NULL | GMSK_MultislotPowerProfile = NULL | EightPSK_MultislotProfile = NULL | MultipleTBF_Capability = NULL | DownlinkAdvancedReceiverPerformance = NULL | ExtendedRLC_MAC_ControlMessageSegmentionsCapability = NULL | DTM_EnhancementsCapability = NULL | PS_HandoverCapability = NULL | DTM_Handover_Capability = NULL | FlexibleTimeslotAssignment = NULL | GAN_PS_HandoverCapability = NULL | RLC_Non_persistentMode = NULL | ReducedLatencyCapability = NULL | UplinkEGPRS2 = NULL | DownlinkEGPRS2 = NULL | EUTRA_FDD_Support = NULL | EUTRA_TDD_Support = NULL | GERAN_To_EUTRAN_supportInGERAN_PTM = NULL | PriorityBasedReselectionSupport = NULL | MS_RA_capability_value } | </span><br><span style="color: hsl(120, 100%, 40%);">+DRLCMACDATA NOTICE Got 143 remaining bits unhandled by decoder at the end of bitvec</span><br><span> DCSN1 INFO csnStreamEncoder (RAcap): MS_RA_capability_value { | u.Content = 1 | RF_Power_Capability = 1 | Exist_A5_bits = 0 | ES_IND = 1 | PS = 0 | VGCS = 0 | VBS = 0 | Exist_Multislot_capability = 1 |  : Multislot_capability | Exist_HSCSD_multislot_class = 0 | Exist_GPRS_multislot_class = 1 | GPRS_multislot_class = 3 | GPRS_Extended_Dynamic_Allocation_Capability = 0 | Exist_SM = 0 | Exist_ECSD_multislot_class = 0 | Exist_EGPRS_multislot_class = 1 | EGPRS_multislot_class = 0 | EGPRS_Extended_Dynamic_Allocation_Capability = 0 | Exist_DTM_GPRS_multislot_class = 0 |  : End Multislot_capability | Exist_Eight_PSK_Power_Capability = 0 | COMPACT_Interference_Measurement_Capability = 0 | Revision_Level_Indicator = 0 | UMTS_FDD_Radio_Access_Technology_Capability = 0 | UMTS_384_TDD_Radio_Access_Technology_Capability = 0 | CDMA2000_Radio_Access_Technology_Capability = 0 | UMTS_128_TDD_Radio_Access_Technology_Capability = 0 | GERAN_Feature_Package_1 = 0 | Exist_Extended_DTM_multislot_class = 0 | Modulation_based_multislot_class_support = 0 | Exist_HighMultislotCapability = 0 | Exist_GERAN_lu_ModeCapability = 0 | GMSK_MultislotPowerProfile = 0 | EightPSK_MultislotProfile = 0 | MultipleTBF_Capability = 0 | DownlinkAdvancedReceiverPerformance = 0 | ExtendedRLC_MAC_ControlMessageSegmentionsCapability = 0 | DTM_EnhancementsCapability = 0 | Exist_DTM_GPRS_HighMultislotClass = 0 | PS_HandoverCapability = 0 | DTM_Handover_Capability = 0 | Exist_DownlinkDualCarrierCapability_r7 = 0 | FlexibleTimeslotAssignment = 0 | GAN_PS_HandoverCapability = 0 | RLC_Non_persistentMode = 0 | ReducedLatencyCapability = 0 | UplinkEGPRS2 = 0 | DownlinkEGPRS2 = 0 | EUTRA_FDD_Support = 0 | EUTRA_TDD_Support = 0 | GERAN_To_EUTRAN_supportInGERAN_PTM = 0 | PriorityBasedReselectionSupport = 0 | u.Content length = 65 | MS_RA_capability_value } | </span><br><span style="color: hsl(120, 100%, 40%);">+DRLCMACDATA ERROR Failed to encode MS RA Capability IE: not enough bits in the output buffer, need more 107</span><br><span> DCSN1 INFO csnStreamDecoder (RAcap): MS_RA_capability_value { | Choice MS_RA_capability_value_Choice = 1 | u.Content length = 21 | offset = 4 | RF_Power_Capability = 1 | Exist_A5_bits = 0 | ES_IND = 1 | PS = 0 | VGCS = 0 | VBS = 0 | Exist_Multislot_capability = 1 |  : Multislot_capability | Exist_HSCSD_multislot_class = 0 | Exist_GPRS_multislot_class = 1 | GPRS_multislot_class = 3 | GPRS_Extended_Dynamic_Allocation_Capability = 0 | Exist_SM = 0 | Exist_ECSD_multislot_class = 0 | Exist_EGPRS_multislot_class = 1 | DCSN1 ERROR csnStreamDecoder: error NEED_MORE BITS TO UNPACK (-5) at EGPRS_multislot_class (idx 31): End Multislot_capability | </span><br><span>diff --git a/tests/rlcmac/RLCMACTest.ok b/tests/rlcmac/RLCMACTest.ok</span><br><span>index 438417f..3c9d8b0 100644</span><br><span>--- a/tests/rlcmac/RLCMACTest.ok</span><br><span>+++ b/tests/rlcmac/RLCMACTest.ok</span><br><span>@@ -136,7 +136,7 @@</span><br><span> GPRS multislot class = 3</span><br><span> EGPRS multislot class = 0</span><br><span> === Test encoding of MS RA Capability ===</span><br><span style="color: hsl(0, 100%, 40%);">-encode_gsm_ra_cap() returns 0</span><br><span style="color: hsl(120, 100%, 40%);">+encode_gsm_ra_cap() returns 107</span><br><span> vector1 (len_ind=29) = 13 a5 14 62 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 </span><br><span> vector2 (len_ind=65) = 18 25 14 62 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 </span><br><span> === Test decoding of a malformed vector (short length indicator) ===</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-pcu/+/17392">change 17392</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-pcu/+/17392"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-pcu </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ieec8e6e0823c6f6985f9d343af6d503b8fe9e6ab </div>
<div style="display:none"> Gerrit-Change-Number: 17392 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: fixeria <axilirator@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>