Commit Graph

47 Commits

Author SHA1 Message Date
Harald Welte 5426124dc7 rspro_server: Handle ipa_server_link_open() error case
>>>     CID 307530:  Error handling issues  (CHECKED_RETURN)
>>>     Calling "ipa_server_link_open" without checking return value (as is done elsewhere 4 out of 5
times).

while at it, also add a missing pthread_rwlock_destroy() call which was
missing in the existing ipa_server_link_create() error path.

Closes: CID#307530
Change-Id: Ic32d53a236b80711651fb4ee196ac3b95148e61f
2023-02-06 13:16:02 +01:00
Harald Welte ae0d9d2e60 remsim_server: handle osmo_fd_register() failure case
>>>     CID 307531:  Error handling issues  (CHECKED_RETURN)
>>>     Calling "osmo_fd_register" without checking return value (as is done elsewhere 83 out of 97 times).

Closes: CID#307531
Change-Id: I7c2448303fba7caa27df65ac5f4d91ddf232ceb6
2023-02-06 13:14:02 +01:00
Harald Welte 2d5d4c3bee rest_api: strtoul canot return negative
>>>     CID 307538:  Control flow issues  (NO_EFFECT)
>>>     This less-than-zero comparison of an unsigned value is never true. "map_id < 0UL".

Closes: CID#307538
Change-Id: Ic5019e216dd7b26be0bd988df218a2cb5775e411
2023-02-06 13:13:53 +01:00
James Tavares e206e6a2e2 bankd, client, server: add -L option to disable log coloring
When the stderr of these services is sent to syslog, for example by
using systemd's StandardError=syslog, syslog's escaping of ANSI color
ESC sequences in log messages really clutter the log files. This
option allows log coloring to be disabled on the command line.

Change-Id: I6955b0af1ceb11a4029383e32bb298ee8da7503f
2022-11-19 09:18:16 +00:00
Harald Welte a04ff860c1 server: Fix various error paths if startup fails
Don't segfault or use heap after free if osmo-remsim-server cannot
fully initialize, e.g. due to ports already in use.

Change-Id: I558e6a0ea089a779f916aa5576341d1c55da1271
2022-05-03 18:09:14 +02:00
Harald Welte eea631bff0 encode actual hostname in RSPRO
The RSPRO ComponentIdentity includes a 'name' for each remsim component.

So far we always used "fixme-name" instead of something meaningful.
Let's use the hostname of the system instead.

Change-Id: I14925f16ae242dae89fa853a2fe31c5c1b32981d
2022-05-03 18:09:14 +02:00
Harald Welte 65006583c1 server: Detect duplicate client/bankd connection; drop new ones
we're dropping the current (new) connection as we don't really know which
is the "right" one. Dropping the new gives the old connection time to
timeout, or to continue to operate.  If we were to drop the old
connection, this could interrupt a perfectly working connection and opens
some kind of DoS.

Related: OS#5527
Change-Id: I00387dbc19d689415470e2f08df08a47a78b81c0
2022-05-03 18:09:14 +02:00
Harald Welte 900ee725b5 server: Fix segfault in error path (client component ID != client)
When we terminate the FSM instance, we must immediately return.

Change-Id: I8dff45daa6584ed111a8469e7b3bf90e7c939612
2022-05-03 16:28:52 +02:00
Harald Welte 15e8b7f79c server: Differentiate log levels, not everything is DEBUG
Change-Id: Iee1e2f66e8675146883a6f5e355460608fe6d547
2022-04-27 09:24:21 +02:00
Harald Welte e1590df408 server: Log keep-alive timeout and TCP disconnects
Change-Id: I9912fee7fb892c724a0277d1fa52d056c11c9b73
2022-04-27 09:19:48 +02:00
Harald Welte fb48de8968 server: Log connection establishment from bankd/client; warn on localhost
If a bankd connects to the server from 127.0.0.0/8, then clients will
not be able to reach it unless they also run on localhost.  Warn the
user.

Change-Id: I5446752961b039dad54aec981c1df4814779f765
2022-04-27 09:15:43 +02:00
Harald Welte a9d7ad1175 switch to libosmocore multihread-logging
When osmo-remsim was originally developed, libosmocore logging was
not yet thread-safe.  This meant that the worker threads of remsim-bankd
and remsim-server could not log via the libosmocore logging framework
but directly used stderr/stdout, which produced rather inconsistent log
output.

However, since 1.3.0, libosmocore has received support for
multi-threaded applications.  Let's make use of this and consistently
use it in remsim-server and remsim-bankd.  This obviously also means
adding some more log categories.

Change-Id: I7bd5264c559b756927046563a2d00c54826bee9b
2021-12-08 21:17:15 +01:00
Harald Welte 73bbd54cdb logging: Print category + level, disable category-hex
Change-Id: I9ae27b78b965d173146583b030fd93e2d70b845e
2021-12-08 21:15:49 +01:00
Harald Welte a5daec426e Use OSMO_FD_* instead of deprecated BSC_FD_*
Change-Id: Ice73ab253ae038848c791871693ba2e5c3352ffc
2020-10-18 22:40:42 +02:00
Harald Welte 80a0110f77 add '-d' command line argument to configure stderr logging verbosity
The '-d' option is pretty much tradition in most osmocom programs,
particularly for those without a VTY / config file it is the only
option to configure per-subsystem logging verbosity.

Change-Id: I0abecc26a5d8b6a5607e1eb8982af4c05909afed
2020-05-25 15:49:33 +02:00
Harald Welte f43babac56 server: Don't accept out-of-range bank/client/slot numbers on REST
Change-Id: Id0c9dcda58d1f85df431a74bbfba06cfaa0af69d
2020-02-20 18:52:24 +01:00
Harald Welte 3598c58eb8 server: Send ConfigClientBankReq with bankd_port == 0 on map delete
If a slotmap is deleted via the REST API, don't only remove it from
the bankd, but also remove it from the client.

Change-Id: Ia2fc2a098471add56cb35e74639417d865704989
Closes: OS#4399
2020-02-16 15:46:19 +01:00
Harald Welte ea3eefe433 server: don't dereference map before OSMO_ASSERT() in _update_client_for_slotmap()
Change-Id: Ib36d2ba7928ea17a508cb68748e6c50f22784227
2020-02-16 15:46:19 +01:00
Harald Welte cd7fcd717c Add "--version" to all executables to print compile-time version info
Change-Id: I9ae504ff95beeefb9e90e02a576861351ea9e143
2019-12-04 21:13:24 +00:00
Harald Welte 4ccd2fca84 Check for osmo_fsm_register() error return value
Change-Id: Idda1a4050cf9d285225ae48a4ba6f48c04f9598b
2019-12-01 13:34:32 +01:00
Harald Welte 3591382ffa server: rest_api: Fix memory leak in slotmap post
We need to decrement the refcount on the json_req object.

Change-Id: I1a550eff76e6a72013ab47ef8f240a72d7a7d9cb
2019-07-21 20:42:21 +02:00
Harald Welte 0c50c34f18 track libulfius and jansson memory allocations with talloc
Change-Id: I0ad63a79a806b420ea0de42b67726da36ebac828
2019-07-21 20:42:15 +02:00
Harald Welte 6b990f914f rspro_server.c: Fix memory leak in processing inbound RSPRO
We need to unconditionally free the msgb that gets handed into
sock_read_cb() by the ipa server.

Closes: OS#4096
Change-Id: I12b4a22854eea79c9e9c3e565dd4803e4dc0ed5a
2019-07-18 19:02:31 +02:00
Harald Welte 92fd7343e3 remsim_server: Enable talloc tracking of msgb allocations
Change-Id: Ia8c729756da6bb85e61a65addae4d4c83e7b6fde
2019-07-18 19:02:31 +02:00
Harald Welte 51cfec03b1 rename executables to include osmo- name prefix
Change-Id: I4498a004519499cc4b897a68c7f33efe29a63425
2019-04-03 09:50:04 +02:00
Harald Welte 5345f3d43f Makefile.am: Fix dependency of server on libosmo-rspro.la
Change-Id: I0a1badfa44479ff771be7062a19fd842f3d56b41
2019-04-03 08:42:47 +02:00
Harald Welte f51166790e cosmetic: remove some FIXME that actually are already fixed
Change-Id: I62ac36aae6da374b83e27b71ff52b0c3d52bf346
2019-04-02 20:56:16 +02:00
Harald Welte 56298ca4e0 server: Fix dependency on libosmo-rspro.la
Change-Id: Ia05a5f0f01999b32fd10d76694e95df9b1ccb207
2019-04-01 10:57:08 +02:00
Harald Welte b54a51eec2 improve talloc memory leak debugging
* switch to talloc_report_full() on SIGUSR1
* include asn1-internal allocations in talloc report

Change-Id: I14fff863449971024002e0d5465fb7a964d67095
2019-03-31 15:57:59 +02:00
Harald Welte 35ded29788 rspro_server: Fix Warnings about unused variables
Change-Id: Id8615062772c09d7396254fa5d1f42dd029e8a22
2019-03-31 15:13:09 +02:00
Harald Welte 4c37f66048 rspro_server: Configure client's bankd parameters (nr/slot/ip/port)
Change-Id: I821d0b2ba4390b9772097ddd3d610ba2c9393399
2019-03-31 15:00:00 +02:00
Harald Welte a8b86ceff2 client/server: log failed attempts to transmit/encode RSPRO
Change-Id: Iac56ddf7417fdee637660db34a7f0e6bdb9c4ab5
2019-03-31 14:59:20 +02:00
Harald Welte 10f7a76373 rspro_server: Treat keepalive timeouts (by closing connection)
Change-Id: I42f2d5c6c7a4387cb61cb8b46d01b7dfb86b927b
2019-03-31 12:38:47 +02:00
Harald Welte 1c691b173a rspro_server: Give proper name to IPA_KEEPALIVE FSMs
Once we know the Client / Bankd Identity, update not only the connection
FSM with that identity, but also the IPA keepalive FSM.  This will
provide proper context when logging.

Change-Id: I92bf47b6b0072c8062449ed3bb51ddf0b7aaf9a1
2019-03-31 10:58:11 +02:00
Harald Welte 19dee08862 rspro_server: Print human-readable message type instead of numeric value
Change-Id: I0c26e1be1ae9ddee663fee582a44d4449e6beea7
2019-03-31 10:53:45 +02:00
Harald Welte f30ff9eeb0 rspro_server: Add client_conn_by_slot() API function
Change-Id: Ie2eefad358b45541cf90d0cacac2d03953f0c367
2019-03-30 19:17:37 +01:00
Harald Welte 0a64da6e2d rspro_server: Split CONNECTED into CLIENT and BANKD specific states
Change-Id: I5b2205393de62b16439b49fb7a39ee640f750cc5
2019-03-30 17:38:04 +01:00
Harald Welte 1b07f7fbc9 rspro_server: Add more comments
Change-Id: Iafe8674161a117b70e97ffeac4e988ba9a45db93
2019-03-30 17:33:07 +01:00
Harald Welte ba781c065f rspro_server: Fix log output in client_conn_send()
Change-Id: I4b089011dcdc261837d1d9a7dc184568027f6df0
2019-03-30 17:32:53 +01:00
Harald Welte ce638d8fd7 client, bankd: Add SIGUSR1 handling for talloc context debugging
Change-Id: I9153f4cc89b3911a4f9ea4f02fe1b108420d2eed
2019-03-17 09:36:04 +01:00
Harald Welte cf8b89ad84 Move client/bank slot conversion functions to rspro_util.c
Change-Id: I18f1d1cb1fb712b01a0991419743db52338688af
2019-03-11 22:16:22 +01:00
Harald Welte d571a3e2e1 RSPRO: split ConfigClient into ConfigClientId and ConfigClientBank
The point is that the ClientId is only set once at start-up (and
also only optionally), while the Bank IP/port/ID/slot can be changed
any number of times during a RSPRO connection.

Change-Id: Ic76207c7dd7c18fe93bc5133b29c5f9438a9fb0e
2019-03-11 22:09:50 +01:00
Harald Welte b49ac9c6bb rspro_util: Add rspro_msgt_name() to get RSPRO message type name + use it
Change-Id: I4b270addd024f9766923183a75381b71ffe1cfae
2019-03-09 20:36:07 +01:00
Harald Welte 15b75e1e5c remsim-server: Add support for keepalive
This ensures that any RSPRO client (remsim-client or remsim-bankd) is
disconnected if he's no longer responding to IPA PING requests.

Change-Id: I324f0f2a0613d6310e1d191103b136c539b6ec05
Depends: libosmocore Change-Id I2763da49a74de85046ac07d53592c89973314ca6
2019-03-08 17:09:07 +01:00
Harald Welte 7bfcc65227 slotmap: restructure read_cb()
Change-Id: I7fb457f028f9aabc7b4b53bf036e5eac9d785299
2019-03-08 16:55:01 +01:00
Harald Welte e5c7773c7f client slot
Change-Id: I40f0589b2014a1df5ce4de745ec46642c68ad0c5
2019-03-07 23:58:24 +01:00
Harald Welte f5a0fa37c4 Initial version of remsim-server
Change-Id: I1caadc528d5e61a4129c32c53283250cd37f3a3c
2019-03-07 21:35:48 +01:00