Commit Graph

2658 Commits

Author SHA1 Message Date
Pau Espin b0c2f75665 jenkins: Validate gsm 08.58 IEs are added to tlv_definition
It was recently found that several IEs which were added in the header
file were not actually added to the tlv_definition, and hence the tlv
parser failed to decode them. Let's make sure we don't foget to add new
IEs in the future.

Related: SYS#5915

Change-Id: Id8a679ca43eb0fcc4882780e9a95ec21c7f51972
2022-04-05 17:38:25 +02:00
Pau Espin 388a53a8d7 rsl: Fix tlv_parse of IPAC_DLCX_IND message
The IE was missing in rsl_att_tlvdef.

Related: SYS#5915
Change-Id: Ib637197ef3508ec94aec05d08d4e6aa15ddea055
2022-04-05 17:32:41 +02:00
Daniel Willmann 767bfd8c87 bssgp_bvc_fsm: Add a hook to notify when a reset was acknowledged
There are cases where we want to be notified of a successful BVC reset,
e.g. for a signalling because we can then start resetting the PtP-BVCs.
With this hook it's now possible to do that.

Change-Id: If240dd13f0f674693018c93390386b2c8afb97af
Related: SYS#5908
2022-03-30 18:00:56 +02:00
Harald Welte c17546faff vty: Support platforms that don't support pthread_getname_np()
pthread_getname_np() is a non-portable extension of pthreads.  While
it exists in glibc, for example musl didn't have it until rather
recently (April 2021) and there still hasn't yet been a musl release
with this change, resulting even current OpenWRT not yet supporting
pthread_getname_np.

So let's check if pthread_getname_np is supported, and only use it
in that case.

Change-Id: Ibd01485af24e2fe574006f8d049bf37226dda966
2022-03-29 12:58:01 +00:00
Harald Welte e1a0aaa860 libosmovty: Link libosmovty against libpthread
Ever since Change-Id If76a4bd2cc7b3c7adf5d84790a944d78be70e10a in 2020
(part of libosmocore >= 1.4.0) we have introduced cpu_sched_vty.c, which
directly uses libpthread.  As a result, libosmovty should be using
pthread compiler flags and link against libpthread.

This missing dependency is causing osmocom applications to
fail to link on OpenWRT (at leats for ath79-generic).

Change-Id: I7febbf88cbe61eacd05f46a9316e773b5c148e77
Related: SYS#4986
2022-03-27 23:31:24 +02:00
Vadim Yanitskiy be1338789a bssmap_le: support additional IEs in Perform Location Request
Change-Id: I8775a93cf4089b1752d040e43d2cba6b8997f955
Related: SYS#5891
2022-03-22 18:38:19 +03:00
Pau Espin 3cf475917e gsm0808: Add missing IEs in bss_att_tlvdef
Change-Id: I8660640ce50a6dc20e718c4165ccf779c5f553a4
2022-03-18 17:36:46 +01:00
Pau Espin fffd7c345b gsm0808: Fix decoding of IE GSM0808_IE_LCS_CLIENT_TYPE
Change-Id: I7acafdefd105e330c466df2e17e884327651e348
2022-03-18 17:36:46 +01:00
Vadim Yanitskiy 7ec19de720 libosmocodec: osmo_hr_check_sid(): simplify the logic
According to TS 101 318, section 5.2.2, a SID frame is identified
by a SID codeword consisting of 79 bits (r34..r112) which are all 1.
Given that there are no gaps in the codeword, we don't really need
to use bitvec_get_bit_pos() and check each field individually.
This brings additional complexity and negatively affects performance.

Instead, let's use bitvec_get_bit_pos() to check all bits in a row.

Change-Id: I678f8ff92317fe87f1aca511a3a062ad898e55cc
Related: SYS#5853
2022-03-10 13:57:39 +03:00
Neels Hofmeyr b54229d2ec osmo_time_cc: rate_ctr presence should not affect counting
Make sure that osmo_time_cc counts exactly the same, regardless of a
rate_ctr being present or not. Only skip sending counter increments when
there is no rate counter, do not affect anything else.

In osmo-bsc, we are discussing a patch where an lchan redirects
osmo_time_cc counter increments to different rate counters depending on
its current type. In my comments I am also claiming that osmo_time_cc
works the same regardless of a rate_ctr being present or not. Looking at
the code, this is not actually the case.

Before this patch, when there is no rate_ctr, the reported_sum would
freeze, and as soon as a rate_ctr shows up, all counter increments from
the previous reported_sum would be sent to the newly set rate_ctr.
Instead, we want counter increments to simply be lost while there is no
rate_ctr set. IOW, rate_ctr == NULL should mean >/dev/null.

Related: I1b0670c47cb5e0b7776eda89d1e71545ba0e3347 (osmo-bsc)
Change-Id: I380b28d7ab0a6c8aab6c7e2a64bc73cab14863d2
2022-03-08 23:41:23 +01:00
Harald Welte ef872cb7ad usb: Match device by VID/PID without path/addr if it is unique
If there's only a single device with matching VID/PID attached,
we don't need to insist that either the path or the address of the
device matches.  Those are only needed to disambiguate multiple
devices with identical VID/PID.

Change-Id: I2ef245a56dfcf22758a0216b86d2a5c602ee5588
2022-03-03 17:48:51 +01:00
Pau Espin 28b404fb71 gsm: lapd_core: Change log line NOTICE->INFO
Change-Id: I71f014645b4b487bf91499a1da9ed2d3032d7e40
2022-03-02 19:03:32 +01:00
Neels Hofmeyr 9c7f7f85c8 add osmo_sockaddr_set_port()
Do it like osmo_sockaddr_port() in reverse.

Related: SYS#5599
Change-Id: I9512e44c3203daebb3fe3435fceef167613c1a73
2022-03-01 16:33:40 +00:00
Neels Hofmeyr a25a6dca25 BSSAP: HO Request Ack: add missing Codec List (BSS Supported)
Related: SYS#5839
Related: I3c0576505a3ceb3cd5cc31dc69c5bc4a86a4ea08 (osmo-bsc)
Change-Id: Iab0a7b4d81592157fc111d1adb9e9f4cb53a94e9
2022-02-28 11:04:08 +00:00
Michael Iedema a6d1ef0d60 stats: use tcp stat names as provided
If an API user has defined a name for this particular
stat, we should consider it unique and not append ip and
port information from the connection.

By appending ip and port information to all tcp stat
names, we end up creating unique stat names every
time a reconnection occurs and the source port changes.
This makes the statistic impossible to track over time
as it is continually using a different name.

A quick example from the field over the course of a
day:

tcp.ipa-rsl-0,r=192.168.55.88.33056<->l=192.168.0.1.3003.tcp.rtt
tcp.ipa-rsl-0,r=192.168.55.88.33311<->l=192.168.0.1.3003.tcp.rtt
tcp.ipa-rsl-0,r=192.168.55.88.35510<->l=192.168.0.1.3003.tcp.rtt
tcp.ipa-rsl-0,r=192.168.55.88.35958<->l=192.168.0.1.3003.tcp.rtt
tcp.ipa-rsl-0,r=192.168.55.88.36110<->l=192.168.0.1.3003.tcp.rtt
tcp.ipa-rsl-0,r=192.168.55.88.39269<->l=192.168.0.1.3003.tcp.rtt
tcp.ipa-rsl-0,r=192.168.55.88.40394<->l=192.168.0.1.3003.tcp.rtt
tcp.ipa-rsl-0,r=192.168.55.88.40397<->l=192.168.0.1.3003.tcp.rtt
tcp.ipa-rsl-0,r=192.168.55.88.42920<->l=192.168.0.1.3003.tcp.rtt
tcp.ipa-rsl-0,r=192.168.55.88.43839<->l=192.168.0.1.3003.tcp.rtt

This change would treat tcp stats like other stats
around the system. A unique name must be set by the
API user. This would let us set a unique name like
the following to avoid the situation above:

bts.0.rsl.0.tcp.rtt

Matching the existing rsl related stats:

bts.0.rsl.delete_ind
bts.0.rsl.ipa_nack
bts.0.rsl.unknown

...they retain a constant name regardless of the underlying
connectivity situation.

Change-Id: Ib04c2f5bfcbd6c19dd87debf1fc053abf0b9bef2
2022-02-24 06:22:55 -08:00
Pau Espin b5551eec33 gsm: [ABI BREAK] Support CellId SAI, change CellId CGI-PS id number
Those are available in 3GPP TS 48.008 version 16.0.0 Release 16, section
3.2.2.17 Cell Identifier. It can be seen that we have a collision
between the osmocom non-standard format and the SAI standard one.

This is because CGI-PS is not really a TS 48.008 Cell Identifier, but only
specified in TS 48.018 and has no ID number assigned. The CGI-PS was
added there because the whole osmo-bsc neighbour configuration works
with CellIds to manage neighbours, so it felt natural to extend the APIs
to also provide means to use CGI-PS format (TS 48.018 even refers 48.008
existance and mentions there's no explicit ID).

At the time this Cell Identifier was added, the firstly available number
(11) was taken, which was of course a really bad idea since newer
versions of the spec can at some point use it, which is the case if one
checks for instance TS 48.008 Release 16 SAI Cell Id.

There no perfect way to fix this bad decision at the time, but the
CGI-PS is only used in osmo-bsc and only for RIM related purposes, so by
changing the ID of CELL_IDENT_WHOLE_GLOBAL_PS, we only break RIM under
some specific CIs being used, and when an osmo-bsc is built against
older libosmocore and then used at runtime against a newer libosmocore
(which should be rare).
Hence, the downside is acceptable, and by moving the new ID number to be
ouside of the spec proto TS 48.008 range (4 bits), we make sure we don't
have the same problem again in the future.

Related: SYS#5838
Fixes: ca33a71ca8
Change-Id: Id25e563febdb7640174540136225f399515a0089
2022-02-16 17:59:23 +01:00
Neels Hofmeyr 1790f1763a follow-up to osmo_sockaddr_from/to_octets()
Forgot to apply one code review change before merge.

Related: OS#5599
Change-Id: Id202f3fda51bea9149ab3462a2efe35cf08d8030
2022-02-07 22:15:27 +01:00
Neels Hofmeyr cf7f7924d2 add osmo_sockaddr_from/to_octets()
Shorthand for the INET/INET6 switch() to get/put the addr part, useful
for encoding and decoding message buffers.

Related: OS#5599
Change-Id: Ie9e33bfac525c59c30714663d2bfcc62ec9eeb81
2022-02-07 22:13:20 +01:00
Neels Hofmeyr 1633735e9b add osmo_quote_str_buf3, osmo_escape_str_buf3
There already are osmo_quote_str_buf() and osmo_quote_str_buf2(), same
for _escape_, but none of them return the snprintf() like string length.
A private function does, publish this in the API.

The returned chars_needed is required to accurately allocate sufficient
size in string functions that call osmo_quote_str/osmo_escape_str. I am
adding such in osmo-upf.git.

Related: SYS#5599
Change-Id: I05d75a40599e3133da099a11e8babaaad0e9493a
2022-02-07 22:10:29 +01:00
Neels Hofmeyr f3270f246f log: socket.c: rather use the osmo_sockaddr_str _FMT
The OSMO_SOCKADDR_STR_FMT() and _ARGS() macros properly place square
braces around IPv6 addresses, so that the port nr is clearly
distinguishable.

before: 1:2::3:4:5
after: [1:2::3:4]:5

When using a struct reference, the macro resolves to '(&sastr) ? .. : ..',
which the compiler complains about as "condition is always true". Shim
around that error with a pointer variable.

I considered using osmo_sockaddr_to_str_c() instead, but here in
socket.c we cannot assume that osmo_select_main_ctx() is being used and
hence can't just use OTC_SELECT for log string composition. The
struct osmo_sockaddr_str is a string representation in a local variable,
and hence doesn't need talloc for log strings.

I considered adding log_check_level() around the log string conversion,
but since all of these instances are on LOGL_ERROR, I didn't bother.

Related: SYS#5599
Change-Id: Idbe7582b2b7f14540919e911dad08af6d491f68f
2022-02-07 22:10:19 +01:00
Harald Welte e452dd053e osmo_libusb: Print log message on libusb initialization error
Change-Id: I2ac56e378e1279e7e333d93e54cd7a182d76498d
2022-01-31 18:40:03 +01:00
Harald Welte a366a89597 osmo_libusb: Use libusb_get_pollfds() to get initial file descriptors
It seems it is insufficient to register file-descriptor call-backs
with libusb_set_pollfd_notifiers(), but we also need to call
libusb_get_pollfds() once to get the initial set of file descriptors
which may have been created already during libusb_init().

As we don't have a libusb context before libusb_init() returns,
we cannot call libusb_set_pollfd_notifiers() early enough to be
active already during libusb_init().

Change-Id: Icf81014d689ffa738719af68120fa2dedbeec689
2022-01-31 18:40:03 +01:00
Vadim Yanitskiy 83f423b11e logging: fix printing of '\0' when filename printed last
As was demonstrated in I54bf5e5c036efb1908232fe3d8e8e2989715fbb3,
when the logging is configured to print the filename *after* the
logging message, each logging line contains an artifact - '\0'.

The problem is that the 'len' variable is not updated.  Fix this.

Change-Id: I5c920a0d5c1cf45bcdd327b39e33d63346b4f51c
Fixes: I393907b3c9e0cc1145e102328adad0a83ee13a9f
2022-01-31 16:56:09 +00:00
Neels Hofmeyr 09d6574a45 add osmo_sockaddr_to_str_c(), osmo_sockaddr_to_str_buf2()
To easily log and print a sockaddr using OTC_SELECT, add
osmo_sockaddr_to_str_c().

Implement osmo_sockaddr_to_str_buf2() using osmo_strbuf, so that we can
return the chars_needed which osmo_sockaddr_to_str_c() uses.

From previous osmo_sockaddr_to_str_buf(), call
osmo_sockaddr_to_str_buf2() and return NULL if the buf_len was
insufficient, to mimick previous behavior. This makes it more
consistently returning NULL for insufficient buf_len, as shown in the
tweak that is needed in socket_test.c. Before osmo_sockaddr_to_str_buf()
would return a truncated port number, now it's all or NULL.

I will use osmo_sockaddr_to_str_c() in the new osmo-upf implementation.

Related: SYS#5599
Change-Id: I12771bf8a021e6785217b1faad03c09ec1cfef0e
2022-01-31 15:03:53 +00:00
Vadim Yanitskiy e56f1b67f4 logging: fix coding style issues in _output_buf()
Change-Id: Ia794dbf51045361ee40815f708344c88abe87a96
2022-01-31 15:49:08 +06:00
Vadim Yanitskiy 846db1b3c3 gsm_7bit_encode_n(): use regular malloc() instead of calloc()
In general, it's safe not to use talloc API here because those are
internal allocations, and there are no 'return' statements between
calloc() and free().  However, we don't really need to initialize
the heap memory with 0, so let's use the 'normal' malloc().

Change-Id: I6956cbd83b2999dbcf8e2d210134b0a166c33efb
2022-01-29 01:02:32 +06:00
Philipp Maier 4c44d46308 logging: log to stderr when logging is not initialized
When the logging framework is not initialized we get an error:

"ERROR: osmo_log_info == NULL! You must call log_init() before
using logging in ..."

There are sometimes situations where some code tries to log before
logging was initialied. This is a problem because the actual log
line with the debug info we need is covered up by the error message
from the logging framework.

Lets introduce a fallback logging function that is called when the
the logging framework is not available. This function can just use
fprintf to output to stderr.

Change-Id: I9b1b0988e02322e3e44fd4ceea3e1bc2d4df3c45
2022-01-25 17:49:20 +01:00
Harald Welte fca15ebf99 osmo_libusb: Fix NULL check in osmo_usb_removed_cb()
Thread 1 "simtrace2-tool" received signal SIGSEGV, Segmentation fault.
0x00007ffff73dd2a0 in llist_del (entry=0x0) at ../include/osmocom/core/linuxlist.h:130
130             __llist_del(entry->prev, entry->next);
(gdb) bt

Change-Id: I2b7ab8dddd69453826053663dd5589a941c2e47d
2022-01-25 16:23:45 +01:00
Neels Hofmeyr 13fa00e183 PFCP: add DLPFCP and osmo-upf port numbers
Related: SYS#5599
Change-Id: I0a46b147ec6a76d909df28136cfd2b764b2c75ea
2022-01-21 00:55:51 +01:00
Philipp Maier bdd7df3c83 iuup: do not use illegal characters in state/event names.
The event names contain '.', and there are spaces ' ' in the state
names. This is a problem since states and events can also be monitored
via the CTRL interface. Unfortunately the CTRL interface does not allow
certain reserved characters. So lets rename the states and event names
to make them compatible with the CTRL interface.

Change-Id: Id19973b56f9d7b1e3d0b0d7c7d0be7beba5428fc
Related OS#4149

Change-Id: I5ebc9ab5b1456fee29aa4e254fae862dc053f0aa
2022-01-18 12:04:47 +01:00
Philipp Maier c7c1ff573b gsm23003: fix docstring for osmo_plmn_from_bcd()
The parameters described in the docstrings for osmo_plmn_from_bcd() do not match the actual parameter list.

Change-Id: Ic0999dbe096a98418db7482bd110e20497d8e4a5
2022-01-14 17:14:15 +01:00
Pau Espin 1322755922 iuup: Improve CRC checksum error logging
Change-Id: I14f2ff14af24f20b788d123c0bfb47aeb0333d19
2022-01-10 13:58:45 +00:00
Harald Welte 494282f767 msgb: Fix -Wsign-compare warnings
Change-Id: I4bd14bb712fb3868b55d7e79d13276b707a6cdcb
2022-01-10 10:53:06 +01:00
Harald Welte 0b08d518f2 socket, select: Fix -Wsign-compare warnings
Change-Id: Idf6213e66e9bf609e930c6134292458a7d521871
2022-01-10 10:53:03 +01:00
Harald Welte cd58e1e8e7 bits.c: Fix -Wsign-compare warnings
Change-Id: I6a2e3e9c8743b229633204562712fda1433a78ec
2022-01-09 12:04:22 +01:00
Harald Welte e6fb890b98 log_taget_find() should use enum log_target_type, not int
This has shown up in -Wsign-compare

Change-Id: I2f5ba81aa0328db7db29f49f26de4cea3f522789
2022-01-09 12:04:22 +01:00
Harald Welte 7d6166a0e3 utils: Fix -Wsign-compare warnings
Change-Id: I8b1118ca519b0a419a42eab8b7d4ba9e26a0bab5
2022-01-09 12:04:19 +01:00
Harald Welte c85aaed3fb bitvec: Fix -Wsign-compare warnings
Change-Id: I34f65cda83bcd7050bd0cc0fb9e5cb5d33a09086
2022-01-09 12:04:16 +01:00
Philipp Maier 42dcbf0c1f stats_tcp: fix stats item identifier
The identifier of stats item STATS_TCP_REORD_SEEN is tcp:sndbuf_limited,
it should be tcp:reord_seen.

Change-Id: If3539ceb570ae784cc9b6567c59da7afd11acf82
Related: OS#5701
2022-01-07 13:40:11 +00:00
Pau Espin 604eaba2c3 iuup: Submit RNL-STATUS-Initialization.ind upon rx of Init
This allows init-passive users to get the configured sizes for the RFCIs
and other similar information once engotiated with the peer.

Realted: OS#1937
Change-Id: I63ee780b4aa162ea097410b234e73984000c0965
2022-01-07 13:02:56 +00:00
Pau Espin d3b016fec5 iuup: Fix decoding of 1byte-length subflow size fields
Change-Id: I78ae9e7d46d0725ddec05e004ae22ee5da738162
2022-01-05 23:09:17 +00:00
Harald Welte 2f54889f65 src/conv.c: Align better with Osmocom coding style
Change-Id: Ie37ed571b4ca0d133d3d18812bf664572fd77916
2022-01-05 20:36:34 +00:00
Sylvain Munaut d5974e9155 conv: Fix the traceback for tail biting codes
When picking the end state, looking only at the path metric
is highly suboptimal because in a tail biting code, we _know_ that
whatever treillis path is correct, it must start and end at the same
state. So we only consider path meeting that condition. We know any
path that doesn't isn't the right one. We only fallback to only
path metric if no path met that condition.

Fixes OS#4508

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I87e51d3880c0fe7bf3d6cd08fd46517a424a230c
2022-01-05 20:24:49 +00:00
Vadim Yanitskiy 2f4186a3d2 VTY: implement 'no log gsmtap [HOSTNAME]' command
Change-Id: I9a4efa1e35cbc22cea06a64a15a369522c32d3c4
2022-01-05 09:51:34 +00:00
Pau Espin beaf2a2839 logging: Fix Not enough tailroom msgb_put in _output_buf callers
The function clearly specified in its documentation that the number of
bytes written to the out buffer were being returned. However, the value
returned was "the number of characters (excluding the terminating null
byte) which would have been written to the final string if enough space
had been available.", aka snprintf-style.
The 2 callers of that function were not expecting it, so if a long
enough buffer was passed, the program asserted.

Closes: OS#5383
Change-Id: I8d71bd1a0dad37606acb8302b05c2ae338112e57
2022-01-04 13:36:20 +01:00
Oliver Smith d841bec8d2 select_main: don't poll forever during shutdown
Do not poll without timeout during shutdown if no timers are pending.

Change-Id: I81c64a7ae440304522c2179c212023a566ddced8
2021-12-28 12:14:12 +00:00
Harald Welte 29814a5374 iuup: Fix signed/unsigned loop counter control flow issue
The use of an unsinged integer as for loop counter variable doesn't
work when counting down and comparing with >= 0.  The existing code
would be an infinite loop if it wasn't for the (data dependent) break
condition:

>>>     CID 243259:  Control flow issues  (NO_EFFECT)
>>>     This greater-than-or-equal-to-zero comparison of an unsigned value is always true. "i >= 0U".
572             for (i = 15; i >= 0; i--) {
573                     if (match_mask & (1<<i)) {
574                             iui->mode_version = i;
575                             break;
576                     }

Change-Id: I019d0f0d8f2b167575a2883a13cca692c96961cf
Closes: CID#243259
2021-12-24 11:35:57 +01:00
Harald Welte c809f4e494 tcp_stats: fix compilation on CentOS 7
This is to fix the following compile error on CentOS 7:

[   74s] stats_tcp.c: In function 'fill_stats':
[   74s] stats_tcp.c:138:15: error: 'struct tcp_info' has no member named 'tcpi_notsent_bytes'
[   74s]        tcp_info.tcpi_notsent_bytes);
[   74s]                ^

Closes: OS#5374
Change-Id: Icde6651baeb0828477dbf540a02b16a1a5f91797
2021-12-24 11:34:18 +01:00
Philipp Maier b1ef8f5f69 select: gather statistics for TCP connections
osmocom applications are deployed in a variety of different situations.
Dependung on the medium that interconnects the network components
unexpected behaviour may occur. To debug problems with the
interconnection between network components it might help to monitor the
health of the related TCP connections.

Change-Id: I1416f95aff2adcf13689646b7574845de169fa3d
Related: SYS#5701
2021-12-23 14:52:15 +00:00
Harald Welte 9fe1f9fb0b Introduce CRC and FSM for IuUP (user plane) as used in 3G RTP data
Only support for SMpSDU mode is introduced in this commit.

Not supported explicit list:
- Transparent mode
- ATM/AAL2 based Transport layer
- GTP-U based Transport Layer
- Iu Rate Control procedure
- Time Alignment procedure

APIs are provided to allocate the primitives properly inside the related
msgb. This way primitives can be placed in the headroom, leaving the
data part of the msgb for the IuUP payload, hence allowing re-use of the
msgb and 0 copy of IuUP payload when forwarding data over RNL<->TNL.
Since RNL and TNL primitives relu struct osmo_prim_header, which is not
packed, they cannot be set to packed, and hence proper memory alignment
in the msgb must be done to avoid misaligned accesses (Asan errors about
it otherwise).

Related: SYS#5516
Change-Id: Ibe356fa7b1abaca0091e368db8478e79c09c6cb0
2021-12-22 14:58:31 +01:00