Commit Graph

13 Commits

Author SHA1 Message Date
Harald Welte d8a3e4d390 osmo_io: sendmsg/recvmsg support
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-22 22:09:03 +01:00
Andreas Eversberg 34518d3c6d osmo_io: Move notify_connected function to backend
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-22 15:44:18 +01:00
Daniel Willmann 84611881c9 osmo_io: Factor out and use common send function from backend
This handles reenqueuing a message on EAGAIN and incomplete write

Change-Id: I6da2653d32aedd0e7872be0cf90a841b56462e59
2023-11-30 14:27:39 +01:00
Harald Welte 38d8170fa4 osmo_io: rename unsupported SCTP mode to OSMO_IO_FD_MODE_SCTP_RECVMSG_SEND
The two functions of the SCTP socket interface we use in osmo-* are
sctp_send() and sctp_recvmsg().  We do not use sctp_sendmsg() at all,
so let's make sure the mode is named correctly.

Change-Id: Ie2d1c7ce6f211dbe025a0e843ad733443102ea15
Related: OS#5751
2023-11-22 12:20:12 +00:00
arehbein 2e2a0a1561 osmo_io_poll: Handle -EAGAIN in case of OSMO_FD_WRITE
Related: OS#6213
Change-Id: I59c86370d13f2bb33c289d1b177df895726975cb
2023-10-20 10:00:32 +00:00
Daniel Willmann 435856be51 osmo_io: Init struct msghdr to zero
Avoid uninitialized read, found with valgrind

Syscall param recvmsg(msg) points to uninitialised byte(s)
   at 0x49FD865: __recvmsg_syscall (recvmsg.c:27)
   by 0x49FD865: recvmsg (recvmsg.c:41)
   by 0x4891FAE: iofd_poll_ofd_cb_recvmsg_sendmsg (osmo_io_poll.c:66)
   by 0x48921B2: iofd_poll_ofd_cb_dispatch (osmo_io_poll.c:119)
   by 0x48941F1: poll_disp_fds (select.c:419)
   by 0x4894299: _osmo_select_main (select.c:457)
   by 0x4894304: osmo_select_main (select.c:496)
   by 0x10DC3E: test_segm_ipa_stream_srv_run (stream_test.c:628)
   by 0x10E2A5: main (stream_test.c:879)
 Address 0x1ffefffa68 is on thread 1's stack
 in frame #1, created by iofd_poll_ofd_cb_recvmsg_sendmsg (osmo_io_poll.c:45)

Change-Id: I21114ad57784126cfdeb4a932ed44dbf23946fbe
2023-09-27 11:14:02 +02:00
Daniel Willmann 2b34e92d0e osmo_io: Add iofd_handle_recv()
Handle msg reception in a common function that can be called from the
different backends.

Change-Id: Ifc407d446805f885d37767f421ff710cb276a01f
2023-08-24 14:46:51 +00:00
Daniel Willmann f89162f8ab osmo_io: Use bitfield for various boolean flags
Change-Id: Ic134e4c8d791c34778202fea98a70bc04007a113
2023-06-29 17:06:23 +00:00
Daniel Willmann a8a27c2c6f osmo_io: Use LOGPIO instead of LOGP
Change-Id: I4ee256b18544f7ca6bff6b7c6ebcce15546bb1f2
2023-06-26 19:28:54 +02:00
arehbein 5099d99192 core/osmo_io: Fix reception of partial packets
Always append to 'msg->tail' instead of to 'msg->data'.

Change-Id: I0ab8028c807b4181fddd3c00ea2e037c40cf0813
2023-06-19 15:40:57 +00:00
Daniel Willmann cbbd17e3f4 osmo_io: Support detecting non-blocking connect()
libosmo-netif does a non blocking connect(), which as per definition of
 the socket API is signalled from the OS to the user by marking the file
descriptor writable.

osmo_io needs to signal this somehow. Previously osmo_io would only call
the write_cb if actual data has been sent. This patch changes the behaviour
so that calling osmo_iofd_write_enable() will call write_cb() on a writable
socket even if the write queue is empty.

Change-Id: I893cbc3becd5e125f2f06b3654578aed0aacadf3
2023-05-19 12:50:21 +00:00
Daniel Willmann a4b958bda2 osmo_io: Avoid read of uninitialized variable
Change-Id: Ica8087c73fc10f01026fdbe692b172ad07fe593d
Fixes: CID#315618
2023-05-15 18:10:25 +02:00
Harald Welte 8857f3b798 Add osmo_io with initial poll backend
* make backend configurable for later
* segmentation callback for chunked streams
* logging target for osmo_io
* support partial writes

Change-Id: I50d73cf550d6ce8154bf827bf47408131cf5b0a0
Related: SYS#5094, OS#5751
2023-05-10 06:04:57 +00:00