aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2024-03-19WIP: migrate gsmtap logging over to osmo_iolaforge/log_io_gsmtapHarald Welte4-5/+24
This is working in principle; The problem is just that osmo_io itself contains LOGP calls from within osmo_iofd_write_msgb() and downstream code, so we might easily get up in an infinite recursion bug. This needs further study; possibly we need a "safe" logging function which will never use osmo_io. Or something like a per-thread global boolean variable which the code can check to know if it's re-entering? Change-Id: I69d7eca7d50666b4fcfe73a1dc03f8e8491b32fc
2024-03-19msgb: Also copy msgb {dst, lchan, cb} during msgb_copy_*Harald Welte1-0/+5
It wasn't really specified if those fields are supposed to be copied. But after all, a copy is supposed to behave exactly like the original, not just in terms of the data but all aspects. Change-Id: I68328adb952ca8833ba047cb3b49ccc6f8a1f1b5
2024-03-19osmo_io: Make {write,sendto,sendmsg} completion callback optionalHarald Welte1-15/+6
There are situations (like multicast datagram transmit) where we don't really care about the result of a write operation, and hence don't need a write completion callback. As the completed message buffer is free'd by core osmo_io, there is no leak in doing so. Change-Id: I0c071a29e508884bac331ada5e510bbfcf440bbf
2024-03-19osmo_io: Massive improvement of API documentationHarald Welte2-53/+223
* introduce a new "Osmocom I/O interface" group to show up in API docs * expand the documentation to turn it into something useful for somebody wanting to write an application using it. Change-Id: I6315cfc7ff34a0f8971517edf035e1efcef3ed5c
2024-03-15osmo_io: Dont use __linux__ but !EMBEDDEDHarald Welte2-4/+4
osmo_io (unlike its io_uring backend) is not linux specific, so putting it in an "#ifdef __linux__" block is plain wrong. A side-effect is that all our doxygen comments are not processed as __linux__ is not set while doxygen parses the source file. Change-Id: I260443ba3cd0bb81dade434208dea4ea70fe8ad8
2024-03-14Fix file descriptor that is passed to io_uring_register_eventfd()Andreas Eversberg1-1/+1
Fix Change-Id I03752c0114cc6fad0c31fff6fff43072f36a50a7 Change-Id: Ie085c7cb3eb57e0da10485be8f90208cb41b0073
2024-03-14core: fix missing '\n' in iofd_uring_connected_cb()Vadim Yanitskiy1-1/+1
Change-Id: I43df86cdbd3e52d4f8f7bc0e48478b6f9b288e9f
2024-03-14io_uring: check all operations in osmo_iofd_uring_init()Harald Welte1-4/+17
check all operations in osmo_iofd_uring_init() and panic if any of them fails. Change-Id: I03752c0114cc6fad0c31fff6fff43072f36a50a7
2024-03-14io_uring: more verbose error messages if io_uring setup failsHarald Welte1-2/+2
"Assert failed 0 osmo_io_uring.c:94" is rather useless in terms of an error message. Let's improve upon that. Change-Id: I0ac9ae59e99c3704b3ce33919c9e7d11024476e3
2024-03-12socket: Add remote PID and local FD to AF_UNIX socknamePau Espin Pedrol1-3/+28
This allows identifying precisely an AF_UNIX socket. Change-Id: Ic465e557ea49de8e044d1ef6d91fc3c852c88ff2
2024-03-12socket: Support AF_UNIX in osmo_sock_get_name_buf()Pau Espin Pedrol1-7/+46
Right now stream_cli/srv print "<error-in-getsockname>" when using an AF_UNIX socket. This commit fixes the problem. Change-Id: I224c3712a029ee338ee1209a67d820b887170910
2024-03-12ctrl: re-introduce duplicate declaration of ctrl_cmd_send()Harald Welte1-0/+2
In Change-Id Ic81af56e7ea6921ba39168727ef64c308e9c6754 we removed the duplicate declaration of ctrl_cmd_send(), which was declared both in control_if.h and in control_cmd.h. Unfortunately this broke legacy openbsc.git, so let's re-introduce it. Change-Id: I1d415c5e80cfb7ef9e11d33c0c3eaece40ebb1da
2024-03-08osmo_io_poll: Use -errno as result on write errorAndreas Eversberg1-1/+1
This was done for read error in a previous patch. This is required because osmo_io_uring does not support errno, instead it uses the result code. To have a unified API, set the result code equally. Related: OS#5751 Change-Id: I405094449a6644db37534757f2fbccbcff982f23
2024-03-07osmo_io: Avoid implementing non-existant situationsHarald Welte1-7/+4
Both of our back-ends have a register_fd and unregister_fd back-end. Let's simplify the code by not treating them as optional, which introduces code paths that we never take, adds small runtime overhead and makes the code harder to follow. Should we ever introduce more backends which might not need those call-backs, we can either have empty functions or think about how to make them optional. Change-Id: I0077151eb676f61320b3fa2124448852aa8fd4a9
2024-03-07osmo_io: avoid OSMO_ASSERT one each API callHarald Welte1-2/+7
There's only one way to set the osmo_iofd_ops, which is by environment variable during the constructor time at shared library load time. There's hence no point in doing OSMO_ASSERT() on each and every call to osmo_iofd_notify_connected() at runtime. We can move those kind of asserts to the one-time load-time constructor instead. At the same time, we can extend those asserts to all the mandatory call-backs to be provided by the backend. Change-Id: Id9005ac6bb260236c88670373816bf7ee6a627f1
2024-03-07osmo_io: Don't pretend to support backends without close_cbHarald Welte1-2/+2
Let's not pretend we support backends without a close_cb. In such situations nobody would actually close(2) the file descriptor, but we would set iofd->fd to -1, effectively creating a file descriptor leak. Both of our two back-ends provide a close_cb, and we don't need to consider hypothetical future back-ends that would not like to register such a call-back. Related: OS#6393 Change-Id: Id285f1d7b73ae5805aa618897016ae8b73bf892d
2024-03-07osmo_io: Log error message in case call-backs incompatible with modeHarald Welte3-2/+20
Change-Id: I50ba6a76c0144f249d67488874a6c4edf01ec6f2
2024-03-07osmo_io: Guard osmo_iofd_register() with invalid file descriptorHarald Welte1-0/+5
Let's return an error if both osmo_iofd_setup() and osmo_iofd_register() are called with an invalid file descriptor like -1. Either one of them must have been called with a valid file descriptor. Change-Id: Ie4561cefad82e1bf5d37dd1a4815f4bc805343e6
2024-03-04osmo_io: do check_mode_callback_compat() only if ioops is set at ↵Andreas Eversberg1-1/+1
osmo_iofd_setup() Setting ioops is optional when calling osmo_iofd_setup(). If it is not set, do not call check_mode_callback_compat() to check for compatibility. Closes: Coverity CID#349578 Change-Id: I1e25f3e420f25a44cbf73a4da9a498b7561e9ddd
2024-03-02cbsp: Add osmo_cbsp_segmentation_cb for message segmentationlaforge/cbspHarald Welte3-0/+22
This call-back can for example be used as segmentation call-back for libosmo-netif stream_cli/stream_srv or directly for osmo_io. Related: OS#5755 Change-Id: I5e922c54b3431d759b38e81e55076125c5a34008
2024-03-02ctrl: Don't expose write_queue in ctrl_cmd_send() apiHarald Welte5-7/+19
ctrl_cmd_send() should always have taken a 'struct ctrl_connection' as argument, not directly its write_queue member. Let's offer a ctrl_cmd_send2() which fixes the problem, and deprecate the old ctrl_cmd_send(). Related: OS#5751 Change-Id: Ic81af56e7ea6921ba39168727ef64c308e9c6754
2024-03-02osmo_io_uring: Check if osmo_fd_register fails at iofd_uring_notify_connected()Andreas Eversberg1-2/+4
If it fails, do not set the IOFD_FLAG_NOTIFY_CONNECTED flag and log an error message. Closes: Coverity CID#349579 Change-Id: I34e8cc9a2b9df0c624841e5f9268a15c32418da1
2024-02-29osmo_io: Assign const name when stealing TX msg from iofd ctxAndreas Eversberg1-3/+1
All TX messages are moved from iofd instance to the user's context. iofd may be destroyed, but the message is still available to the user. To prevent a use-after-free bug, the context name must be changed from iofd->name to a constant that does not belong to iofd. Change-Id: Ib8dae924fa2d94a7f636136ba7279b965a18cf5b
2024-02-29osmo_io: Add osmo_io_get_ioops() functionHarald Welte3-0/+10
This function can be used by user code to obtain the currently-set io operations, it's the inverse of osmo_io_set_ioops(). Change-Id: I03398c811b9534f50c6644b21eea89a04be29fb0
2024-02-29osmo_io_poll: Declare local functions "static"Andreas Eversberg1-8/+8
Change-Id: I6ba88cd7bbd5b5ef42eb460679696f105c9158cb
2024-02-29osmo_io_uring: Detach msghdr from iofd before calling ↵Andreas Eversberg1-1/+9
iofd_handle_send_completion() msghdr must be detached, because subsequent callback at iofd_handle_send_completion() may destroy the iofd (which in turn frees this msghdr, if still attached) and frees the msghdr, causing a double free. Related: OS#5751 Change-Id: Ia349f73de2145fa360b20dd40deb73a8ffc71f07
2024-02-28osmo_io_uring: Cancel pending request, free msghdr on completionAndreas Eversberg1-4/+19
There is always a completion after cancelling a uring request. Because uring requests use msghdr pointer as user data, we cannot just free the msghdr after cancelling. Upon completion (received after cancelling), the user data still points to the msghdr. To prevent a use-after-free bug, msghdr is not freed, but detached from iofd instance. Then upon completion, the msghdr (if it was detached from iofd) is freed. Additionally it is not required to keep IOFD_FLAG_IN_CALLBACK set anymore, if there is a msghdr attached to iofd. As described above, all msghdr get detached, if iofd is freed (uring request get cancelled) during callback. Related: OS#5751 Change-Id: Ic253f085dd6362db85f029f46350951472210a02
2024-02-28osmo_io_poll: Use -errno as result on read errorAndreas Eversberg2-1/+2
Related: OS#5751 Change-Id: Ida63b74feecddf96bab7b2ade4e9ad216fe56e06
2024-02-28osmo_io: Reject writing messages with length of 0Andreas Eversberg1-0/+15
io_uring will reject to transmit messages with length of 0. Change-Id: I94be5ec7344d92157f7853c6c0ddf7007513ba8e Related: OS#5751
2024-02-28osmo_io: Use poll/select to notify socket connection at osmo_io_uring.cAndreas Eversberg2-1/+76
In order to receive a connect notification from SCTP socket, poll/select event must be used instead of a write notification via io_uring completion event. Once the connect notification has been received, subsequent write notifications via io_uring are used. Change-Id: I4eca9ea72beb0d6ea4d44cce81ed620033f07270 Related: OS#5751
2024-02-28osmo_io: sendmsg/recvmsg supportHarald Welte6-20/+169
Add support osmo_io operations resembling sendmsg() and recvmsg() socket operations. This is what will enable the implementation of higher-layer functions like equivalents of sctp_recvmsg() and sctp_send() in libosmo-netif and/or other users. Change-Id: I89eb519b22d21011d61a7855b2364bc3c295df82 Related: OS#5751
2024-02-28osmo_io: Move notify_connected function to backendAndreas Eversberg4-2/+29
This relocation is necessary as the backend (osmo_io_fd or osmo_io_uring) requires a different approach in handling connect notifications. As a result, a function call has been introduced to struct iofd_backend_ops. In a subsequent patch, the process for the osmo_io_uring backend will be modified to handle SCTP connect notifications using poll/select. If connect notification is requested using poll/select, the file descriptior must be registered to osmo_fd, using osmo_fd_register. If read / write notification is requested by application, the file descriptior must be registered also. A flag is used prevent calling osmo_fd_register / osmo_fd_unregister multiple times, which would cause a crash. Change-Id: I905ec85210570aff8addadfc9603335d04eb057a Related: OS#5751
2024-02-27gsup.h: define newly added PCO IEAlexander Couzens3-0/+19
PCO - Protocol Configuration Options 3GPP TS 24.008 / 10.5.6.3. The PCO will be used by the osmo-epdg to pass PCO internally. The PCO will be passed towards to the PGW in the Session Request. Related: OS#6369 Related: osmo-gsm-manuals.git Change-Id Id912ead4e1205f84a40af6505a5ddf050d1e086d Change-Id: I0f9de90c7c67fe194b441a9d118eba70f09afb5e
2024-02-23osmo_io: Change struct osmo_io_ops to contain struct, not unionHarald Welte4-37/+75
As we introduce more modes, and each mode aliases call-back function pointers to those of another mode, we have more and more error cases where we (for exampele) access read_cb, but in reality the user has populated recvfrom_cb. Let's use a struct, meaning that call-backs of one mode no longer alias to the same memory locations of call-backs fro another mode. This allows us to properly check if the user actually provided the right callbacks for the given mode of the iofd. This breaks ABI, but luckily not API. So a simple recompile of higher-layer library + application code will work. Change-Id: I9d302df8d00369e7b30437a52deb205f75882be3
2024-02-23Make socket.c compile without libsctp support (--disable-libsctp)Andreas Eversberg1-0/+4
Change-Id: I214a16b60e0149a8b1cdcfd3c788cc56a1a40476
2024-02-12cosmetic: tests/gsup/gsup_test: Move send_e_send_end_signal_res to correct placePau Espin Pedrol1-10/+10
All the different procedures are placed in order, except this one. Change-Id: If0877deca2bcbf40229c9c61f471112f1e8cdb0e
2024-02-06comment: gsm_04_08.h: add a spec hintNeels Hofmeyr1-1/+2
Change-Id: I2a606047db88ea47317397a790611048dead6403
2024-01-31coding: fix wrong n_bits_total reported for PDTCH CS2 and CS3Vadim Yanitskiy2-7/+16
In gsm0503_pdtch_decode(), we decode CS2 and CS3 as if no puncturing was employed, reordering the coded bits and setting punctured ones to 0 manually. Because of that, osmo_conv_decode_ber_punctured() reports n_bits_total higher than we actually receive over the air. Change-Id: I6b20cc450f25c48175a61da02644d66c08e22ece Related: OS#6342, OS#6200
2024-01-31coding: fix artificial bit errors for PDTCH CS2 and CS3Vadim Yanitskiy2-8/+11
GPRS coding schemes CS2 and CS3 (defined in 3GPP TS 45.003 sections 5.1.2 and 5.1.3, respectively) employ so-called puncturing, which can be described as intentional removal of coded bits. The goal of puncturing is to reduce the number of coded bits, so that they fit into 4 bursts. The receiving side recovers punctured bits, as if they were received corrupted. The puncturing is also used for other channel types like TCH/F9.6, TCH/F14.4, TCH/AFS and TCH/AHS, but only for CS2 and CS3 we're doing puncturing/depuncturing *manually*. This explains why we're seeing artificial bit errors only for CS2 and CS3. gsm0503_pdtch_decode() should not be reporting punctured bits as bit errors, fix this by using osmo_conv_decode_ber_punctured(). Change-Id: I024276d167e769396187998d881f8e7626461249 Related: OS#6342, OS#6200
2024-01-31coding: improve readability in osmo_conv_decode_ber_punctured()Vadim Yanitskiy1-6/+10
Change-Id: Iaece6d0fe42f173187baa5c87fcbe3cfc60c21fc Related: OS#6342, OS#6200
2024-01-31coding: fix a typo in docs for gsm0503_pdtch_decode()Vadim Yanitskiy1-1/+1
Change-Id: I72e7dab116229d908add3896ecb47b59e3001f1b
2024-01-31utils/conv_codes_gsm.py: fix inconsistent formattingVadim Yanitskiy1-2/+2
Change-Id: Ida99f0fe149b234c738875527dd64b610d33e050
2024-01-30ctrl: Add lchan nodeMatan Perelman1-0/+1
Change-Id: Ibf2786f668ee7e4f5b6a9ef43f2141cd2d79b4e2
2024-01-30Prevent poll() in select.c to timeout too earlyAndreas Eversberg1-0/+9
Adjust osmo_timers_nearest_ms() to round up the remaining time. Note that poll() has a granularity of 1 millisecond. Previously, when rounding down the remaining time, osmo_select_main() would return too early, before the nearest timer timed out. Consequently, the main loop repeatedly called osmo_select_main() until the timer actually timed out, resulting in excessive CPU usage. By modifying osmo_timers_nearest_ms() to round up the remaining time, we ensure accurate timeout calculations, preventing unnecessary CPU consumption during the main loop. The patch only applies to non-embedded version of libosmocore, because the impact on embedded systems is not verified tested. Related: OS#6339 Change-Id: I79de77c79af4d50d1eb9ca0c5417123ff760dca3
2024-01-29tests/Makefile.am: do not add files to EXTRA_DIST conditionallyVadim Yanitskiy1-1/+1
These files must be present in the release tarballs regardless of the configure options (ENABLE_LIBSCTP, ENABLE_SCTP_TESTS). Change-Id: I8f530d6157b00907dd1b438100bb0fb300dfcd22 Related: OS#6349
2024-01-28osmo-release.sh: make it a bit more user friendlyVadim Yanitskiy1-1/+3
Change-Id: I8574cb00de820ab477eb5c4abd05d8e546ca89cc
2024-01-26tests/sockaddr_str: rc_name(): also handle -EAFNOSUPPORTVadim Yanitskiy2-39/+41
Change-Id: I489378705e19c6b09f2fa894ddea4b8a0dc0c7e4
2024-01-26tests/sockaddr_str: fix dead code, print some errno valuesVadim Yanitskiy2-87/+82
This fixes a -Wunused-function warning thrown by clang. Change-Id: I45e9044f80e1f634c811e729f4314ec9bcf6a9ad
2024-01-25tests/a5: fix bit-wise vs logical and in test_a5[34]()Vadim Yanitskiy1-2/+2
This fixes a -Wbitwise-instead-of-logical warning thrown by clang. Change-Id: I6ae0d13882ab7a6b1ca35ccd7f9a5e1d9cac911d
2024-01-25tests/iuup: fix duplicate assignment in def_configure_reqVadim Yanitskiy1-1/+0
This fixes a -Winitializer-overrides warning thrown by clang. Change-Id: Id29237d212a05dec1c57bbfd53d9cb7e71ca0991