Commit Graph

650 Commits

Author SHA1 Message Date
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 745c0e2a0f stream: Add new stream_{cli,srv_link} parameters to set SCTP_INITMSG sockopt values
This will allow osmo_stream users (like libosmo-sccp) to set
SCTP_INITMSG related parameters, like number on inbound/outbound
streams, connect attempts, connect timeout.

Related: SYS#6558
Change-Id: I5343c7659881b29e0201e72badbc2d07e1ef2dca
2023-09-12 00:01:00 +02:00
Pau Espin efd56fb2a2 stream: Introduce API to set several transport parameters
This will allow extending capabilitites to set different parameters at
the lower layers as we need them.

This commit changes the behavior of osmo_stream_{cli,srv_link}: It now
doesn't enable by default SCTP AUTH/ASCONF features using setsockopt. It
is left up to the user of the API (libosmo-sccp in this case) to set it.
Since this unilateral use of setsockopt() has only been added recently
and we didn't release yet, it's fine changing it. libosmo-sccp will be
changed to unconditionally set its using setsockopt. It is left up to
the user of the API (libosmo-sccp in this case) to set it.

Related: SYS#6501
Related: SYS#6558
Change-Id: I2607c1c926a625986cd851adc65dd8b4de83d6ab
2023-09-08 17:53:21 +02:00
Pau Espin 839c90e149 stream: Use new libosmocore API osmo_sock_init2_multiaddr2()
Use the new API available in libosmocore to set sockopts related to
ASCONF SCTP features. The old flag OSMO_SOCK_F_SCTP_ASCONF_SUPPORTED has
been dropped. This only affects master builds since there's no release
ever done with that flag defined.

Depends: libosmocore.git Change-Id I1f6fd09a79b0a2bd794e5669d933be25bbf1eeaa
Related: SYS#6501
Related: SYS#6558
Change-Id: I2b2073de72625b4f4f99892179c9406163d28592
2023-09-08 13:15:56 +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 74b626282c stream: Use new flag OSMO_SOCK_F_SCTP_ASCONF_SUPPORTED for SCTP sockets
This is required if the user of the stream API wants to use SCTP extra
features such as setting the Peer Primary Address through ASCONF.

At a later point we may want to add new osmo_stream APIs to set extra
flags for the socket, or maybe simply add a new API specifically to
enable ASCONF for the stream.

Depends: libosmocore.git Change-Id Iac07031927b66a9d32d2bb2faab817e4c922a359
Related: OS#6076
Change-Id: I807b3748b8535d8e75ceea812d7baaf153fa1d60
2023-08-21 10:25:57 +02:00
Pau Espin 18c160a012 stream_cli: Forward SCTP MSG_NOTIFICATION to upper layers
Same mechanism as already used in stream_srv.

Change-Id: I4cb94d264109f1b763cccd44c6ba049cc7509319
2023-08-21 10:25:54 +02:00
Pau Espin deafe50cef stream: Refactor sctp_recvmsg_wrapper() logging
*Move the helper function to stream.c and pass a logging prefix string
so that it can be used by both client and server.
* Adapt log level based on message type.
* Rework logging code to log everything in one line

Change-Id: I0ed84cc2effb71b6ef1f6efb3f8b663c602a5a31
2023-08-21 10:25:01 +02:00
Pau Espin a49a2b4d70 stream_srv: Log SCTP REMOTE_ERROR events
The event was enabled but was not being logged.

Change-Id: I49f5a648fd474e320101424fb6873a37442339bf
2023-08-07 19:16:24 +02:00
Pau Espin bcfa37ade0 stream_srv: sctp: Log error cause of COMM_LOST event
RFC 6458 6.1.1:
"""
sac_error:  If the state was reached due to an error condition (e.g.,
SCTP_COMM_LOST), any relevant error information is available in
this field.  This corresponds to the protocol error codes defined
in [RFC4960].
"""
Change-Id: Ie48360d22ce1e35eefb1a305dde106948dfa80e8
2023-08-07 19:16:24 +02:00
Pau Espin 7d1430152f sctp: Document relevant RFC specs
Change-Id: Iae325b787fdb7fc95aa6922975a7e1fcf368527a
2023-08-07 19:16:24 +02:00
Pau Espin 48f9a3c27f stream_cli: Proper handling of send() socket errors
Upon EAGAIN, simply re-enqueue the message and return waiting for next
poll. Upon any other error, force close + reconnect.

Related: OS#6134
Change-Id: I462cb176ebc51f3e99ee796310e8665144c84ccc
2023-08-07 19:16:24 +02:00
Pau Espin 3ee5274265 stream_srv: Handle ESHUTDOWN and other write() errors destroying the socket
If internal send() fails with a fatal error, it should destroy the
socket. The user will know about the event through the close_cb() called
during osmo_stream_srv_destroy().

As a result, the socket is not closed when receiving SHUTDOWN by the
peer (through SCTP MSG_NOTIFICATION), but keep it alive since the socket
can still keep receiving data from the peer. Only fail if write() to
that read-only socket is attempted.

Related: OS#6134
Change-Id: I84ddebabdffe47733cb529bcfebec8757e6a172b
2023-08-07 19:16:24 +02:00
Pau Espin a69a958ae3 stream: Append data to current tail of message upon recv()
The previous behavior was not standarized, and even erratic under some
code paths (passing msgb_data() and size=msgb_tailroom()).
This patch standarizes the behavior, and makes it possible to append
content if the user wishes so instead of erasing old data in the msgb
passed to it.

Change-Id: I2cfcd4f61545e6a76d84495c3467999efccf22df
2023-08-07 19:16:24 +02: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 7e68ac2c04 stream_srv: call setsockopt(SO_NOSIGPIPE) also in srv sockets
Commit 5b0ad8bd85 added call to
setsockopt(SO_NOSIGPIPE) in order to avoid SIGPIPE being signalled on
platforms not supporting send() flag MSG_NOSIGNAL (macOS, FreeBSD
etc...).
While it may be a topic to discuss whether we support those platorms or
not, the fact that we call an extra setsockopt() during socket creation
doesn't hurt much, and for sure we want to have the same behavior in
client and server.

Hence, this commit adds the same behavior pesent in srv sockets to cli
ones.

Change-Id: I867d8e244e473679abb7e7e7a9b531eeed046436
2023-08-07 19:16:24 +02:00
Pau Espin f42d4c3bb3 stream_srv: Use LOGSLNK() to print log line
Change-Id: I9aaa63b676b1cd77c7ea500f9bceda989db50db0
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
arehbein 8355b65d9b ipa: Add segmentation callback
Related: OS#5753
Change-Id: I87ef4c7023126b783dd79e7ed47be31e1b76f975
2023-08-07 17:46:53 +02:00
arehbein 8712af589c examples: Add extension header octet to example
Mainly to make data/packets look (pseudo-)correct in Wireshark.

Also: Add helper for allocating message buffers with extended headroom for IPA.

Change-Id: I962b9edcba65cdc98da00d2f8753dc5acd481502
2023-08-07 16:50:22 +02:00
Pau Espin 7fe21f67f6 stream: Split cli/srv specific code out of stream.c
The dev/user in general is only interested about one side of the stream
when looking at the code. Since the stream.c file is tarting to be quite
large/bloated, this patch splits its content into stream_cli.c and
stream_srv.c to make it easier to improve/extend and review.
Keep common code between cli and srv in stream.c, and add a private header
to contain references to it.

Change-Id: I22af01bba2040eb320ba48fd1b46c090c98be159
2023-08-04 13:28:50 +02:00
arehbein 2bd08ade1f stream: Fix osmo_panic log fmts
Change-Id: Id082a9473b788f8de20cdc2ba4430b3289f4ce5a
2023-07-25 14:41:50 +02:00
Daniel Willmann 4b4298965f stream: Notify stream_cli on connect()
Change-Id: I29621ca53cdbdf8b5b2d128307fcb6432db669d3
Depends: Ieed10bc94c8aad821c0a8f7764db0e05c054c1e3 (libosmocore.git)
2023-06-30 13:35:19 +02:00
Pau Espin 42309e34ab stream: Rename static function to have correct prefix
That function is used by the srv_link object, not the srv object. Rename
it to avoid confusion.

Change-Id: I1a3870b3a269b84ac2a9285ee6fe3389c5c96a94
2023-06-27 16:44:31 +02:00
Pau Espin 7e5e18520a stream: srv cb: Use osmo_sockaddr and improve logging when cli connects
Specially important is the change where we now print the remote port
which connected to us, not our local port (which is already printed as
part of LOGSLNK).

Change-Id: I6e556f8263496ded41bb221ccc8e193c5361697f
2023-06-20 13:50:56 +02:00
Pau Espin 832c086852 stream: Drop name param from recently added API osmo_stream_srv_create2()
It was later decided that since setting a name is not really required,
it is best to leave it out of the create() function and let the user use
the osmo_stream_srv_set_name() API if needed (otherwise a dynamic name
based on socket is selected)

Change-Id: I5d677ef57b7db0aedd8c43282568c845097cb12b
2023-06-20 13:50:44 +02:00
Pau Espin 08e9b6c612 stream: Drop recently added API osmo_stream_cli_create2
It was later decided that since setting a name is not really required,
it is best to leave it out of the create() function and let the user use
the osmo_stream_cli_set_name() API if needed (otherwise a dynamic name
based on socket is selected).

Change-Id: I2a2fad318ef22c2ac117f95588a078ca3beccea5
2023-06-20 13:49:37 +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 14c1df9881 stream: Set state to closed before calling disconnect_cb()
Fixes recent crashes in ttcn-cbc-test

Change-Id: I40ceb17c32d1f58f8d0eeda8d1d794cf3f478e83
Related: OS#6063
2023-06-17 06:18:03 +00:00
Daniel Willmann 39f99fa3ce stream: Assert that fd is valid in stream_cli_handle_connecting()
This function should never be called if we don't have a valid fd.

Change-Id: If0bed2bae556e0a8233e9e66e82c70a5c677fc3c
Fixes: Coverity CID#321045
2023-06-16 11:24:22 +02:00
Daniel Willmann 8cd2c4455e examples: Set logging level to DEBUG in {,ipa-}stream-{client,server}
Change-Id: I8c37bbe3db9823a399773d6790000ba508e79377
2023-06-16 09:23:28 +00:00
Daniel Willmann 4bc6d3054c stream: Remove duplicated code in osmo_stream_cli_create()
Simply call osmo_stream_cli_create2() with name ""

Change-Id: I0652361a6bdf194545f36edc5e12e5d26798163a
2023-06-15 22:07:21 +02:00
Daniel Willmann b59825440b stream: Document osmo_stream_cli_create2()
Change-Id: I0c2f46e02d94c3459e4043a9db7fccd906521dd2
2023-06-15 22:07:21 +02:00
Daniel Willmann b08309a890 stream: Setup ofd in osmo_stream_cli_open
Don't reset the osmo_fd data in osmo_stream_cli_set_read_cb().
osmo_ss7_asp_restart() in libosmo-sccp calls
osmo_stream_cli_set_read_cb() which causes the fd to be set to -1.
osmo_stream_cli_open() which is called after that then doesn't close the
old fd and opening the new one fails.

osmo_fd priv_nr, callback and data are never modified in osmo_stream_cli
so simply use these values in osmo_stream_cli_open()

Change-Id: Id9b4db06d5ea1f29cbd1817cab3c71765ab30a53
2023-06-15 22:07:21 +02:00
Daniel Willmann c873b62929 examples: Use new stream API in {ipa-,}stream-{client,server}
Change-Id: I97a9979199c816686b32080534627f6f033e009e
2023-06-14 18:17:13 +02:00
Daniel Willmann 0e7028f742 Add osmo_io support to osmo_stream_cli and osmo_stream_srv
Change-Id: I2f52c7107c392b6f4b0bf2a84f8c873c084a200c
2023-06-14 17:33:35 +02:00
Daniel Willmann 383f721cf7 stream: Correctly close osmo_stream_cli when in state WAIT_RECONNECT
If cli is in STREAM_CLI_STATE_WAIT_RECONNECT cli->timer is scheduled.
Delete the timer if osmo_steam_cli_close() called so we don't end up
reconnecting. Also fixes the recent test failures in
master-libosmo-sccp Jenkins jobs.

Change-Id: Ic5227432192c4007f861f171ae961a8f4dea6522
2023-06-14 17:28:12 +02:00
Daniel Willmann a97bfa750e stream: Use cli->state to check if cli is already closed
Change-Id: I92231528da08f8891e20c1226b61989a65e00ccd
2023-06-12 16:05:22 +02:00
Daniel Willmann a5d5b33a91 stream: Factor out reconnection handling
Change-Id: I418377eabd465ee4ffce9b4440e96287c7734924
2023-06-12 16:05:22 +02:00
Daniel Willmann d455f9e60a stream: Update log messages
Change-Id: Ife20b9d18e6ca86a06991d68165694e31052c58a
2023-06-08 16:57:14 +02:00
Daniel Willmann de32f6ad57 cosmetic: Change name of osmo_stream_src_fd_cb()
Change-Id: I8a9d27856ebdd5405b1977d12e91f8dcbdcd1d6b
2023-06-08 16:36:07 +02:00
Daniel Willmann 2d340403f2 stream: Properly name osmo_stream_srv read callback
Change-Id: I12d74e9b407f1ea7af83fb3ec4d03ad7228a27cf
2023-06-08 13:44:44 +02:00
Daniel Willmann 6aa4b6961c ipa-stream-server: Return -EBADF in read_cb after osmo_stream_srv_destroy()
This fixes a potential heap-use-after-free error.
When there is still data to be written the osmo_stream_srv_cb() will
call osmo_stream_srv_write() which will try to dereference conn even
though it has already been freed.

Change-Id: I5ac1920b8d4ce3b0205f00d253e7ed878fb745e3
2023-05-31 12:11:15 +02:00
Daniel Willmann 68dc5218ca stream: (typo) Change callback param name of struct osmo_stream_cli from srv to cli
Change-Id: I742db401165477f85e66bb428f156ecbbd5d6665
2023-05-17 17:38:21 +02:00
Daniel Willmann 9117ed32da stream: Introduce and use osmo_stream_cli_fd() to get the fd
This will become useful once osmo_io can be used as a backend.

Change-Id: I7e964dea0adee8edbb9b75d2d17e7d0c5d8917d5
2023-05-17 17:38:21 +02:00
Oliver Smith ee17c3890a debian: set compat level to 10
Related: OS#5958
Change-Id: Icfdbea7cbe4681cd3b286471032fd6dd7226888f
2023-04-25 16:48:18 +02:00
Vadim Yanitskiy 9e6542641a src/Makefile.am: do not overwrite AM_LDFLAGS
Change-Id: I7b656c167cceb0657c0362b1237f846b7f3e9770
2023-03-13 04:46:02 +07:00