From 36bae67eef91bf21293214e527047c25a40896b7 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Tue, 7 Sep 2021 13:16:39 +0200 Subject: [PATCH] nr-rlc: bugfix: copy correct part of PDUs in case of segmentation --- openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c | 2 +- openair2/LAYER2/nr_rlc/nr_rlc_entity_um.c | 2 +- openair2/LAYER2/nr_rlc/tests/run_tests.sh | 2 +- openair2/LAYER2/nr_rlc/tests/test16.h | 19 +++++++++++++++++++ openair2/LAYER2/nr_rlc/tests/test16.txt.gz | Bin 0 -> 168 bytes openair2/LAYER2/nr_rlc/tests/test17.h | 18 ++++++++++++++++++ openair2/LAYER2/nr_rlc/tests/test17.txt.gz | Bin 0 -> 148 bytes 7 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 openair2/LAYER2/nr_rlc/tests/test16.h create mode 100644 openair2/LAYER2/nr_rlc/tests/test16.txt.gz create mode 100644 openair2/LAYER2/nr_rlc/tests/test17.h create mode 100644 openair2/LAYER2/nr_rlc/tests/test17.txt.gz diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c index 08f5b11c23..8db5ce31ad 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c @@ -218,7 +218,7 @@ static void reassemble_and_deliver(nr_rlc_entity_am_t *entity, int sn) bad_sdu = 1; } if (!bad_sdu && len > 0) { - memcpy(sdu + so, pdu->data, len); + memcpy(sdu + so, pdu->data + so - pdu->so, len); so += len; } free(pdu->data); diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity_um.c b/openair2/LAYER2/nr_rlc/nr_rlc_entity_um.c index f967c3c543..71173eee5a 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity_um.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity_um.c @@ -148,7 +148,7 @@ static void reassemble_and_deliver(nr_rlc_entity_um_t *entity, int sn) bad_sdu = 1; } if (!bad_sdu && len > 0) { - memcpy(sdu + so, pdu->data, len); + memcpy(sdu + so, pdu->data + so - pdu->so, len); so += len; } free(pdu->data); diff --git a/openair2/LAYER2/nr_rlc/tests/run_tests.sh b/openair2/LAYER2/nr_rlc/tests/run_tests.sh index a98f6b5d0f..7ca4798861 100755 --- a/openair2/LAYER2/nr_rlc/tests/run_tests.sh +++ b/openair2/LAYER2/nr_rlc/tests/run_tests.sh @@ -1,6 +1,6 @@ #!/bin/sh -test_count=15 +test_count=17 for i in `seq $test_count` do diff --git a/openair2/LAYER2/nr_rlc/tests/test16.h b/openair2/LAYER2/nr_rlc/tests/test16.h new file mode 100644 index 0000000000..92f9923809 --- /dev/null +++ b/openair2/LAYER2/nr_rlc/tests/test16.h @@ -0,0 +1,19 @@ +/* + * am test (SN field size 18): + * there was a bug when we receive a full PDU after receiving only the + * beginning of it; the data was copied at the end but from the start of the + * full PDU instead of the correct offset. This test captures this case. + * Gnb sends the start of a PDU then the full PDU. That is the SDU is + * [00 .. 09]. First gnb sends [00 .. 08] then it sends [00 .. 09]. + */ + +TIME, 1, + GNB_AM, 100000, 100000, 45, 35, 0, -1, -1, 8, 18, + UE_AM, 100000, 100000, 45, 35, 0, -1, -1, 8, 18, + GNB_PDU_SIZE, 12, + UE_PDU_SIZE, 20, + GNB_PDU, 12, 0x90, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, +TIME, 2, + GNB_PDU_SIZE, 20, + GNB_PDU, 13, 0xc0, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, +TIME, -1 diff --git a/openair2/LAYER2/nr_rlc/tests/test16.txt.gz b/openair2/LAYER2/nr_rlc/tests/test16.txt.gz new file mode 100644 index 0000000000000000000000000000000000000000..74b19724aab10fcde721e98fa8e7565616eb133e GIT binary patch literal 168 zcmV;Z09XGXiwFpENH<{u19W9`bTKwAba-?C3vmq&u~H~5Nh~Vi3IVg-{hX{646PKB zON&eLa}@$yLV@y`RjCSwMpg>Z3YG>625@AkU|^(RV60$ZqF`XEU|^=Hc7$25@uMaE7(;jsX3WtsYMFGE}>Af41h)vZ356W>8W|CMTsS;@dYWR WQ1^hH19gZ=EEfRSWj{L<0RR98);?kY literal 0 HcmV?d00001 diff --git a/openair2/LAYER2/nr_rlc/tests/test17.h b/openair2/LAYER2/nr_rlc/tests/test17.h new file mode 100644 index 0000000000..3da9fcc6e5 --- /dev/null +++ b/openair2/LAYER2/nr_rlc/tests/test17.h @@ -0,0 +1,18 @@ +/* + * um test (SN field size 12): + * same problem as for test16, but we test by sending [00 .. 08] then + * [02 .. 09] (they overlap, the full SDU is [00 .. 09]), which probably + * never occurs in practice but triggers the bug. Doing as for test16 does + * not trigger the bug. + */ + +TIME, 1, + GNB_UM, 100000, 100000, 35, 12, + UE_UM, 100000, 100000, 35, 12, + GNB_PDU_SIZE, 8, + UE_PDU_SIZE, 20, + GNB_PDU, 11, 0x40, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, +TIME, 2, + GNB_PDU_SIZE, 20, + GNB_PDU, 12, 0x80, 0x00, 0x00, 0x02, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, +TIME, -1 diff --git a/openair2/LAYER2/nr_rlc/tests/test17.txt.gz b/openair2/LAYER2/nr_rlc/tests/test17.txt.gz new file mode 100644 index 0000000000000000000000000000000000000000..b30f671617a67a09b01e8016f96b5de33e669e73 GIT binary patch literal 148 zcmV;F0BipriwFplNH<{u19W9`bTKzBba-?C3vmq&u~H~5Nh~Vi3IVg-{hX{646PKB zON&eLa}@$yLV@y`RjCSwK*4AQ69WYU2r^VKFj6ouRxmJ8FfdgxFjFuvS1_=MMK;C= zn=wWpV=Umt7-2O=!N3w`Qm8A~Jt?U