Commit Graph

3831 Commits

Author SHA1 Message Date
Harald Welte 1262c4f18e ns2: Properly indent VTY output
If multiple objects are printed in the VTY, only the first line of each
object should be on the first character of the line, all others should
be indented.  With  this patch the "snow ns entities" output becomes
much more readable:

OsmoGbProxy> show ns entities
NSEI 00102: UDP, DEAD
 FSM Instance Name: 'GPRS-NS2-SNS-BSS(NSE00102-SNS)[0x6120000018a0]', ID: 'NSE00102-SNS'
  Log-Level: 'DEBUG', State: 'SIZE'
  Timer: 1
 Maximum number of remote  NS-VCs: 8, IPv4 Endpoints: 4, IPv6 Endpoints: 0
 NSVCI none: UNCONFIGURED DYNAMIC data_weight=1 sig_weight=1 udp)[127.0.0.1]:23000<>[127.0.0.11]:8888
NSEI 00101: UDP, DEAD
 FSM Instance Name: 'GPRS-NS2-SNS-BSS(NSE00101-SNS)[0x6120000015a0]', ID: 'NSE00101-SNS'
  Log-Level: 'DEBUG', State: 'SIZE'
  Timer: 1
 Maximum number of remote  NS-VCs: 8, IPv4 Endpoints: 4, IPv6 Endpoints: 0
 NSVCI none: UNCONFIGURED DYNAMIC data_weight=1 sig_weight=1 udp)[127.0.0.1]:23000<>[127.0.0.10]:7777

Change-Id: Id1b4c80a6caef410076a68b4301adaa01ba7e57a
2021-01-20 14:59:03 +00:00
Harald Welte cec4bbed73 vty/fsm_vty: Add vty_out_fsm2() + vty_out_fsm_inst2() with prefix
Callers other than "show fsm" / "show fsm-instances" may want to
indent the output.

Change-Id: I10e01ef91116369868cdb878a99634c8681728af
2021-01-20 14:59:03 +00:00
Alexander Couzens 273f063f94 gprs_ns2_vc_fsm: in RESET accept RESET as ACK
When both side sends RESET at the same time 48.016

Change-Id: I49d2a4f257f45b7bc4f0a7a6c5b8381071893686
2021-01-20 13:11:26 +01:00
Alexander Couzens ea01bf2b29 gprs_ns2_vc_fsm: ensure all state is resetted via force_unconf
Change-Id: I240225ce82fa27dfcb5b4b8e2981bb4d8cc4cd70
2021-01-20 13:04:33 +01:00
Alexander Couzens f577543887 gprs_ns2_vc_fsm: rename all event to match RX_ or REQ_
Similiar to the BSSGP layer prefix events with RX if it's an received PDU
or REQ if it's a request from the code.

Change-Id: I341fa28fb671d439c050d985c88ece1521430a99
2021-01-19 20:19:08 +01:00
Alexander Couzens 856b94cd7b gprs_ns2: correct handle BLOCK message on initator
A BLOCK message can be received when waiting for a UNBLOCK message
in state BLOCK

Related: SYS#5208
Change-Id: Ie7b34b3ef04aa28304143191222324e1a3786cb2
2021-01-19 20:18:49 +01:00
Alexander Couzens 47afc424c3 gprs_ns2: implement BLOCK/UNBLOCK of a NSVC by vty
The vty should be able to block or unblock a specific NSVC.
Further more this case is special for the UNITDATA as those
can be still received until the other side response to the BLOCK PDU.

Related: OS#4939
Change-Id: Ic0ce3c5fabc8644cc1ee71a8f6dd783fadf7b84d
2021-01-19 19:42:03 +01:00
Alexander Couzens fd96dc5343 osmo-ns-dummy: don't leak primitive messages
The message in the primitive must be freed by the user

Change-Id: I2a7b19f019485c7b1f15baf20b62edc19b663415
2021-01-19 19:33:41 +01:00
Alexander Couzens ea37724b3c gprs_ns2: allow to use free_vc() with NULL
Usually talloc_free() and other free functions in osmocom allows
to be called with NULL which is then ignored.

Change-Id: If7b0c6916a29d4611d0a40c388414076eb83e6b5
2021-01-19 19:33:41 +01:00
Alexander Couzens 55bc86931e gprs_ns2: add assert on most bind calls
Add a OSMO_ASSERT to all bind calls which doesn't
check if the bind is from the expected type.
The only exception is rx and tx functions (hot path).

Change-Id: Ia4f8932263c60618c7f0dfc32d50ba5a8d57602b
2021-01-19 19:33:41 +01:00
Philipp Maier 7741bc320c gprs_bssgp: add utilities to send and parse BSSGP rim PDUs
At the moment libosmogb offers no convinient way to send RIM PDUs. Also
parsing an incoming RIM messages into destination, source routing
info and RIM container is not available.

Change-Id: I18134fd9938040d2facb6beee3732628b167ce8c
Related: SYS#5103
2021-01-19 18:04:13 +01:00
Alexander Couzens aca31b8b2d test: gprs_ns2: free the nsi after each test
Change-Id: I700da48d7afe6b1a81484a0725faf0c56073446d
2021-01-19 15:06:35 +00:00
Alexander Couzens af5bfebcf3 test: gprs_ns2: replace free_bind() with clear_pdus()
free_bind() should free up all driver specific state but NOT
the bind itself. As the only thing left is clearing the pdus
rename the function to it.

Change-Id: Iac506734c93aca8be045ac13788d07d1bdc78eb3
2021-01-19 15:06:35 +00:00
Philipp Maier 7450f77f57 bssgp_rim: move bssgp_parse_rim_ri and bssgp_create_rim_ri to gprs_bssgp_rim
The function bssgp_parse_rim_ri() and bssgp_create_rim_ri() are located
in gprs_bssgp.c, since there is now a gprs_bssgp_rim.c module it makes
more sense to put them there. Also adjust the code a bit so that its
more intuitive to read.

Change-Id: Icd667f41d5735de56cd9fb257670337c679dd258
Related: SYS#5103
2021-01-18 21:11:44 +01:00
Philipp Maier 9828d28fc3 bssgp_rim: add encoder/decoder for NACC related RIM containers
BSSGP RIM uses a number of nested containers to signal RIM application
specific payload information in a generic way. Lets add the container
structurs required for NACC.

Depends: libosmocore If48f412c32e8e5a3e604a78d12b74787a4786374
Change-Id: Ibbc7fd67658e3040c12abb5706fe9d1f31894352
Related: SYS#5103
2021-01-18 21:11:44 +01:00
Harald Welte 3221f878ee ns2: delay NS_AFF_CAUSE_RECOVERY until NS-VC for data + sig are unblocked
Right now we end up in situations where only a NS-VC for data (BVCI != 0)
becomes unblocked, but the BSSGP and/or user application code is
notified that the NSE has recovered.

In the case of osmo-gbproxy, this will trigger a BVC-RESET on the
BVCI=0, but that obviously only works if the sig_weight > 0...

Closes: OS#4956
Change-Id: I933ee3969c052394d61ec6cf8c7c21d17957d9ab
2021-01-18 16:11:33 +01:00
Harald Welte 603f404e41 gprs_ns2: Give NS-VC FSMs a proper name/identifier
Log output without a proper identifier is mostly useless.

Change-Id: Id9d5b0684584d03685900c6298fe70246793de14
Closes: OS#4876
2021-01-18 14:07:48 +00:00
Harald Welte 509047ba5d gprs_ns2_fr: reduce duplication between gprs_ns2_fr_connect / connect2
gprs_sn2_fr_connect2() is the same as gprs_ns2_fr_connect() with
the lookup-and-create-on-demand of the NSE first.

Rather than copy+paste, they should simply invoke each other.

Change-Id: If835bf138f213e7f58205018e7efe3ecb772c624
2021-01-18 14:07:48 +00:00
Alexander Couzens e19b7966e2 test: gprs_ns2: don't leak the talloc context
Makes the address sanitizer happy

Change-Id: Ibf926d8db88cdb403d29de5e666dfb71eefc7b72
2021-01-18 10:47:47 +01:00
Alexander Couzens 5443ff8af3 gprs_ns2_vc_fsm: fix spaces and remove wrong comment
Change-Id: I52799d8ce8244fae7512a6e14a3cf2408a218c2d
2021-01-18 10:47:47 +01:00
Alexander Couzens d1cd650dd8 gprs_ns2: flag then NSE as dead in nse_free()
The transfer cap call in ns2_prim_status_ind() asserts if
NSE is in an invalid state (nse is either alive or has NSVCS).

Change-Id: I535b3e5dd7240d19dd685652173775b250f5cc2d
2021-01-18 10:47:47 +01:00
Alexander Couzens 7a7b20b770 gprs_ns2_sns: clear local and remote entries when SNS failed
The local and remote entries should be cleared on SNS Size.
Further it can be cleared when SNS failed (e.g. all NSVC become dead)
so VTY doesn't show old entries before entering SNS Size.

Related: OS#4949
Change-Id: Ie4db81acdd5f8ddf1a1f5dc7645d1144545d9c73
2021-01-18 10:47:33 +01:00
Alexander Couzens a14b9d3089 gprs_ns2: when calling nsvc_force_unconf for a dynamic NSE drop the NSE.
The vty command is used for test cases to reset NSE state.
So dynamic NSE shouldn't present.

Related: SYS#5208
Change-Id: I0a4f35c974c8c3b79c48f2f56170722c95254332
2021-01-18 10:47:26 +01:00
Alexander Couzens c4b746284f gprs_ns2_vc: answer UNBLOCK on unblocked nsvc
48.016 7.2: says an UNBLOCK pdu should be answered with UNBLOCK_ACK on
already unblocked NSVC

Related: SYS#5208
Change-Id: Ic92e99b2607d1e54ecb4668667065502a55a2ce0
2021-01-17 16:11:36 +01:00
Alexander Couzens 03f88d910e osmo-ns-dummy: allow to create dynamic NSEs
Without setting the flag the osmo-ns-dummy won't create
any dynamic NSEs.
This flag will be removed in a future release but for now
it will be included.

Related: SYS#5208
Change-Id: I196cc454b5d7bc53848f73596a2f92730b78922b
2021-01-17 16:11:36 +01:00
Alexander Couzens 05ac4e52b9 gprs_ns2: check if persistent nsei or nsvc exists when creating dynamic NSE
When receiving a NS Reset over an unknown NSVC the NS code would create
a dynamic NSE. If the NSEI or NSVCI is already configured to a
persistant NSE/NSVC the packet should be ignored.

Related: SYS#5208
Change-Id: I855911e7d364f2e5b08ea05857747aa63fcf1cd3
2021-01-17 16:11:36 +01:00
Daniel Willmann 89a00f352d ns2: Fix memory leak in IP-SNS
Don't allocate msg twice - it's not nice.

Change-Id: I3fa0076eb480a7bcadb74cc86760dc29b77ac600
Related: OS#4874
2021-01-17 14:20:28 +01:00
Daniel Willmann cf8371ad4d Refactor ns2_nsvc_create_ip*
Move code common in ipv4/6 into a separate function and call that
function.

Change-Id: I076d53bee2e67e1cb3ad6ee5cd05c63ebe3359fb
Related: OS#4948
2021-01-17 08:32:51 +01:00
Daniel Willmann bb8990582f ns2: Add sanity check
Prevent memory corruption or segfaults by asserting that NSE and bind
link layer match. A mismatch should never happen and might cause the
bind to access invalid memory when sending because nsvc->priv doesn't
match what it expects.

Change-Id: I7ca4cd1c5dac8b5e44ffc4825b9373b2d04911ab
Related: OS#4948
2021-01-16 19:47:32 +01:00
Daniel Willmann 967e2c1868 NS2: Fix bind selection of SNS NSVCs
The SNS code ignored the link type of the bind and just bound to every
bind it could find. This resulted in a segfault when an SNS NSVC tries
to send its UDP messages though frame relay.

Fixes: OS#4948
Change-Id: Ibb832a39876362d094cce635192f7b4f84dc2b10
2021-01-14 18:09:44 +00: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
Pau Espin dec7b8c238 ctrl: ports.h: Add OSMO_CTRL_PORT_BSC_NEIGH
Hence 4248 becomes the well-known port for osmo-bsc's Neighbor
Resolution Service.

Related: SYS#4909
Change-Id: Ic77a8cff022c2f939a684ebd1f9f62a82e0de510
2021-01-13 14:48:53 +01:00
Harald Welte efdd641c29 tlv_parser: Fix various out-of-bounds accesses
The libosmocore TLV parser had a number of insufficient bounds checks
leading to reads beyond the end of the respective input buffer.

This patch
* adds proper out-of-bounds checks to all TLV types
* simplifies some of the existing checks
* introduces test cases to test all the corner cases
  where either TAG, or length, or value are not fully contained
  in the input buffer.

Thanks to Ilja Van Sprundel for reporting these problems.

Change-Id: I98b02c914c9e3ecf56050af846292aa6979d7508
2021-01-12 21:11:20 +01:00
Pau Espin ca33a71ca8 Intoduce Packet Switch CGI
This structure is needed in order to identify a given cell within the
BSS during RIM transactions.
The naming was made up by myself since I couldn't find any naming
reference for this kind of data (RAI + CI).
Since LAI + CI = CGI, then RAI + CI = CGI-PS

osmo_rai_name2 family of functions get a "2" suffix due to already
existing functions handling struct struct gprs_ra_id in gsm48.h

Change-Id: If48f412c32e8e5a3e604a78d12b74787a4786374
2021-01-11 14:22:21 +00:00
Vadim Yanitskiy e2ad6ebb7a gprs_bssgp: abuse gsm48_encode_ra() to encode TAC
Both LAC and TAC take 2 octets and follow MCC/MNC fields on the wire.
We abuse gsm48_encode_ra() for encoding of MCC/MNC, but it can also
be abused to encode TAC in bssgp_create_rim_ri().  There is no need
to encode '0000'O and then override it with osmo_store16be().

Change-Id: I986552aa52cf38b1c5290d2e5cd3ff2d1c36a4e5
2021-01-11 14:21:21 +00:00
Harald Welte 5d797c4264 Revert "pkgconfig: link to mnl if available"
This reverts commit 2253224b33.

Reason for revert: Causes massive build failure for osmo-pcu and osmo-sgsn on all the distributions/architectures we build for

Change-Id: I6dbe4507701bee013b29dcc26f32c4e1a3c23613
Closes: OS#4936
2021-01-08 10:14:02 +00:00
Daniel Willmann 09bea0152a bssgp_bvc_fsm: Handle block request from application correctly
This is no event from an incoming message so rx is NULL, and we can't send a
status PDU. Also blocking the signalling BVC is not allowed (unblocking it is already
forbidden).

Change-Id: I3e384b71d57e939efc1596ac1d92380ed5eb916d
Fixes: CID#215716
2021-01-07 18:57:57 +00:00
Daniel Willmann 210774f60b ns2_frgre: Fix missing break statement for recv from IPV6
Change-Id: I549277483fee55f390e0b5ae1dafec6f2d68eae7
Fixes: CID#215836
2021-01-07 18:57:28 +00:00
Daniel Willmann 7dccf8ede5 logging: Remove duplicate color for DLSMS
Change-Id: Ia797efce36e0afff74de54374d568521ecedf486
2021-01-07 18:57:18 +00:00
Eric Wild 2253224b33 pkgconfig: link to mnl if available
The dependency on mnl breaks builds of osmo-pcu et al if mnl is used for
libosmogb, but not linked in for lib users

Change-Id: Ib4df95d5c922f8edfa33e68645652fd30d321ff8
2021-01-07 14:28:42 +00:00
Vadim Yanitskiy 7e104d96ba bts_features: s/Repeation/Repetition/ in osmo_bts_features_descs[]
Change-Id: Ia8c77766842ce80eae969774959cbf46e86f97b9
2021-01-07 14:22:56 +01:00
Philipp Maier cea0c30507 gsm_08_18: add struct to parse RIM PDU Indications
3GPP TS 48.018, section 11.3.65 describes an IE to transfer some control
flags via a RIM container. The IE is essentially just a bitfield, so it
can be parsed by overlaying it with a C-struct. Lets add an appropiate
struct to protocol/gsm_08_18.h

Change-Id: I781ab838bd02ac1b13d384ce3f4259e26cedb61e
Related: SYS#5103
2021-01-06 18:33:42 +01:00
Pau Espin Pedrol 9584cd718a ctrl: Allow handling CTRL get/set replies in user defined code
Prior to this patch, it was not possible to gather SET/GET reply
information when implementing a CTRL client using libosmocontrol. This
is specially important when using the GET command, since one wants to
receive the queried value.
CTRL traps can also be handled this way by extending this patch in the
future if needed.

Change-Id: Id3c4631cd32c13e78e11b6e8194b8c16307ec4f1
2021-01-06 12:32:36 +00: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
Pau Espin Pedrol 463dca0b9c gitignore: Ignore *~
They seem to be generated by newer versions of autofoo.

Change-Id: Ia4514da3c3dcbc383487a3d98b322a5ecb918568
2021-01-05 18:39:37 +01:00
Daniel Willmann fbb78a73b4 bssgp: Add SUSPEND_NACK to osmo_pdef_bssgp
Change-Id: Ic996a343215ad32e3f301712411006e5d41f9084
Related: SYS#4865
2021-01-05 15:31:08 +00:00
Vadim Yanitskiy c9f4c49f81 gprs_bssgp: fix uninitialized struct fields in bssgp_create_rim_ri()
Change-Id: Ifc3dda1fe5e9743072751dbb14c2d973388cb3b2
Fixes: CID#215836
2021-01-05 15:21:39 +00:00
Vadim Yanitskiy 222e844718 gprs_ns2_fr: fix resource leaks due to early return in set_ifupdown()
Change-Id: Ie52bf8ac6d62e7f2d760294bf2fe90119cc96b4b
Related: CID#215869
2021-01-05 15:21:39 +00:00
Vadim Yanitskiy d8b7003df7 gprs_ns2_sns: always check rc of osmo_sockaddr_str_from_sockaddr()
Writing a configuration that will be rejected by the VTY parser
is not the best solution, but still better than printing values
from previous iterations or the stack garbage.  In any case,
this is unlikely to happen, just making Coverity happy.

Change-Id: I26644fe544c82c90767ec1a9709918474bd1be53
Fixes: CID#215852
2021-01-05 15:21:39 +00:00
Alexander Couzens 1c8785dd81 gprs_ns2: set transfer cap in NS Status primitive
Related: SYS#5153 OS#4835
Change-Id: Ia1046db9e0d50855bff9de670b612ffc57af9995
2021-01-05 14:24:03 +00:00