Commit Graph

146 Commits

Author SHA1 Message Date
Pau Espin 05ff552f25 stream_{cli,srv}: Add 'res' param to read_cb2
Notify user about read errors, similar to what is supported in the
earlier ofd cb backend of osmo_stream_cli/srv:
https://osmocom.org/issues/6405#note-15

Related: OS#6405
Fixes: 5fec34a9f2
Fixes: 0245cf5e07
Change-Id: I395c75ff1e9904757ce1d767a9ac2f779593c4c8
2024-04-18 10:55:13 +02:00
Pau Espin 01f33ec93f tests/stream: Fix missing msgb_free()
Rework a bit the function to early free the rx msg when it is no longer
needed.

Change-Id: I7e7579175aa6a7c1c22eb3bc147a67f6f62ad6bc
2024-04-18 10:52:35 +02:00
arehbein 04d35cda72 stream_test: Fix memleaks
- Clean up all allocations, introduce clean memory management to entire
   test

Related: OS#6222

Change-Id: Ica25fcd71e8bf8946def3ea7ce320354ea6edb3a
2023-10-18 03:55:38 +02:00
arehbein 0aa9a5f783 stream_test: Improve mem mgmt, fix connection mgmt
- Use tall_test as root context everywhere, don't create any other contexts
 - change .*_(cli|srv)_run_client() signature by adding talloc context as parameter
 - Open and Close server link inside test_recon()

Related: OS#6222
Change-Id: I9ef02ed113bc049ae430b93d0eb69641e2ee809b
2023-10-18 03:55:33 +02:00
arehbein 106b63907a stream: Add and use helper function osmo_ipa_push_headers()
Related OS#5753, OS#5751

Change-Id: I61e1fe59166c46595efe8c1f32b8f2607cb6c529
2023-10-09 12:49:36 +00:00
arehbein 64d9b5487a stream (test): Fix Coverity CID 323456
Fix Coverity CID 323456 ("Control flow issues  (NO_EFFECT)") by removing
'greater than 0'-check on unsigned integer-type variable.

Change-Id: I2efb28feae4d4fa7516702f01026af09aa3777ac
2023-10-05 18:44:19 +02:00
arehbein bc496b1db0 stream: Add client-side (segmentation) support for IPA
With this commit, IPA segmentation is taken care of by setting the
segmentation callback provided by libosmo-netif.

The ipa-stream-server example needs to prepend IPA headers now because
those are stripped by the segm. cb on both sides.

Depends: libosmocore.git I3a639e6896cc3b3fc8e9b2e1a58254710efa0d3f

Related: OS#5753, OS#5751
Change-Id: I822abf52c6ae396c90b5c50228a0a39c848d3de6
2023-10-02 13:40:01 +00:00
arehbein 82e1ae260f stream_test: Disable nagling
Disable nagling to make kernel packet processing time more predictable

Change-Id: I7e8f6851df28e006fcb714673b97cf7b6be367bf
2023-10-02 13:40:01 +00:00
Pau Espin fd2eaea824 Bump version: 1.3.0.56-745c-dirty → 1.4.0
Change-Id: I2f0d6617c89cff83b1937996006ffe7106db2557
2023-09-12 13:50:26 +02:00
Pau Espin 23f7d850a3 stream_test: Avoid leaking osmo_stream_srv_link
Change-Id: I43b7327893c220447492d2c36c87b187a414cbdb
2023-09-04 16:48:46 +02:00
arehbein aede010687 stream test: Fix test output check
A previous commit added additional logging information, necessitating changes to
the test code as well as to the output check.

Related:OS#5753

Change-Id: Ib8f01c3651c13814c212328946415094da39d6a8
2023-08-25 17:43:49 +02:00
arehbein f990b307bd stream: Add server-side (segmentation) support for IPA
With this commit, IPA segmentation can be taken care of by setting
the segmentation callback osmo_ipa_segmentation_cb().

Depends: libosmocore.git I3a639e6896cc3b3fc8e9b2e1a58254710efa0d3f

Related: OS#5753, OS#5751
Change-Id: I6c91ff385cb5f36ab6b6c96d0e44997995d0d24c
2023-08-25 13:26:46 +00:00
Pau Espin b8fb69542b stream_srv: Improve logging lines accepting new connections
Change-Id: Iaca9a99417d2f1dbf449e2b20e5dfcdd5e05b683
2023-08-07 19:16:24 +02:00
Pau Espin 1f7c44a17c stream_cli: Increase log level of established conn to INFO
Change-Id: I49776db0b12ee46b629381d2fa2b501c2a63e390
2023-08-07 19:16:24 +02:00
Pau Espin b04f0384ee stream: Print socket info as part of the logging context
Since the local port is logged now in stream_test, it must be set to
a specific value in order to have deterministic log output being
validated.

Change-Id: I17ef699dab72c1b613708070d22e9f040b0fe069
2023-06-20 13:48:25 +02:00
Pau Espin 64c241be5d stream: Allow setting name printed during logging
Depends: libosmocore.git Change-Id If2772a3ccaa98616e0189862a49ab0243435e343
Change-Id: I539a0d29d11348efe702f971965a55cf56db5c59
2023-06-20 09:05:24 +00:00
Daniel Willmann d455f9e60a stream: Update log messages
Change-Id: Ife20b9d18e6ca86a06991d68165694e31052c58a
2023-06-08 16:57:14 +02:00
Vadim Yanitskiy 761f42b31e tests/Makefile.am: clean up AM_* variables
* -I is a preprocessor flag, so it should be in AM_CPPFLAGS
* $(LIBOSMOCORE_LDFLAGS) is not defined here, remove it

Change-Id: Ice892f848e06b601e67b06a4e1e25c11fb7c4128
2023-03-13 04:46:02 +07:00
Vadim Yanitskiy c8620bf275 {utils,tests}/Makefile.am: reorder libraries in LDADD
Otherwise the linker may pick system-installed libs instead.

Change-Id: Ia639b1c5460ad9391d2c311b4978ca9374789f7a
2023-03-13 04:45:51 +07:00
Pau Espin e63329eb1f Bump version: 1.2.0.114-3804-dirty → 1.3.0
Change-Id: Id67541378193f22f924409f02301f0063aab639e
2023-02-07 13:28:19 +01:00
Pau Espin 678c7fc8fe amr: Support all SID and NO_DATA amr formats
Related: SYS#6161
Change-Id: I0e766b3231f03ea87d89fad6ecdce3bd14769054
2022-12-19 19:44:16 +01:00
Pau Espin c2228b7674 tests/amr: Add test case for unused FT=14
FT=15 will be accepted in follow-up patch, so keep a tests checking the
invalid FT code path.

Change-Id: I5872921f5d4a909261e770ddecf048329200724b
2022-12-19 17:38:40 +01:00
Pau Espin 8eeb8220e1 tests/osmux: Add extra asserts to validate osmux header is pulled correctly
Change-Id: Ie2ccc22c53c33025c477236166ea97972c21ec3e
2022-11-21 10:56:52 +01:00
Pau Espin fbce10e286 osmux: Improve logging of osmux_xfrm_input
This allows easily identifying and following state and lifecycle of
CIDs when looking at logs.

Related: SYS#6161
Change-Id: I6a3113dfaef0adbb20162985e3b7d57c46dbc016
2022-11-21 10:56:47 +01:00
Pau Espin 22b4e8159d osmux: Introduce API osmux_xfrm_input_set_name()
This will be used internally by osmux code to print more meaningful
lines.

Related: SYS#6161
Change-Id: Ibbcfdb23a6015ce45840bb64b2b560c2806f7ff6
2022-11-18 17:37:46 +01:00
Pau Espin c798429cb0 osmux: Support recreating lost RTP packets at start of the batch
Previously, if RTP jumps were detected in the incoming RTP stream and
osmux state for that circuit was to start the next batch, the hole would
not been filled during queueing time and instead the encoder would have
set the M bit in the osmuxhdr to announce a sync point.
For small holes (eg less than the batch factor) it makes sense to start
filling the batch with crafted RTP packets in order to avoid the encoder
later on setting the M bit and hence avoid the peer receiving the Osmux
frame having to start a new syncrhonization point.

Related: SYS#6161
Change-Id: I9596501adf5b7b91983618c92c7b1792ee9461a3
2022-11-18 16:46:00 +01:00
Pau Espin b8ef4a0853 osmux: Set M bit in osmuxhdr if seqnum hole found encoding RTP pkts
So far only small intra-batch seqnum jumps are filled in with forged RTP
packets when storing the incoming RTP packets.
Under some conditions, holes may still exist in the queue of RTP packets
for a stream:
* Seqnum detected when first incoming RTP in batch is queued (this can
  be improved in the future).
* Big seqnum jumps > batch_factor or simply filling out of bounds for currently
  enqueued batch.

Specially the second case can come from long network dropouts, or simply
due to a bug in the RTP being feed to osmux layer (be it from local code
or peer). In that case (long jumps) we don't want to generate tons of
packets filling in several entire batches (potentially incredibly big
amount of batches).
Instead, in these scenarios, simply let the osmux peer know there was a
jump by setting the M bit on the next osmux header for that circuit
after the seq jump has been detected.

Related: SYS#6161
Change-Id: I05b1eae400cb60d1f4e927f853619d5ff470163f
2022-11-16 19:54:16 +01:00
Pau Espin e6306faebd osmux: Use better rationale when limiting amount of lost & forged RTP incoming packets
Related: SYS#6161
Change-Id: I4ea700dbbf469498befc939a844324259bbe332a
2022-11-16 19:53:28 +01:00
Pau Espin 348229a37c osmux: Obey current batch_size restrictions when creating forged RTP packets to fill holes
osmux_link_add() is renamed to osmux_link_handle_rtp_req(), and the last
part of it is split out and kept as osmux_link_add().
hence osmux_link_handle_rtp_req() does proper input checking (like
duplicates, holes, etc.) while osmux_link_add() expects all that to be
sorted out.
Reuse osmux_link_add() in osmux_replay_lost_packets() to properly update
the link state of the to-be-transmitted packet, circuit state, etc.

Change-Id: I4ea435bfb2490a375ad3e5068ee926e48b53cf5c
2022-11-16 19:49:42 +01:00
Pau Espin 95bd0ecd82 tests/osmux: Test big seqnum holes (>batch_factor) in incoming RTP stream
This test shows that there's 2 bugs in the osmux_input code:
* It should be transmitting 2 osmux frames instead of 1
* Once it is fixed to transmitt 2 osmux frames, it should set the M bit of the 2nd
generated osmux header after the seqnum jump in order to announce a jump in the
stream to the peer receiving osmux.

The bugs are fixed in follow-up patches.

Related: SYS#6161
Change-Id: I521c2e97a739e8a824b16f06ec2a578333388247
2022-11-16 19:46:30 +01:00
Pau Espin a9c1c5d61c tests/osmux: Test incoming RTP stream with seqnum jumps during wraparound
Related: SYS#6161
Change-Id: Idd3a609452767f9c480c7c5ba9fc2a3e0a499968
2022-11-16 18:00:54 +01:00
Pau Espin ecb6de4117 tests/osmux: Test replay of one lost RTP packet when generating osmux batches
Change-Id: I913c2ccfc3ad4e7ed801344d64e33e166a0817cf
2022-11-16 18:00:08 +01:00
Pau Espin 7c4d953b6d osmux: dup in RTP pkt: Replace potentially internally forged pkt with incoming one
When RTP packet provided by user to osmux layer, it may contain a seq
gap, and osmux will refill the packets to avoid losing that information
on the other side when it receives the batch.
If out of order UDP packets are received, it can happen that we first
detect a gap and later on we receive the previous RTP packet, which we
is then detected as duplicate because it was previously forged to fill
the hole. In that case, let's better keep the incoming packet instead of
the potentially internall forged one which doesn't contain the real AMR
payload.

Related: SYS#6161
Change-Id: I82e11ef3dcd20ffea33c94ed83abcedf0f186871
2022-11-15 19:55:03 +01:00
Pau Espin 17fca03cf8 osmux: Rework log formatting when replaying detected RTP gaps
The existing code has several flaws which will be fixed in follow-up
patches.

Related: SYS#6161
Change-Id: I5fd64acf7bc1e53efae0674d0c906d1255a9bbf6
2022-11-14 17:53:16 +01:00
Harald Welte 6bca110e3f Support building with -Werror=strict-prototypes / -Werror=old-style-definition
Unfortunately "-std=c99" is not sufficient to make gcc ignore code that
uses constructs of earlier C standards, which were abandoned in C99.

See https://lwn.net/ml/fedora-devel/Y1kvF35WozzGBpc8@redhat.com/ for
some related discussion.

Change-Id: Ied224520b9a09743bd19818ab00cbdf915baef34
2022-11-03 12:23:39 +01:00
Pau Espin 6fe1f35001 osmux: Replace deprecated osmux_xfrm_input_* APIs in examples & tests
Change-Id: I7f3f8d40f89ffdd135a73316ee60fd429ba2a5b0
2022-10-03 11:30:45 +02:00
Pau Espin 9d7ea681ef tests/osmo-pcap/osmux: Replace deprecated API osmux_xfrm_output_init2()
Replacing this one with the newer API was missed a few commits ago when
this API was marked as deprectated. Do it now.

Change-Id: Ia0958dfae951d82feafe427eff2112d327d3b0a4
2022-10-03 11:30:41 +02:00
Pau Espin b0369f375f osmux: Take into account configured osmux_in_handle->osmux_seq field
It was not being used anywhere, yet older applications used to set it
(always to 0, which was the default value applied internally).
Let's make use of it and apply it as first seqnum to be used on a
circuit.
This value is applied upon call to osmux_xfrm_input_open_circuit(),
hence it can be set independently for every new circuit.

Change-Id: Ia26fcba5d7364a5744b2d64d0542a2b3880eee34
2022-10-03 09:29:18 +00:00
Pau Espin de68bc9065 osmux: Fix unwanted RTP marker bit upon rx of osmux seqnum wrap around
The wrap around case was not properly considered in the condition
setting the Marker bit. Let's fix it.

Related: SYS#5987
Change-Id: I6e01f29a6239f930c9be2bcb2efe447e5de8fedf
2022-09-29 11:49:47 +02:00
Pau Espin dc4e8747e9 tests/osmux: Test rx of osmux seqnum wrap around
This test shows that there's a bug where the first RTP packet extracted
from the received osmux batch with seqnum=0 has the M bit marked for no
good reason.

Related: SYS#5987
Change-Id: Ida658c681e84878f209ab4965d8aa821a570a580
2022-09-29 11:49:47 +02:00
Pau Espin e486efa264 tests/osmux: Properly flush and free out_handle in osmux_test
Change-Id: Ia86e4324e21ccc4bd4b138fa5b2b748df23b0aed
2022-09-29 11:49:43 +02:00
Pau Espin d2810679c7 osmux: Fix osmux seqnum incremented globally instead of per circuit
There's no real use in having a global seqnum. The seqnum, as specified
by the osmux protocol specification, relates to that of the RTP
seq+timestamp, hence it is per circuit.
Having it per circuit allows detecting gaps and lost batches on the
receiver side, applying the Marker bit on the re-assembled RTP packets.

As a resut of the fix, tests/osmux/osmux_test part validating Marker bit
started failing. It failed because it was wrongly written to start with,
since it used only one osmux_out_handle for the 4 CIDs in use, which was
wrong, since each CID must have its own osmux_out_handle as state is
kept there per circuit.

Related: SYS#5987
Change-Id: I562de6a871d8a35475c314ca107c2a12b55d6683
2022-09-29 11:48:39 +02:00
Pau Espin 77f989504b osmux: Fix AMR F,Q,CMR fields not properly encoded in osmux header
The value of the first RTP packet in the batch was being encoded,
instead of the last one (as documented in the Osmux protocol
specification).

Related: SYS#5987
Change-Id: I06f3d07a05181d938c22bbd0da7172b5dad6659a
2022-09-28 19:13:54 +02:00
Pau Espin b6f4fa2334 tests/osmux: Add new osmux_input_test to validate AMR FT changes
Related: SYS#5987
Change-Id: I105466fc8a4d92341f34886ee81ef0ca04014514
2022-09-28 19:12:39 +02:00
Pau Espin 2640c157f8 osmux: Print osmux_hdr rtp_m field in osmux_snprintf()
Change-Id: Idfe530b944ac5dfd5ce6b5150421c2d4daee8788
2022-09-28 19:03:52 +02:00
Pau Espin bc68849a68 tests: rename test osmux_test2 -> osmux_output_test
That file focuses on testing the osmux_output_* API, ie receiving Osmux
frames and decoding it into batches and later on into rtp packets.

Change-Id: I7e6eda1e2e676673771bc6a7c3682d07ac1d344e
2022-09-28 19:03:52 +02:00
Pau Espin fffbfaa6f8 tests/osmux: Always run with fake time
Let's not make the tests more difficult to maintain and extend by
allowing them to run in real clock time, there's no real need for it.

Change-Id: I549a4722d63d700b54b146260131a68e656b843e
2022-09-28 19:03:52 +02:00
Pau Espin 038d957b7d tests/osmux_test2: Document unit tests
Change-Id: I56f27af52b6a8d798879c70d68a9a3b9e512867d
2022-09-28 19:03:49 +02:00
Pau Espin 0d52cdfe77 tests/osmo-pcap-test/osmux_test: Fix return condition check for osmux_xfrm_input()
According to API doc and implementation, it never returns >1.
Do as done in all other places where this API is used, that this check
for >0.

Change-Id: If23dfecb566f590b7a898356469df6e322f57653
2022-09-23 17:38:33 +02:00
Pau Espin 2087d61c21 stream: Fix typos in log messages
Change-Id: I9e49e222c254c89d182402501024badfd3bf9d9c
2022-09-12 12:44:03 +02:00