Commit Graph

127 Commits

Author SHA1 Message Date
Andreas Eversberg 35f20b1ff7 osmo_io_uring: Run check of tests/osmo_io with io_uring also
Related: OS#5751
Change-Id: I82db9a15bc483a5447d86352512afaafa2bcfbb6
2024-03-20 12:11:08 +01:00
Daniel Willmann 0266b531c5 Disable uring when building for embedded
Change-Id: Iec2503986c6d3487761ba592daef0fd42478aa7d
Related: OS#6233
2023-11-24 16:13:07 +00:00
Daniel Willmann f91d2aac9d osmo_io: Add io_uring backend
Change-Id: I5152129eb84b31ccc9e02bc2a5c5bdb046d331bc
2023-08-24 17:33:19 +02:00
Andreas Eversberg bb20d4e703 Added generation of include/osmocom/core/socket_compat.h
This file is required to compile header files on machines that do not
have sys/socket.h.

Change-Id: Ia3eafc992221900bbbf1760f669725bf9da92105
2023-06-09 15:06:34 +00:00
Pau Espin 3b450f0233 configure.ac: Fix typo in enable flag description
Change-Id: Ida390c50379a429a4b42434e32954eeb832a11ff
2023-03-14 13:13:40 +01:00
Pau Espin 5ef158fbbb configure.ac: Fix logic enabling osmo_fd fd checks
The logic testing the and setting the define was inverted, which made it
enabled by default.

Take the chance to rename the enable flag to be "ofd" instead of
"bsc-fd" (since anyway the flag was broken).

Change-Id: I81112fa1f6ce1a8e5fe85468241ad385ed8805d3
2023-03-14 13:13:40 +01:00
Daniel Willmann 213fc420e0 Add libosmocore.map
Generated with:
nm src/core/.libs/libosmocore.so --defined-only  |grep " T \| D \| B " | cut -c 20-  >> src/core/libosmocore.map

Change-Id: I13169c00a59fb59513dfc598de5a71d094492422
2023-02-27 17:11:08 +00:00
Vadim Yanitskiy 94e0af0a6d doxygen: also generate documentation for libosmo{sim,usb}
We do have API documentation for all libraries, excepte these two.

Change-Id: I2ec5803bc219b9ceaf0d52d41a03ab78f580e689
2023-02-27 11:14:40 +00:00
Pau Espin 4eb89afa80 configure --enable-libmnl: Add libmnl to libosmocore.pc.in Requires
Change-Id: I8ad8418ada95e79bb6079f34c6b57817c6f6ab11
2023-01-25 17:12:07 +01:00
Harald Welte d55a209d1c create libosmoisdn sub-library
There are some parts of libosmogsm which are not really GSM specific,
but rather ISDN bits that were inherited by GSM.  This includes the
I.460 multiplex as well as the core LAPD protocol.

Let's move those bits to its own libosmoisdn library, before we add
more ISDN specific bits to the wrong place.

Backwards-compatibility is created by making libosmogsm depend on
libosmoisdn, and by providing wrapper include files for source
compatibility.

Change-Id: Ib1a6c762322fd5047be3188b1df22408ef06aa50
2023-01-21 22:41:57 +01:00
Pau Espin 4fc6118bb3 Split include/Makefile.am content into subdirs
When someone is modifying a given library there's no need to be looking
at a common file contains tons of lines from different libraries.
Furthermore, this removes the need of "nobase" autofoo prefix, hence
following the usual directive of having one Makefile per directory.

Change-Id: I785891c2f89114bf8303c799094b637d3d25ac71
2023-01-18 18:29:34 +01:00
Pau Espin d4c3dc8d59 Move src/*.{c,h} to src/core/
This way we have all libosmocore.so in an own subdir instead of having
lots of files in the parent dir, which also contains subdirs to other
libraries.
This also matches the schema under include/osmocom/.

Change-Id: I6c76fafebdd5e961aed88bbecd2c16bc69d580e2
2023-01-18 17:14:06 +01:00
Max 7a79dd3dab osmo-stat-dummy: add rate counters and statsd tester
It's handy for testing rate counters as well as statsd metrics.

Related: OS#5671
Change-Id: Ibd8b17aa3ba9ceb527c6231310f01d736fb542a7
2022-12-20 14:20:05 +03:00
Harald Welte 88bb5ed7fa Add -Werror=implicit-int -Werror=int-conversion -Werror=old-style-definition
... if --enable-werror is used

Change-Id: I8acd1b276f1ff8f015856d70fd582e457915ea11
2022-11-08 16:30:58 +00:00
Vadim Yanitskiy 6755aac51e configure.ac: fix 'AM_CONDITIONAL(ENABLE_GNUTLS, false)' listed twice
Change-Id: I057eb55d381144489d0385493af5a43839b45023
2022-10-20 04:51:40 +00:00
Harald Welte 0239620bd1 update git URLs (git -> https; gitea)
Change-Id: I22bc1dd5c8a33fbccc8cc6d0d8daf7f558f17f44
2022-06-17 23:20:26 +02:00
Sylvain Munaut 903705604a build: Disable libusb and libmnl for embedded builds
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Ie7900098ffda7cebfab81c08b25b0001e6fd98ec
2022-04-29 07:39:43 +00: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
Pau Espin c80a004f0b configure: Support libsctp < 1.0.17 without libsctp.pc
libsctp 1.0.17 is the first to contain a pkgconfig file in upstream.
Current OpenSure Leap 15.3 as well as our OpenEmbedded meta-telephony
layer still ship 1.0.16 which contain no pkgconfig file.

Let's attempt first finding the .pc file, and otherwise manually link
against the lib.

Related: https://bugzilla.opensuse.org/show_bug.cgi?id=1197590
Related: https://build.opensuse.org/request/show/965348
Fixes: 12eed19066
Change-Id: I241634388c2d32adffebd860c88bdd13002a6af0
2022-03-29 11:59:51 +02: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
Eric Wild 63e1b2b024 logging: make LIBOSMOCORE_NO_LOGGING work as expected
The macro introduced in d02090bba5 was not
enough: the actual logging macros are being used, i.e. by the fsm, so
wrap those as well, and provide a flag to disable this at build time.

Change-Id: Ia4c78abe5f198139f96ffa289998855be2477585
2021-12-09 15:25:53 +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
Pau Espin 88e4058fc4 Introduce osmo_gettid() API
This API wraps conventional gettid() linux-specific API, which even in
Linux itself is sometimes not properly supported/announced.

This API also allows future porting to other platforms if needed, and so
far falls back to getpid() if no gettid(9 can be found.

Code ported from osmo-trx.git, see commit 7a07de1efd4eb7cc11c33d3ad25cb2df70aa1ef1.

Related: OS#5027
Change-Id: Id7534beeb22fcd50813dab76dd68818e2ff87ec2
2021-02-17 18:24:17 +01:00
Harald Welte 433005c87c initial support for static userspace probes via systemtap
This adds a --enable-systemtap configure option, which will then
add static tracepoints to the generated libosmocore binary.

At this point, only two tracepoints are supported: log_start
and log_done.  They can be used to trace the amount of time
a libosmocore-using application spends in potentiall blocking calls to
log to stderr or to files.

Related: OS#4311
Change-Id: I7e1ab664241deb524c9582cbd1bec31af46c747e
2021-02-03 13:55:40 +00:00
Oliver Smith f2afb98c83 configure.ac: set -std=gnu11
Avoid using different dialects by accident (and resulting compiler
errors if compiler assumes a different dialect), like in
I72310886bef4db635078b75715c9d98ee45391cc.

Related: https://lists.osmocom.org/pipermail/openbsc/2019-September/013030.html
Related: https://lists.osmocom.org/pipermail/openbsc/2021-January/013360.html
Related: osmo-pcu Ia57ba101627e3cc0babeca82631e207a3e2e0960
Change-Id: Id79b13d3c498acb565f91eba650328fccb5a13ef
2021-01-27 13:42:12 +01:00
Vadim Yanitskiy 2ecb71bcd4 fixup: configure.ac: fix: do not define HAVE_NEON unconditionally
Instead of removing AC_DEFINE(), I should have used AS_IF().

Change-Id: I20e256bd6fdb0256c95ab7073e07b7437af6a12f
Fixes: I761a7afaeda9d232ac26edff47949e911f8f1f0c
2021-01-14 18:57:52 +01:00
Harald Welte e4cd267ab1 Add inter-thread queue
This adds an inter-thread queue "it_q" to libosmocore. With it_q,
one can perform thread-safe enqueing of messages to another thread,
who will receive the related messages triggered via an eventfd
handled in the usual libosmocore select loop abstraction.

Change-Id: Ie7d0c5fec715a2a577fae014b0b8a0e9c38418ef
2021-01-06 00:22:13 +01:00
Harald Welte 53a2fde368 Integrate libmnl (minimal netlink) library with libosmocore select loop
This adds an easy way to listen to netlink events form the Linux kernel
from within libosmocore applications.

The new dependency can be disabled via the "--disable-lbimnl" configure flag.

Change-Id: I4f787ee68f0d6d04f0a5655eb57d55b3b326a42f
2020-12-02 21:04:51 +00:00
Harald Welte b904e428aa select: Migrate over to poll()
select is an ancient interface with weird restrictions, such as
the fact that it cannot be used for file descriptor values > 1024.

This may have been sufficient 40 years ago, but certainly is not in
2020.  I wanted to migrate to epoll(), but unfortunately it doesn't
work well with the fact that existing programs simply set osmo_fd.flags
without making any API calls at the time they change those flags.

So let's do the migration to poll() as a first step, and then consider
epoll() as a second step further down the road, after introducing new
APIs and porting applications over.

The poll() code introduced in this patch is not extremely efficient,
as it needs to do extensive linked list iterations after poll() returns
in order to find the osmo_fd from the fd.  Optimization is possible,
but let's postpone that to a follow-up patch.

At compile time, a new --enable-force-io-select argument can be given
to configure, forcing the use of the old select() backend instead of the
new poll() based backend.

Change-Id: I9e80da68a144b36926066610d0d3df06abe09bca
2020-10-23 15:09:05 +00:00
Vadim Yanitskiy e7bf4354b9 logging: introduce 'systemd-journal' target
This change implements 'systemd-journal' logging target, that is
similar to the existing 'syslog' target.  The key difference is
that 'systemd-journal' allows us to offload rendering of the meta
information, such as location (file name, line number), subsystem,
and logging level, to systemd.  Moreover, we can attach arbitrary,
user-specific fields [1] to the logging messages, so they can be
used for advanced log filtering (e.g. by IMSI/TMSI/TLLI):

  $ journalctl OSMO_SUBSYS=DMSC -f

Since we don't want to make libsystemd a required dependency, this
feature is optional, and needs to be enabled at build-time:

  $ ./configure --enable-systemd-logging

The new logging target can be configured in the same way as any
other one - via the VTY interface, or using the configuration file:

  log systemd-journal [raw]
    logging level set-all notice
    logging filter all 1

Two logging handlers are available: generic and raw.  The first one
behaves similarly to both 'syslog' and 'stderr', i.e. all the meta
information is rendered by libosmocore itself, and then passed to
systemd together with the logging message.  The later is more like
the 'gsmtap' target, so all available meta information is handed
over to systemd in form of fields [1]:

  - CODE_FILE / CODE_LINE - location info,
  - PRIORITY - syslog-compatible logging level,
  - OSMO_SUBSYS - Osmocom-specific sub-system (e.g. DMSC),
  - OSMO_SUBSYS_HEX - same as OSMO_SUBSYS, but encoded in hex,
  - MESSAGE - the logging message itself,

and then can be rendered in any supported format (e.g. JSON).

More details about the API can be found in [2].

[1] https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html
[2] https://www.freedesktop.org/software/systemd/man/sd-journal.html

Change-Id: I609f5cf438e6ad9038d8fc95f00add6aac29fb23
2020-10-19 15:02:00 +00:00
Pau Espin 16b076cd15 tests: Split SCTP tests to its own file and run them conditionally
Some systmes (like the ones available in OBS) don't support creating
SCTP sockets, so we need to skip those tests there.

Change-Id: I1d16280674625877ec22cc60cbc5deb67868a656
2020-08-25 14:22:03 +02:00
Vadim Yanitskiy 7dbae9ea40 configure.ac: print ARM NEON instructions support status
Change-Id: I0e8910d6cf337a95d6b4295f5c425d2d4cfa2b41
2020-08-07 04:01:12 +07:00
Vadim Yanitskiy cab3835805 configure.ac: fix: do not define HAVE_NEON unconditionally
Change-Id: I761a7afaeda9d232ac26edff47949e911f8f1f0c
2020-08-07 03:55:32 +07:00
Vadim Yanitskiy 325d9b32ee configure.ac: clarify description of --enable-neon
Change-Id: Id261dcf396f19a385203ae5f339cc5570efa4aab
2020-08-07 03:53:40 +07:00
Eric Wild 3afc1d1777 libomsocoding: NEON viterbi acceleration
configure flag required to enable this: --enable-neon

Although autodetection according to __ARM_NEON would work because this
is only defined if the fpu is neon neon-fp16 neon-vfpv3 neon-vfpv4
neon-fp-armv8 crypto-neon-fp-armv8 doing that would lead to a unknown
performance impact, so it needs to be enabled manually.

Speedup is about ~1.3-1.5 on a unspecified single core Cortex A9. This
requires handling a special case for RACH with len 14 which is far too
short for neon and would actually incur a performance penalty of 25%.

Related: OS#4585
Change-Id: I58ff2cb4ce3514f43390ff0a2121f81e6a4983b5
2020-08-06 16:47:40 +00:00
Oliver Smith 6370f5dd6f contrib: integrate RPM spec
Remove OpenSUSE bug report link, set version to @VERSION@, make it build with
CentOS 8 etc.

Related: OS#4550
Change-Id: I59255889740195ec811a947a7130ae0918ea4b4d
2020-05-20 10:29:05 +00:00
Pau Espin d05def0885 Drop old BSC references in fd check configure option
Change-Id: I053c2bfe461aa82085e7dac1cdcc95dd77219949
2020-05-11 17:24:16 +00:00
Pau Espin 47eb4e18d0 configure.ac: Fix HAVE_CLOCK_GETTIME undef when func in -lrt
AC_SEARCH_LIBS was finding the function correctly, but later on
AC_CHECK_FUNCS was not including the found LIBRARY_RT so the function
was not found, and hence HAVE_CLOCK_GETTIME ended up undefined (which in
turns disables support for osmo_clock_gettime() API).
This happened in systems like the soekris where the clock_gettime sybmol
is available in external lib -lrt.

Let's avoid double-checking for the function twice, and simply define
HAVE_CLOCK_GETTIME when AC_SEARCH_LIBS succeeds (the success action is
guaranteed to be called even if there's no extra lib required).

Change-Id: Iced1e0542cee6beb9f08f5299aad49fab142cfb4
2020-05-01 16:51:26 +02:00
Harald Welte a70ac85f5b select.c: Introduce support for signalfd
The signalfd(2) mechanism of Linux allows signals to be delivered
and processed via normal file descriptor I/O.  This avoids any of the
usual problems about re-entrancy of signal processing, as signals can
be processed from the osmocom select() loop abstraction just like any
other event.

Change-Id: If8d89dd1f6989e1cd9b9367fad954d65f91ada30
2020-04-18 21:16:12 +02:00
Eric Wild 099c8340ed configure.ac: fix libtool issue with clang and sanitizer
As pointed out at https://github.com/libexpat/libexpat/issues/312
libtool does not play nice with clang sanitizer builds at all.
For those builds LD shoud be set to clang too (and LDFLAGS needs the
sanitizer flags as well), because the clang compiler driver knows how
linking to the sanitizer libs works, but then at a later stage libtool
fails to actually produce the shared libraries and the build fails. This
is fixed by this patch.

Addtionally LD_LIBRARY_PATH has no effect on conftest runs during
configure time, so the rpath needs to be set to the asan library path to
ensure the configure run does not fail due to a missing asan library,
i.e.:

SANS='-fsanitize=memory -fsanitize-recover=all -shared-libsan'
export CC=clang-10
ASANPATH=$(dirname `$CC -print-file-name=libclang_rt.asan-x86_64.so`)
export LDFLAGS="-Wl,-rpath,$ASANPATH $SANS $LDFLAGS"

Change-Id: I8ebd9c6d4efda41c7c8196f963d1f04d65160754
2020-04-11 18:31:59 +00:00
Harald Welte 3c44a646bd libosmosim: Build irrespective of PC/SC support
libosmosim contains a variety of definitions and utility fuinctions
useful when working with SIM card [protocol].  They can not only
be used with PC/SC readers but also in other contexts.

Change-Id: I741940d3dc2a5653c760e9d1597d7f08afb3b631
2020-03-16 11:28:21 +01:00
Harald Welte c6a8697800 Introduce helper functions for safe fork+exec of processes
In some situations, we want to execute an external shell command
in a non-blocking way.  Similar to 'system', but without waiting for
the child to complete.  We also want to close all file descriptors
ahead of the exec() and filter + modify the environment.

Change-Id: Ib24ac8a083db32e55402ce496a5eabd8749cc888
Related: OS#4332
2019-12-17 13:49:28 +01:00
Harald Welte da432cdc35 libosmocore libusb integration
Osmocom applications typically use libosmocore select.[ch] event loop
code as their main event dispatch mechanism.  When they want to deal
with libusb in a non-blocking/asynchronous way, they need to integrate
libusb into that select().

The new libosmousb is doing exactly that: Providing a shared utility
library for Osmocom programs that wish to use libusb.  This is useful
for example in simtrace2 host utilitie as well as osmo-e1d.

Change-Id: I656a1a38cbb5b1f3a9145d2869d3b4d0adefcae3
Closes: OS#4299
2019-12-16 00:17:27 +01:00
Vasil Velichkov 499510bd52 Add code coverage support
The coverage report shows what code is covered by tests and what is not
and the ratio could be tracked over time. These reports will allow us
to identify code that is not being tested and improve the test suites.

To enable the reports configure with --enable-code-coverage and execute
"make check-code-coverage". The HTML report will be generated in a
subdirectory with name libosmocore-$(PACKAGE_VERSION)-coverage/index.html

The report is generated using gcov, lcov and lcov_cobertura tools and
the OSMO_AC_CODE_COVERAGE macro. The osmo_ax_code_coverage.m4 is a copy of
ax_code_coverage.m4 taken from autoconf-archive v2018.03.13. It was
copied to avoid the additional external dependency and renamed to avoid
overwriting it in case autoconf-archive is already installed as we are
going to install it in $(datadir)/aclocal in order to be reused in other
osmocom's projects.

Closes: OS#1987
Change-Id: I6f4ffb91bd7f3dd070aa09dd16d5ad1faf130a4c
2019-11-30 02:17:23 +00:00
Pau Espin ea2afb21d6 configure: Introduce --disable-libsctp and error by default if libsctp not found
This way libosmocore build fails during configuring phase if expected
default behavior (building with libsctp support enabled and providing
osmo_sock_init2_multiaddr() API) fails. User is still provided with
--disable-libsctp option in case he doesn't need those features or his
environment doesn't provide required libsctp APIs.

Change-Id: I710c9cb1c6da0e5fc94b792df8bf60194a72208f
2019-10-24 15:56:49 +02:00
Pau Espin 3f464fc007 socket: Introduce API osmo_sock_init2_multiaddr()
This API will be used by libosmo-netif's osmo_stream for SCTP sockets,
which in turn will be used by libosmo-sccp to support multi-homed
connections.

Related: OS#3608
Change-Id: Ic8681d9e093216c99c6bca4be81c31ef83688ed1
2019-10-18 09:21:48 +00:00
Pau Espin d12f698dbb logging: Introduce mutex API to manage log_target in multi-thread envs
log_enable_multithread() enables use of locks inside the
implementation. Lock use is disabled by default, this way only
multi-thread processes need to enable it and suffer related
complexity/performance penalties.

Locks are required around osmo_log_target_list and items inside it,
since targets can be used, modified and deleted by different threads
concurrently (for instance, user writing "logging disable" in VTY while
another thread is willing to write into that target).

Multithread apps and libraries aiming at being used in multithread apps
should update their code to use the locks introduced here when
containing code iterating over osmo_log_target_list explictly or
implicitly by obtaining a log_target (eg. osmo_log_vty2tgt()).

Related: OS#4088
Change-Id: Id7711893b34263baacac6caf4d489467053131bb
2019-10-09 14:19:52 +02:00
Pau Espin afce89dac1 configure: Allow disabling workaround for TLS bug in old ARM gcc versions
Some toolchains (such as sysmobts 201705 one) containing the TLS bug on
old ARM gcc versions (<7.3.0) also crash if the initial workaround found
is aplied (CFLAGS="-mtls-dialect=gnu2"). In that scenario, let's provide
a way to disable the workaround (to avoid "ld" crashing) and warn the
user about requirement to build with -O0 to avoid runtime crashes.

Related: OS#4062
Related: SYS#4628
Change-Id: I04ff8c702eabcf4f6e7b59e11aece2744267cefe
2019-08-06 12:50:26 +02:00
Pau Espin e188b8cd98 configure: Autodetect TLS bug on ARM with old gcc and apply workaround
Check if compiler being used contains the bug. GCC 7.3.0 is the oldest
version containing the fix, and version 6.3.0 is known to contain the
bug. Bug is only known to appear so far only on ARM32. If the bug is
present, gcc will generate a wrong binary which wil lend up segfaulting
when accessing TLS (__thread) variables under certain conditions.

Related: OS#4062
Related: SYS#4628
Change-Id: I8acc2cf41b73da0c3290f1cefd79f2bc68b0e77d
2019-08-06 08:10:48 +00:00