Commit Graph

286 Commits

Author SHA1 Message Date
Pau Espin a15d00ca57 osmux: use uint8_t everywhere for batch_factor
Change-Id: I9fcc8e94b2fcd843b10cb3f8f009f2348eb3a4af
2017-04-27 08:50:01 +00:00
Max dafdb5ef8c Fix debian packaging
* add separate -doc packages
* fix dh_install override
* add conflict with previous version

Change-Id: I2781c800d39923c5541bac00f00cb128f4acf008
2017-04-25 13:28:10 +02:00
Harald Welte c108c9db96 SCTP: Don't enable sender_dry_event for SCTP, as it breaks Linux SCTP
Enabling sender_dry_event in SCTP_FLAGS breaks reliable delivery of DATA
chunks to the scoket user on Linux.  Let's avoid enabling that, while
still enabling various other interesting events.

See https://bugzilla.redhat.com/show_bug.cgi?id=1442784 for all related
details.

Change-Id: Ib616cd07a6044ca2ee7e05093b22df3369c62b56
2017-04-17 16:05:22 +02:00
Harald Welte c200a95615 stream.c: Fix SCTP_NODELAY setting
We were using the wrong variable when setting the SCTP_NODELAY,
resulting in the setsoctkopt() fialing.

Change-Id: Ic04cb8bb5ff41f177f7f5b7f7e2a2ecc686dd4c0
2017-04-16 23:34:28 +02:00
Harald Welte d8348ddafc netif/ipa.h: Don't redefine 'struct ipaccess_unit' from libosmocore
'struct ipaccess_unit' is defined in libosmocore/gsm/ipa.h, we shouldn't
re-define it here.  This entire IPA code duplication accross multiple
libraries and programs is a big mess.

Change-Id: If378a088c741df540befb928a5557fc62dea954a
2017-04-15 16:06:56 +02:00
Neels Hofmeyr 719d1a38c6 osmo_stream_srv_fd_cb(): don't leak socket FDs on errors
So far we seem to assume that the accept_cb does all handling of socket
fd cleanup. However, there are cases where there is no accept_cb set,
the accept_cb returns error, or an earlier sctp_sock_activate_events()
or the activation of non-blocking mode fails.

For those cases, close the socket and return an error code.

Fixes: CID#57915
Change-Id: I3a3ce9194ab7ca5c1921fc79c2a1c9e10a552cf0
2017-04-14 11:06:09 +02:00
Harald Welte a7d7dd220c ipa.h: Don't redefine what libosmocore already defines
Change-Id: Ibd81efc1dc61b8c2019d55a8fa6e3bb99b5acb20
2017-04-14 10:55:55 +02:00
Harald Welte 73a44d2348 stream.h: Add missing stdbool.h include
Functions introduced in 9ec26583cd are
using the bool type without referencing stdbool.h as include file.

Change-Id: I736cb04629d516c10c7d5f42f792ed3d5ae6658f
2017-04-12 15:06:37 +02:00
Harald Welte 5ae42bca91 SCTP: Fix PPID byte width
In a659590e29 we fixed endianness issues
with the Stream ID field, but at the same time mistook the PPID field
for 16bits.  In reality it is 32bits, and hence our 'htons' is rendering
wrong PPID values.

Change-Id: I1b60523044835ee630dba9a43d26af4f1ebd1ced
2017-04-12 12:08:45 +02:00
Harald Welte 9ec26583cd Add osmo_stream_{cli,srv_link}_set_nodelay() function
Using this function, the user can configure if sockets related to the
respective stream client or server should have the NODELAY socket
option set in order to avoid Nagle algorithm or related algorithms
that may introduce packet delay on the transmitter side.

Change-Id: Ibeb9ba227bab18f7f4f16518c0022c4f003cc8e9
2017-04-11 19:54:07 +02:00
Harald Welte a659590e29 stream.c: Fix endianness handling of PPID and STREAM_ID
In their infinite wisdom, the inventors of SCTP designed an API (the
sockets API described in RFC6458), where some members are in host byte
order (like the stream identifier), while other members are in network
byte order (like the PPID).

Let's handle this properly (we assumed both are network byte order), and
also use 16-bit htons/ntohs fo the PPID, rather than htonl/ntohl.

Change-Id: I777174ca2915c6de0063db41a745c71b4a09bbec
2017-04-10 17:48:42 +02:00
Harald Welte 7cee4b67e9 stream/datagram: Ensure reliable close/destroy
* when using osmo_*_destroy(), always call *_close() internally to
  make sure we don't free memory holding references to sockets that are
  still open
* when closing the socket, always make sure to set the fd to -1 in all
  cases, to avoid attempts to avoid later close() on a new file using
  the same fd number as the socket closed previously.

Change-Id: I29c37da6e8f5be8ab030e68952a8f92add146821
2017-04-10 06:52:59 +00:00
Harald Welte 0bacc71fc2 stream/datagram: Consistently use osmo_talloc_replace_string()
during osmo_*_set_addr(), we must make sure to talloc_free() any old
address before copying in the new address.  Not all functions did this,
and those that did implemented it manually.  Let's use
osmo_talloc_replace_string() which is exactly intended for this case.

Change-Id: Ie1b140a160c66e8b62c745174865d5ba525cb2c2
2017-04-10 06:47:28 +00:00
Harald Welte a2c2b59165 stream+datagram: Allow local bind + connect for client sockets
This uses the new osmo_sock_init2() features introduced in libosmocore
Change-Id Idab124bcca47872f55311a82d6818aed590965e6 to bind *and*
connect a given socket during creation.

Change-Id: I013f4cc10b26d332d52d231f252bb0f03df8c54b
2017-04-10 06:40:14 +00:00
Harald Welte edad98b4a0 doc: Add Doxygen group for OSMUX related functions
Change-Id: I87e08bd84236ae5d5c057bca96d122e568a6b52a
2017-04-08 20:13:14 +02:00
Harald Welte d0f9bd600c Add minimal doxygen documentation for stream + datagram modules
We should have doxygen documentation for all libosmo-* APIs.

libosmo-netif is currently devoid of any API docs. Let's start with the
stream and datagram socket related functions.

Change-Id: I589a5e60d9df2b8a65fbaf68f80e3ae0039d8c2a
2017-04-08 20:13:14 +02:00
Daniel Willmann 5fe77a4656 stream.c: Handle SCTP in osmo_stream_srv_recv()
Change-Id: If0875cfa3eba9ef36acc0c4bfd0d168a45c380b9
2017-03-29 15:23:52 +02:00
Harald Welte db9808e883 stream client: Ensure client is notified on reconnection
without setting the BSC_FD_* flags prior to reconnection, the re-connect
would happen silently and the client program would not be notified via the
connect_cb().

Change-Id: Iaf8ec8662cf83476eee1b76fa41dc57f063f0ad3
2017-03-20 01:32:06 +00:00
Harald Welte 3a060c59be README.md: Make sure all hyperlinks have <>
Change-Id: I5a5659afde32f08b324e602b7b1f96de805ba031
2017-03-17 21:30:33 +01:00
Harald Welte d8c820570b stream: Export osmo_stream_cli_reconnect()
In case the application is using the read-callback and a read returns 0,
then the application itself would want to trigger the reconnect.  This
is different from the osmo_stream_cli_recv() case where the reconnect
can be handled internally to the library.

Change-Id: I41314bad4a9f44e8a61b9d2ba33d1a76b25bd145
2017-03-17 12:07:19 +01:00
Harald Welte f2174ef1a2 stream: When destroying, make sure to kill reconnect timer
if osmo_stream_cli_destroy() is called while the reconnect timer is
running, we would end up in a crash.

Change-Id: If6597130f472f1e2b8d9682002250ecd54675bb0
2017-03-17 12:07:19 +01:00
Harald Welte a4c1a73250 stream: don't crash in _close() when fd is not initialized
We use the magic value '-1' in case the file descriptor is not yet
initialized.  If somebody calls osmo_stream_*_close() before this
changes, we used to crash.  Let's check for this and avoid a crash.

Also, after close let's change the fd to -1 again to mark the fd
invalidity.

Change-Id: I3aa04999ab01cb7971ee2dad45dfc31ab4142868
2017-03-17 12:06:24 +01:00
Harald Welte 781e7b38f8 stream_client: Actually use/honor the reconect parameter
The reconnect behavior was likely broken in commit
de3f57a8293a5b39435d6f283da23e0172bad8bb

If the user requests a re-connect, we should start it. Not only in case
the connection drops later, but also if the initial connection itself
fails.

Change-Id: I817e026404cbd9145cae2ce90bc57a1db1d2e12b
2017-03-17 00:24:23 +01:00
Neels Hofmeyr 538e5cd52a jenkins: add value_string termination check
Change-Id: If7f6dce2b8325d4f2f732e1c14d6a1082e122584
Depends: libosmocore change-id I2bc93ab4781487e7685cfb63091a489cd126b1a8
2017-03-16 18:59:34 +00:00
Harald Welte 70a82f0c21 Add README file to libosmo-netif repository
Change-Id: Idfc804740e5a086701017d55c86aaf3304c84148
2017-03-16 15:45:29 +01:00
Max 5fd93e02f8 Fix potential NULL dereference
Change-Id: I5baf369dbf3948565614476980a32be59abaf42a
2017-02-07 11:46:41 +01:00
Max 8d3384290b deb: fix lib version
The library version does not match LIBVERSION from Makefile.am and -dev
package dependency - bump it.

Change-Id: Ie9bcd71ffcaeaa78aeef74ec329a6966ce1f1ba6
Related: OS#1860
2017-01-16 11:30:06 +01:00
Harald Welte 3bb118270b rs232.c: Fix license to GPLv2-or-later. libosmo-netif is GPLv2-or-later
Change-Id: I7c73d1a0b15cfb2a729687cde6f9a8e62a230fd7
2016-12-22 14:19:32 +00:00
Max 7cbed7197b Add gerrit settings
Make it simple to setup and use this repo with 'git review' command.

Change-Id: I4fc8b17a0cbea16c7bdd7e50d106ef4aa35780e0
2016-12-22 14:06:35 +00:00
Max c9a86ff306 Integrate Debian packaging changes
debian/control:
* restructure to make it easier to incorporate further changes
* update package descriptions
* update project URL

debian/rules:
* use proper hardening syntax
* restructure to make it easier to incorporate further changes
* add cleanup override

debian/copyright: add file matching Debian format

Change-Id: I9174b34a79c0562ef43f757ea76d67301088f109
Related: OS#1694
2016-12-21 18:05:27 +01:00
Neels Hofmeyr eda74fafb4 examples/stream-server.c: use read() rc instead of strlen()
Fixes: CID#57922
Change-Id: Ibaafdd49d9446a12fe7d0e2f5b2039da3ffc7ea9
2016-12-01 15:55:49 +00:00
Harald Welte 1f760e8dcc ipa-stream-{client,server}: Add missing #include <sys/socket.h>
This lead to compiler warnings on FreeBSD, as setsockopt() is undefined.

Change-Id: Ie0ee3e48adfd0cd252703ec020cef28cf76ca223
2016-12-01 16:07:23 +01:00
Harald Welte 29d6cd4134 osmo_stream_cli_open2(): Fix bogus EINPROGRESS handling
osmo_sock_init() never returns -1 + errno EINPROGRESS. It will return a
positive fd in case the connect operation is in progress. Therefore,
the related code in osmo_stream_cli_open2() was impossible to execute.

Change-Id: Id3483d1d1d4d2eabba94729ea29e5c93b33abff0
Fixes: Coverity CID 57861
2016-12-01 15:52:54 +01:00
Harald Welte 3dd57f737c rs232: Don't pass negative number to strerror()
Change-Id: Ia777221cd0472cd1e7aa79e5146b07048a545dd8
Fixes: Coverity CID 57860
2016-12-01 15:52:54 +01:00
Harald Welte e63f88146d stream-client: check read() return value before using it as length input to memcpy
Change-Id: Id962821c71b3a1c4c01c1131eb809b8ec8eaa062
Fixes: Coverity CID 57859
2016-12-01 15:52:53 +01:00
Harald Welte a47c8a3f3f stream-client: Check for osmo_fd_register() return value
Change-Id: I1b5fa97d14e69ff502b6deba0fd898a01e53420f
Fixes: Coverity CID 57633
2016-12-01 15:52:53 +01:00
Harald Welte 046b12fa88 rs232-write: Check return value of osmo_fd_register()
Change-Id: If40e85600ca1dfbda5975d7aa92cccdb11f9c34d
Fixes: Coverity CID 57632
2016-12-01 15:52:53 +01:00
Harald Welte b2b2fe643f sctp_sock_activate_events(): Print error message on error
When the setsockopt() in sctp_sock_activate_events() indicates an error,
let's print an error message in the log about this.

Change-Id: I5920154e23debe6d01eaa156005db0842f1a18cc
Fixes: Coverity CID 57634
2016-11-26 16:41:06 +00:00
Harald Welte 7f0e9f1171 examples/lapd-over-datagram-network: Fix compiler warning
lapd-over-datagram-network.c:38:12: warning: ‘sapi’ defined but not used [-Wunused-variable]
 static int sapi = 63, tei = 0;
            ^~~~

Change-Id: If367deb0e0d7d5e031db2bd905179263d18703f0
2016-11-11 15:33:35 +01:00
Arran Cudbard-Bell 5b0ad8bd85
Set SO_NOSIGPIPE on SCTP connections, for patforms which support it (macOS, FreeBSD etc...)
Change-Id: If4f2a99b2baf143551a7122f40ed1f9088c5936c
Signed-off-by: Arran Cudbard-Bell <a.cudbardb@freeradius.org>
2016-11-02 13:22:24 -04:00
Neels Hofmeyr fb88e6b78e jenkins.sh: use osmo-build-dep.sh, log test failures
Like in libosmo-abis' jenkins.sh

Change-Id: I022fbaaa1d211f68b38f18cfaf338ece51198c34
2016-10-07 00:49:12 +02:00
Neels Hofmeyr d0b6eb4777 configure: check for pkg-config presence
Change-Id: Ifaea95befa3d1d8f6f047e22efcd62cb0bd8b287
2016-10-01 00:59:54 +02:00
Neels Hofmeyr e168a1798b build: be robust against install-sh files above the root dir
Explicitly set AC_CONFIG_AUX_DIR.

To reproduce the error avoided by this patch:

  rm install-sh        # in case it was already generated.
  touch ../install-sh  # yes, outside this source tree
  autoreconf -fi

This will produce an error like

  ...
  configure.ac:16: error: required file '../ltmain.sh' not found
  configure.ac:5: installing '../missing'
  src/Makefile.am: installing '../depcomp'
  autoreconf: automake failed with exit status: 1

See also automake (vim `which automake`) and look for 'sub locate_aux_dir'.

Change-Id: Idcce286e83b802b9cd96cee6230aedd51a660b12
2016-10-01 00:59:54 +02:00
Neels Hofmeyr cd7e778f96 gitignore: tests/osmux/.dirstamp
Change-Id: Ia0380da1f4980035938ec39cd2b5674f0400fbb3
2016-07-07 12:52:40 +00:00
Neels Hofmeyr f468e720ad osmux-test: remove real-time constraint by default
Introduce a local #define to disable the real-time constraint from osmux-test.
It would make sense to remove this completely, but in case anyone may be
interested in the timing on a specific platform, I've just #defined it away.

The real-time constraint to pass or fail the test is a bad idea in terms of our
build server. Whenever the server is loaded, the tests will fail for no reason,
like here: https://gerrit.osmocom.org/474
The real time to calculate is highly dependent also on the hardware platform.
The arbitrarity of the time constraint is sort of proven by dd24cdd95f
which simply doubles the time to pass the test.

Change-Id: Ic1da4bd22411652334f73195b2e37853e0738906
2016-07-07 14:13:16 +02:00
Holger Hans Peter Freyther 85bc50cbde debian: Make upgrading from debian SID easier
Make sure the version number of this sourcepackage is higher than
the one found in Debian SID.

Change-Id: I6486f91bc11e0828b4ccd0e22f8e2135af0d271a
Reviewed-on: https://gerrit.osmocom.org/111
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-26 12:22:39 +00:00
Daniel Willmann 2904f82f99 osmux: Add function to delete all msgs pending for a circuit
Use this function in osmux_batch_del_circuit() since msgs are stored in a list
per circuit. After the circuit is free()d the msgs are lost.
Before this patch any messages enqueued inside a batch when the circiut is
deleted were leaking.

Change-Id: Ib0311652183332d0475bf7347023d518d38487ef
Ticket: OS#1733
Reviewed-on: https://gerrit.osmocom.org/120
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-26 12:05:42 +00:00
Daniel Willmann d5235e5e51 osmux: Pass circuit to _batch_del_circuit() and use it from _xfrm_input_fini()
Change-Id: If224980123d4a369133499ab7b577d02511f4055
Ticket: OS#1733
Reviewed-on: https://gerrit.osmocom.org/119
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-25 20:42:41 +00:00
Holger Hans Peter Freyther ecee3f9110 misc: Drop oRTP dependency as there is nothing using it
This seems to be a copy of paste of libsomo-abis. Let us just drop
it here and be done with it.

Change-Id: Ia5cb2b572fb5597605284d1c3f657d548aa790f2
Reviewed-on: https://gerrit.osmocom.org/64
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-14 10:06:38 +00:00
Holger Hans Peter Freyther 3583bc4f03 jenkins: Add the build script from jenkins here
This can be used to replicate a build issue more easily.
2016-04-13 18:55:47 -04:00