An AF_PACKET socket will immediately receive packets of _all_ interfaces
until it is bound to one specific interface. This introduces a race
condition between the socket() and the bind() syscall.
Let's use the ifindex passed for each packet in recvmsg() to drop
any packets received for other interfaces.
Change-Id: I8f708ba4f9b7f76525acce17b24a8f7b125a1c1c
Related: SYS#5245
osmo-pcu unit tests fail ue to this new log line. Let's rather simply
leave a comment there, since anyway known apps will be migrating soon
the new APIs.
Fixes: fde19ed579
Change-Id: Ib9bf528db08f7aaa4adaf7b6a320679a4f11a53d
The FSM doesn't actually implement the flow control logic,
it only decodes / dispatches and encodes messages.
Related: OS#4891
Change-Id: Ie59be6761177c43456898be9148727f15861a622
The 16 ANSI colors we started to use for OpenBSC in 2008 were
sufficient for those few sub-systems that occurred in the BSC/NITB.
Over time, most sub-systems did not get colors anymore. Let's
change that and assign more or less random colors from the 8bit
color palette.
Change-Id: Ia8c0f91a61fbca0441faf66b3f368f45f886187c
Similar to ns2 superseding ns, we now also intoduce a next generation
of BSSGP related code to libosmogb. However, this is not aiming to
be a full implementation yet, but simply those parts that we currently
need from the revamped osmo-gbproxy.
The gprs_bssgp2.[ch] differs in two ways from the old code:
* it separates message encoding from message transmission
* it supports more recent specs / IEs
bssgp_bvc_fsm.c is a genric implementation of the BSSGP BVC
RESET/BLOCK/UNBLOCK logic with support for both PTP and signaling,
both on the SGSN side and the BSS side.
Change-Id: Icbe8e4f03b68fd73b8eae95f6f6cccd4fa9af95a
Historically, BSSGP uses a non-constant, user-configurable integer
varieable for the logging sub-system. Let's replace this with a
statically-allocated library logging constant.
This is required if we want to use the subsystem number in e.g.
static initialized for osmo_fsm.log_subsys.
Change-Id: I506190aae9217c0956e4b5764d1a0c0772268e93
The wrong argument was used to multiply by 4. However it was still
compliant because the SNS code would always supports 16 NSVCs.
Use the correct multiplier.
Fixes: ttnc3 pcu sns test cases
Fixes: 42ad549152 ("gprs_ns2_sns: dynamic calculate the maximum NS-VCs")
Change-Id: I58d706c6fffb4237b90b37cade4dc00c6aba6ac9
Those routines are very useful when puzzling together BSSGP messages
with 16-bit and 32bit sized IEs.
Change-Id: I033f9a708c9d7ffad91336178231dc66233e1693
This extends our existing TLV parser with the ability to
* validate that mandatory IEs of a given message are present
* validate that all present IEs are of required minimum length
Introducing this generic layer will help us to reduce open-coded
imperative verification across virtually all the protocols we
implement, as well as add validation to those protocols where we
don't properly perform related input validation yet.
Change-Id: If1e1d9adfa141ca86001dbd62a6a339f9bf9a912
if we transition to UNBLOCKED as a result of a locally-generated
unblock action, then of course we will receive an inbound UNBLOCK-ACK.
Let's avoid error log messages and confusign the peer with NS-STATUS
in this case:
DLNS DEBUG GPRS-NS2-VC(FR-hdlcnet3-DLCI18-NSEI2001-NSVCI3)[0x612000001720]{UNBLOCKED}: Received Event UNBLOCK_ACK (gprs_ns2_vc_fsm.c:692)
DLNS ERROR GPRS-NS2-VC(FR-hdlcnet3-DLCI18-NSEI2001-NSVCI3)[0x612000001720]{UNBLOCKED}: Event UNBLOCK_ACK not permitted (gprs_ns2_vc_fsm.c:692)
Change-Id: Icc4d960ddad82e3ebbf571d8ff9f24854b52a946
The event GPRS_SNS_EV_NO_NSVC was never dispatched because the
S() was missing to convert it into a bitmask.
Change-Id: I4af01293ff0ba8629e1426b1ba92f72f0520c7f0
The previous hard-coded value could be not enough if the user configures
too many local binds. Allow at least 8 NS-VCs. In case the user
configures too many binds (> 2) increase the maximum NS-VCs to allow
the SGSN to have 4 redundant connections.
Change-Id: Iae859dc504716fd6f705e72db5fc293b4b3298e7
The SNS FSM can go into the SIZE state when all NS-VC are failing.
This is the case if the network connection to the SGSN got interrupted.
Change-Id: I7e7da9451458505c1c2d73836dd916aee7704fda
When importing the hashtable code in I8ef73a62fe9846ce45058eb21cf999dd3eed5741
I didn't import actual implementations of the fls() and fls64()
implementations, as at least gcc-10 was smart enough to detect
we only use it on constant types and hence the computation can happen
at build time via const_ilog2()
However, in our jenkins build verification' this doesn't appear to
happen, as we get below errors:
/build/deps/install/stow/libosmocore/include/osmocom/core/log2.h: In function ‘__ilog2_u32’:
/build/deps/install/stow/libosmocore/include/osmocom/core/log2.h:20:9: error: implicit declaration of function ‘fls’ [-Werror=implicit-function-declaration]
return fls(n) - 1;
^~~
/build/deps/install/stow/libosmocore/include/osmocom/core/log2.h: In function ‘__ilog2_u64’:
/build/deps/install/stow/libosmocore/include/osmocom/core/log2.h:28:9: error: implicit declaration of function ‘fls64’ [-Werror=implicit-function-declaration]
return fls64(n) - 1;
^~~~~
Let's provide some generic implementations for this case. If needed
one could also introduce architecture-specific assembly implementations
like in the Linux kernel, but so far we managed to keep libosmocore free
of any assembly tweaks.
Change-Id: Ifa4898eb66c8d949618edd47961b7a0330ed35b5
In I7da8b25c9a89a7e3ae6c1680ba838e136d7d5293 I seem to have failed
to realize that 3GPP TS 48.018 v15.0.0.0 Table 11.3.26 continues
on yet another page. Let's add those missing PDU types definitions.
Change-Id: I9173c35240ff78048b2b76a1155d90467ef16b2d
'new' is a reserved keyword in C++, so including this header from
a C++ project (like osmo-pcu) breaks compilation. Let's rename
it in the same way as it's already done in this file: add '_'.
Change-Id: I7f7d9143edca75ce932601386a8766b0a62c0e24
Fixes: I8ef73a62fe9846ce45058eb21cf999dd3eed5741
For more than a decade we've used the linuxlist.h for double-linked
lists. Let's also add the hlist (double-linked lists with single
pointer sized head, and the hashtable that builds on top of it.
This reflects the versions included in Linux 5.8 with some modifications
to make them build in userspace (remove RCU versions, adjust for
userspace include files and types, convert to doxygen).
Change-Id: I8ef73a62fe9846ce45058eb21cf999dd3eed5741
In I7da8b25c9a89a7e3ae6c1680ba838e136d7d5293 we introduced the enum
values for all the new BSSGP message types up to Release 15. Let's
also add value_strings for them here.
Change-Id: Ia108ba0d5f1f2c9d46f0c0bd11cd93104b9d62ea
With TLVP_PRESENT we only check if a given TLV/IE is present,
but don't verify that it's length matches our expectation. This can
lead to out-of-bounds reads, so let's always use TLVP_PRES_LEN.
Change-Id: I4c438bc82ea6a48243db568f96a234adf784dc0b
With TLVP_PRESENT we only check if a given TLV/IE is present,
but don't verify that it's length matches our expectation. This can
lead to out-of-bounds reads, so let's always use TLVP_PRES_LEN.
Change-Id: I56e8b31ce51602d2681e3db501c48f84bfe7e438
It's not needed because net/if.h already include
the required parts. Furthermore the linux/if.h generates
a compiler error in combination with net/if.h on older systems
(e.g. debian jessie)
Change-Id: I53650e9c55bb9dd98ba60269025e72673e9f82c1
mnl_socket_open2 is not yet available on e.g. Debian 8. Furthermore,
osmo_fd_register() will set the CLOEXEC flag on every file descriptor
anyway, so there is no benefit from using mnl_socket_open2() at all.
Change-Id: I0b37ffa148ff0c0a22281b490820353f5fef00eb
In Change-Id I779556991bfc88b7751b2be17bb81c329cfb9e01 we introduced
the use of libmnl via osmo_mnl to libosmogb. Howver, we didn't add
LIBMNL_CFLAGS in Makefile.am, which now (rightfully) fails on some
distributions like the SuSE family of distributions.
Let's fix this.
Change-Id: Ib8740e8fd677026efb9dad5d5fe6b95147fb3c23
NSVC filtering was only implemented on sending messages, this also adds
log_set_context() calls to ns2_recv_vc()
Filtering by NSE is implemented similar to NSVC.
Change-Id: I63c0e85f82f5d08c5a6f535da94b8648498439d2
Related: SYS#5232
In I157467d6a74d6109bc23521c978c5aac6d29fe50 we introduced a split
between 'show ns entities' and 'show ns binds'. However, there is
at least one test case in osmo-sgsn.git which depends on 'show ns'
working. So let's re-add it as a backwards compatible, hidden command.
Change-Id: I7571c6d82f7a712803d09d165abb6c7cb5ae2e5c
We use the newly-introduced libmnl integration of libosmocore in order
to receive netlink events from the kernel on link state changes.
If one of "our" interfaces changed link state, we report this in the log
and also store it within the "bind".
Change-Id: I779556991bfc88b7751b2be17bb81c329cfb9e01
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
It's not needed because net/if.h already include
the required parts. Furthermore the linux/if.h generates
a compiler error in combination with net/if.h on older systems
(e.g. debian jessie)
Change-Id: Iccf931207d8bea19969fbfc4225f622a1a709972