Commit Graph

4166 Commits

Author SHA1 Message Date
Pau Espin c7deaf28aa Bump version: 1.5.1.282-ab5e-dirty → 1.6.0
Change-Id: Ia3ac0a36b9e898996f596c6d2787e03cd59bfc11
2021-11-16 13:08:23 +01:00
Pau Espin ab5e989274 osmo-release.sh: Blacklist script file from LIBVERS matches
The file itself appears in the list of matches when run in
libosmocore.git. Let's prevent it:
"""
expr: non-integer argument
WARN: Found 19 files matching debian/lib*.install for LIBVERSION=`gitdiff--cached-GLIBVERSION--stat|grepMakefile.am`, manual check required!
"""

Change-Id: I6d750d312017ebb434650a6e19707ec60faf4020
2021-11-16 13:03:08 +01:00
Pau Espin 4a15c2d47a contrib/libosmocore.spec.in: Depends on talloc 2.1.0
With recent commit (see below) libosmocore started using talloc API
talloc_pooled_object(), which is available only startinf from talloc
2.1.0.
Let's bump required version check accordingly.

Issue found by osmo-release.sh:
ERROR: configure.ac <talloc, 2.1.0> does NOT match contrib/*.spec.in <talloc, 2.0.1>!

Fixes: b72867f0e6
Change-Id: I6797e244118ce2ca7dd22050ff505d8442bba672
2021-11-16 12:47:49 +01:00
Neels Hofmeyr 25c9741445 add osmo_time_cc, moved from osmo-bsc
Related: SYS#4878
Related: Ica9f908a1a30f334a24c59471affa11225117e12 (osmo-bsc)
Change-Id: Iabb17a08e6e1a86f168cdb008fba05ecd4776bdd
2021-11-15 09:06:03 +00:00
Harald Welte 5eb67c2d66 rate_ctr: Make it safe to call rate_ctr_init() several times
There might be library code that has rate counters, and if the main
program calls rate_ctr_init() a second time, we can skip the second
initialization.

Change-Id: I6f5342a77518599eb5ac9a0f0605917a78fcc387
2021-11-14 20:46:11 +01:00
Daniel Willmann 1f666e875d frame_relay, gprs_ns2_fr: Fix log messages, remove unused struct
Fix typo and remove any reference to GRE from gprs_ns2_fr.c.
GRE code is in gprs_ns2_frgre.c

Change-Id: I51c756f3c9d918552591bf87861cb4799721ac37
2021-11-11 16:50:01 +01:00
Daniel Willmann 334cf8759f ns2: Avoid use-after-free when SGSN-side non-persistent SNS-NSE fails
alive_timeout_handler() changes the state to RECOVERING which calls
ns2_st_alive_onenter()->ns2_nse_notify_unblocked(unblocked=false)->
ns2_sns_notify_alive(unblocked=false)

When all (signalling) NSVCs have failed and gss->role is SGSN and not
persistent sns_failed() calls gprs_ns2_free_nse() which talloc_free()s
the nse before returning.

The next line in ns2_nse_notify_unblocked() tries to read nse->alive which then causes the
use-after-free.

Change-Id: I0486a77fd3e21fd3904bd19e4e0225ffbf654935
Related: OS#5302
2021-11-11 16:50:01 +01:00
Alexander Couzens 6b5a533f4d include: add enum for UTRAN cipher
Change-Id: I4b9baff2c2fbd0e339fc769cc69cce58d3a72cdf
2021-11-11 09:02:24 +00:00
Vadim Yanitskiy 52a5c112f1 stats: clarify error messages in cfg_no_stats_reporter_{statsd,log}
Change-Id: I287130213c7de31a510f293bed0f3daddd53ce04
Related: SYS#5713
2021-11-09 15:04:00 +03:00
Vadim Yanitskiy d6b00591f7 stats: don't mark reporter as 'disable' beforehand
Change-Id: I330a079807cca48b7cc43767abcd2b58830a05fc
Related: SYS#5713
2021-11-09 13:46:59 +03:00
Vadim Yanitskiy 4f1c4e3027 stats: cosmetic: print 'stats interval' before the reporters
It's better to have the common parameters printed first.

Change-Id: Ifb401d4d363fb70e89960ca739baba5ee55eefe8
Related: SYS#5713
2021-11-09 13:41:56 +03:00
Vadim Yanitskiy bfc8377398 stats: allow configuring reporter's name in the VTY
This allows configuring more than one reporter of the given type.

Change-Id: Ia815c24dc974648985539913012b3b074ea317a9
Related: SYS#5713
2021-11-09 04:35:07 +03:00
Vadim Yanitskiy 4e92472281 stats: use llist_add_tail() in osmo_stats_reporter_alloc()
This allows printing reporters in the exact order as they were configired.

Change-Id: I904cd0ed53510dbe26c15cd287ba2707ca04cd6e
Related: SYS#5713
2021-11-09 04:34:46 +03:00
Vadim Yanitskiy ac3a3fc91b tests/stats: add VTY transcript tests
Change-Id: I85ac73f4c866617179e55821a292aad33b6edc99
Related: SYS#5713
2021-11-09 04:29:57 +03:00
Vadim Yanitskiy 190b6efafd gsm/protocol/gsm_04_08.h: add gsm48_meas_res_is_valid()
Change-Id: Iae2bd508a08c4b5093d36e514c22218763e11edf
2021-11-04 17:45:52 +03:00
Pau Espin 843a84c425 logging: Fix double lock of log_tgt_mutex
Recent commit introduced the "blocking-io" param to "log stderr" VTY
command, which calls log_target_file_switch_to_{stream,wqueue}.
The VTY command already locks the log_tgt_mutex mutex, since it has to
access the tgt list. However, the functions mention above also want to
lock the same mutex in order to log information. Let's drop the logging
to avoid the double lock, and update its documentation to mention it
must be called with the lock already held, as documented on other
similar functions.

The issue can be spotted when running osmo-trx-uhd:
"""
(gdb) bt
 #0  0x00007ffff75d7600 in __lll_lock_wait () from /usr/lib/libpthread.so.0
 #1  0x00007ffff75d0503 in pthread_mutex_lock () from /usr/lib/libpthread.so.0
 #2  0x00007ffff66314fb in log_tgt_mutex_lock_impl () at /git/libosmocore/src/logging.c:130
 #3  0x00007ffff6638e74 in log_check_level (subsys=8, subsys@entry=-1, level=level@entry=3) at /git/libosmocore/src/logging.c:1510
 #4  0x00007ffff6639c91 in log_target_file_switch_to_wqueue (target=target@entry=0x611000000320) at /git/libosmocore/src/logging.c:1186
 #5  0x00007ffff68565d3 in cfg_log_stderr (self=<optimized out>, vty=0x6140000018a0, argc=0, argv=<optimized out>) at /git/libosmocore/src/vty/logging_vty.c:859
 #6  0x00007ffff683db3d in cmd_execute_command_strict (vline=0x60b0000dfe80, vty=vty@entry=0x6140000018a0, cmd=cmd@entry=0x0) at /git/libosmocore/src/vty/command.c:2768
 7  0x00007ffff683e396 in config_from_file (vty=vty@entry=0x6140000018a0, fp=fp@entry=0x615000036400) at /git/libosmocore/src/vty/command.c:2880
 8  0x00007ffff684cedb in vty_read_config_filep (confp=confp@entry=0x615000036400, priv=priv@entry=0x0) at /git/libosmocore/src/vty/vty.c:1529
 9  0x00007ffff684ebfc in vty_read_config_file (file_name=0x7fffffffe7d8 "/build/new/conf/osmo-trx-uhd.cfg", priv=0x0) at /git/libosmocore/src/vty/vty.c:1920
 10 0x0000555555565270 in main (argc=3, argv=0x7fffffffe3c8) at /git/osmo-trx/Transceiver52M/osmo-trx.cpp:652
"""

Debugged by rebuilding libosmocore with "LOG_MTX_DEBUG 1":
"""
/libosmocore/src/logging.c:1510 [log_check_level] lock
/libosmocore/src/logging.c:1522 [log_check_level] unlock
/libosmocore/src/vty/logging_vty.c:844 [cfg_log_stderr] lock
/libosmocore/src/logging.c:1510 [log_check_level] lock
"""
Fixes: b72867f0e6
Related: OS#4311
Change-Id: Idb4215fa2f364e28c0bb73fb9975b6c9f50a46f6
2021-11-03 17:43:19 +01:00
Vadim Yanitskiy 36c69ed256 gsm/protocol/gsm_44_004.h: fix missing include of 'endian.h'
Without this header, both OSMO_IS_{BIG,LITTLE}_ENDIAN macros are
not defined, and thus the 'struct gsm_sacch_l1_hdr' is empty.

Change-Id: I2c14a1b898fdb743191dab0e6be157ce916e8161
2021-10-29 20:26:20 +03:00
Vadim Yanitskiy 7044d20863 Revert "Prevent GCR encoder/decoder functions from being used directly"
We need this API for communicating GCR over the MNCC and SIP.

Change-Id: I06babb959fdc82f4e82d92260131d60c98b0abd2
Related: OS#5164
2021-10-29 05:47:09 +00:00
Pau Espin 75b03e575d configure.ac: Depend on talloc 2.1.0
With recent commit (see below) libosmocore started using talloc API
talloc_pooled_object(), which is available only startinf from talloc
2.1.0.
Let's bump required version check in configure.ac accordingly.

Fixes: b72867f0e6
Change-Id: Id9d10d02b9b4500a246fcc3e071a14c1d7da4f14
2021-10-28 15:12:37 +02:00
Harald Welte 78d7367c90 logging: Attempt a synchronous, non-blocking write first (file, stderr)
In the old days, we performed synchronous, blocking writes to the log
file or stderr.  This was replaced by code that turned all log
file/stderr writes into non-blocking writes behind a write_queue.

This patch now introduces a further optimization: If we currently
don't have any log messages pending in the write queue, we are not
back-logged and assume we have a fair chance of writing the log message
right now, synchronously.  So we try that first, and only enqueue
the log message if the write fails (no bytes or insufficient number
of bytes written).

This way we should get the best of both worlds: No delay/re-ordering
(and lower select syscall load) for the "normal" case (benefits of
the old synchronous writes) while at the same time never risking to
block on log output.

Related: OS#4311
Change-Id: I08469a7e4be9bc5bbd39140457bb582f4a0b1703
2021-10-26 17:16:50 +02:00
Harald Welte a0b57d0688 logging: Avoid memcpy from stack to msgb in _file_output()
For file and stderr output, the existing code always generates
the log string on a stack buffer, and then (in case of non-blocking
write via write_queue) copies it over to a msgb.

Let's optimize this by turning _file_output() into a raw_output
callback which first allocates the msgb and then format-prints
directly to that msgb instaed of stack + memcpy.

This has the disadvantage that we don't know how long the buffer
has to be in order to print the entire string to it.  As a result
we always have to allocate a 4k-sized buffer (plus msgb overhead).

The write_queue length for log file output has been decreased from
1024 entries to 156 entries in order to stay within the same
memory requirements for each log target memory pool (about 648 kBytes).

Related: OS#4311
Change-Id: I0d10b0199576d2e7ff6421a6dba19ae5ffafd946
2021-10-26 17:16:50 +02:00
Harald Welte b72867f0e6 logging: Change stderr + file target to use non-blocking write
So far, we used blocking, buffered fwrite() to write to stderr
and file targets.  This causes problems if there are [slow] consumers
causing delays, such as gnome-terminal (when the program is started
interactively) or systemd/journald (where we observe 64..128ms blocks on
stderr).

This patch introduces stderr/file based logging via write_queue
and osmo_select_main(), i.e. switch from glibc-buffered, blocking
to internally buffered, non-blocking writes.

* when osmo_stderr_target is created via application.c, we create it
  in blocking stream mode for backwards compatibility, particularly
  for [smaller] programs that don't use osmo_select_main()

* when the VTY code encounters 'log stderr' or 'log file FILENAME',
  we switch that respective target to non-blocking write-queue mode,
  as this means the application is in fact using osmo_select_main()

* The config file can now state 'log stderr blocking-io' or
  'log file FILENAME blocking-io' to explicitly enforce using blocking
  stream based I/O

* The application can at any time use API functions to switch either way

Closes: OS#4311
Change-Id: Ia58fd78535c41b3da3aeb7733aadc785ace610da
2021-10-26 17:16:47 +02:00
Vadim Yanitskiy 8db64ee810 gsm_08_58: extend struct abis_rsl_osmo_temp_ovp_acch_cap
This change adds new [bit-]fields in order to allow:

  * selectively enabling SACCH and/or FACCH,
  * setting the RxQual (BER) threshold.

Change-Id: Ia28293a12de0af71f55e701fb65c46e905dae217
Related: SYS#5319
2021-10-21 21:11:28 +03:00
Pau Espin 0a9430ee48 {ctrl,vty}/ports.h: Allocate ports for osmo-hnodeb
Change-Id: I6514d040d88d145a321075911368645868e6280e
2021-10-21 12:53:33 +02:00
Pau Espin 1573add472 logging: Change LLAPD category color to purple-like one
Previous dark shiny blue one is really difficult to read on the
terminal. Let's change it for some purpleish color which is far easier
to read.

Change-Id: Ia5c0860dd8d756bb24eb8972f94590bfba5bc865
2021-10-15 18:25:06 +00:00
Alexander Couzens 4ef56c0e2d ns2: correct parse a BLOCK PDU which was received over a different NSVC
BLOCK PDU can be send over a different NSVC than the NSVC.
E.g. informing a NSVC got blocked in case of a lower-layer failure.

Change-Id: I483e3a1d3b8c43bbb0cc6185b7f7f772bcb264bf
2021-10-15 13:39:31 +00:00
Alexander Couzens 58be42749e ns2: don't forward an invalid RESET PDU to the FSM
When receiving an invalid RESET (e.g. wrong NSEI or NSVCI) do not
forward the PDU to the NSVC fsm. Answer it with correct NSEI & NSVCI,
log the PDU, then ignore it.

Fixes: OS#5258
Change-Id: I6e562def9c5a1e4534d42884215272b1e66d26c2
2021-10-15 13:39:31 +00:00
Alexander Couzens f8635c7e6f ns2: improve log line when receving a PDU with wrong NSE
Change-Id: I072510461fb426fa62ca20c5103764b0efd25f82
2021-10-15 13:39:31 +00:00
Vadim Yanitskiy c549719088 utils: introduce osmo_talloc_replace_string_fmt()
Change-Id: I6b84fa0525555a98c531fc558e5dc1298fec00c1
2021-10-13 14:03:26 +03:00
Alexander Couzens 69cc4b613b ns2: correct parse a STATUS PDU which was received over a different NSVC
STATUS PDU can be send over a different NSVC than the NSVC which
generated the STATUS PDU. E.g. informing a NSVC got blocked in case of a lower-layer failure.

Change-Id: I5c9e9de10c669c1226da67bb9e2663c5cfe828a8
2021-10-08 05:43:57 +00:00
Alexander Couzens d802f9ae6e ns2: message: allow to pass a foreign NSVCI to STATUS PDU
To answer correct on a BLOCK PDU with a different NSVCI, the
STATUS PDU needs also a NSVCI parameter.

Change-Id: I373eb48697097cdfa45748a091c11f7b3f0345fa
2021-10-08 05:43:46 +00:00
Alexander Couzens cc1621e476 ns2: fsm: add comment don't answer on a STATUS with a STATUS
Change-Id: Ib8f700f9193a96a7bada3b0293dcecf6a05d6efc
2021-10-08 05:43:46 +00:00
Alexander Couzens a2b846be2f ns2: ensure the NSVC is in the correct mode for NSVC UNKNOWN/NSVC BLOCKED cause codes
Those cause codes are only valid for BLOCK/RESET NSVCs.

Change-Id: I560f1c8c2826befd03641bebffe156ac070061c2
2021-10-08 05:43:46 +00:00
Alexander Couzens 67cfc5dc9a ns2: message: BLOCK/BLOCK ACK allow to use a given NSVCI instead of using the nsvc nsvci
The BLOCK and BLOCK ACK PDUs can be send over a working NSVC to inform
the NSE that a NSVC is blocked.

Change-Id: I6189229fdc1f054e86811bc60cb7646e1f758a78
2021-10-08 05:43:46 +00:00
Eric Wild 8ae40cbb91 gsmtap: allow 127.0.0.x local listeners
Even if not bound to a IF they just exist and work as expected, and make
distinguishing traffic for local setups easy.

Change-Id: I1043dfd8075f14481011f43db45c943e9320413c
2021-10-06 13:01:26 +00:00
Vadim Yanitskiy 6dce2cbc1e utils: remove misleading comments for osmo_hexdump[_nospc]_c()
The buffer is allocated dynamically on heap, so there is no such
limitation of 4096 bytes / 1365 characters.

Change-Id: I960dd6a53123fd4209ef6e61dcd0d22e4005e397
2021-10-04 12:37:51 +00:00
Neels Hofmeyr 34907fe6e1 revisit some calls of strtol(), stroul(), strtoull()
Replace some with atoi(), where the VTY has already validated correct
range of the argument.

Replace others with the new osmo_str_to_int() or osmo_str_to_int64()
functions, possibly covering more detection of invalid number strings.

Leave those strtol() callers that depend on endptr to provide the next
string token.

Related: SYS#5542
Change-Id: I0ebb06e751c28f7d1cdf328de29cd227a2449391
2021-10-04 11:24:59 +00:00
Vadim Yanitskiy 6b60d52abf fix rsl_chan_nr_str_{buf,c}(): enlarge the buffer size
20 bytes is not enough for some VAMOS specific channel number values,
so the resulting string representation gets truncated by snprintf():

  expected: "VAMOS TCH/H(0) on TS4\0"
  actual:   "VAMOS TCH/H(0) on T\0"

Let's enlarge the buffers to 32 bytes.

Change-Id: I68d839f4ab742cf56de34e7e22572a1163aec2da
2021-10-01 15:47:05 +06:00
Neels Hofmeyr 137efc9b18 cosmetic: get rid of 3 deprecation warnings
Some deprecated functions are still used in libosmocore .c code. Use
OSMO_DEPRECATED_OUTSIDE() to get rid of those "resident warnings".

Change-Id: I6e79acc87be37ac1aaec900e737e41450b46826a
2021-09-30 18:33:43 +00:00
Neels Hofmeyr 6a5940740a refactor stat_item: report only changed values
Change the functionality of skipping unchanged values: instead of
looking up whether new values have been set on a stat item, rather
remember the last reported value and skip reporting identical values.

stats_test.c shows that previously, a stat item reported a value of 10
again, even though the previous report had already sent a value of 10.
That's just because the value 10 was explicitly set again, internally.

From a perspective of preserving all data points, it could make sense to
send consecutive identical values. But since we already collapse all
data points per reporting period into a max, that is pointless.

Related: SYS#5542
Change-Id: I8f4cf34dfed17e0879716fa2cbeee137c158978b
2021-09-30 18:33:43 +00:00
Neels Hofmeyr e90c7176be refactor stat_item: get rid of FIFO and "skipped" error
Intead of attempting to store all distinct values of a reporting period,
just store min, max, last as well as a sum and N of each reporting
period.

This gets rid of error messages like

  DLSTATS ERROR stat_item.c:285 num_bts:oml_connected: 44 stats values skipped

while at the same time more accurately reporting the max value for each
reporting period. (So far stats_item only reports the max value; keep
that part unchanged, as shown in stats_test.c.)

With the other so far unused values (min, sum), we are ready to also
report the minimum value as well as an average value per reporting
period in the future, if/when our stats reporter allows for it.

Store the complete record of the previous reporting period. So far we
only compare the 'max' value, but like this we are ready to also see
changes in min, last and average value between reporting periods.

This patch breaks API by removing:
- struct members osmo_stats_item.stats_next_id, .last_offs and .values[]
- struct osmo_stats_item_value
- osmo_stat_item_get_next()
- osmo_stat_item_discard()
- osmo_stat_item_discard_all()
and by making struct osmo_stats_item opaque.
In libosmocore, we do have a policy of never breaking API. But since the
above should never be accessed by users of the osmo_stats_item API -- or
if they are, would no longer yield useful results, we decided to make an
exception in this case. The alternative would be to introduce a new
osmo_stats_item2 API and maintaining an unused legacy osmo_stats_item
forever, but we decided that the effort is not worth it. There are no
known users of the removed items.

Related: SYS#5542
Change-Id: I137992a5479fc39bbceb6c6c2af9c227bd33b39b
2021-09-30 18:33:43 +00:00
Keith Whyte 3f43134b6b GPRS: Add PDP_TYPE_N_IETF_IPv4v6
Change-Id: I1f82f9d8fc13dcc4474760329bd74ae9685b9031
2021-09-29 21:05:20 +02:00
Pau Espin 4e3b594e93 cosmetic: gsm: meas_rep.h: Fix typo in comment
Change-Id: I35c47a69ad1e9a75de6cc82c44a87828ebbb7189
2021-09-28 11:32:44 +02:00
Pau Espin 50e6f06658 gsm: Mark gsm0858_rsl_ul_meas_enc() pointer param const
Change-Id: I9b2704250d8a3f6c6fc6cd2a5136b1408c8ed965
2021-09-28 11:32:00 +02:00
Alexander Couzens ca5ce0d849 ns2: nsvc: add a uptime/downtime to track the last state change
To show adminstrator the last state change of a nsvc add a timestamp and
show it on the vty

> show ns nsei 1234
NSEI 01234: UDP, DEAD since 0d 0h 1m 42s
[...]
  4 NS-VC:
   UNBLOCKED DYNAMIC sig_weight=1 data_weight=1 udp)[127.0.0.1]:22000<>[127.0.0.1]:23001 ALIVE since 0d 0h 0m 1s
   UNBLOCKED DYNAMIC sig_weight=2 data_weight=2 udp)[127.0.0.1]:22000<>[127.0.0.1]:23000 ALIVE since 0d 0h 0m 1s
   UNBLOCKED DYNAMIC sig_weight=2 data_weight=2 udp)[127.0.0.1]:22001<>[127.0.0.1]:23000 ALIVE since 0d 0h 0m 1s
   UNBLOCKED DYNAMIC sig_weight=1 data_weight=1 udp)[127.0.0.1]:22001<>[127.0.0.1]:23001 ALIVE since 0d 0h 0m 1s

Related: OS#5028
Change-Id: Ie3a039a209869295afa5feda39297cee81fedf22
2021-09-23 13:12:34 +02:00
Alexander Couzens 2c64c257c8 ns2: nse: add a uptime/downtime to track the last state change
To show adminstrator the last state change of a nse add a timestamp and
show it on the vty

> show ns nse 1234

NSEI 01234: UDP, ALIVE since 0d 0h 0m 16s
 FSM Instance Name: 'GPRS-NS2-SNS-SGSN(NSE01234-SNS)[0x6120000012a0]', ID: 'NSE01234-SNS'
  Log-Level: 'DEBUG', State: 'CONFIGURED'
  Timer: 4
 Maximum number of remote  NS-VCs: 8, IPv4 Endpoints: 2, IPv6 Endpoints: 0
 [...]

Related: OS#5028
Change-Id: I8143080a3c5c9a55d37dfad44ba2ac6561daa216
2021-09-23 13:12:34 +02:00
Alexander Couzens 06929166de vty: add vty_out_uptime() print the uptime to the vty
vty_out_uptime() calculates the time difference to a given timespec
and print it in a human readable format (days, hours,
minutes, seconds) to the vty.

Related: OS#5028
Change-Id: I264a3f49096b96646e0a1f5366623ac20d860793
2021-09-23 13:12:34 +02:00
Harald Welte 53b4bbb955 osmo-auc-gen: Print RFC3310 IMS HTTP-AKA style base64 nonce/res
This is useful when debugging IMS Authentication which uses
RFC3310 representation of the nonce and expected result.

Change-Id: Ibfa72410d8ff8e5b42063f1a12bff69ad2bebbb8
2021-09-21 19:57:56 +00:00
Harald Welte d075e3ae23 base64: reformat using Lindent to conform to our coding style
Change-Id: I2286fa0d2cba7c11359bb48329135dfcd0d8a948
2021-09-21 19:57:56 +00:00
Harald Welte 292f9e7014 base64: Migrate over to osmocom
This containts the osmocom changes to the mbedtls base64 code
merged in the previous commit.

Change-Id: I82c1bf5f827c8def370dbcb80b146e9e4184c4a3
2021-09-21 19:57:56 +00:00