Commit Graph

3810 Commits

Author SHA1 Message Date
Alexander Couzens 3ad73368be gprs_ns2: sns: correct log message when no nsvcs available
The log message should only shown if a reselection will be triggered.

Change-Id: I96b280a927aba6ac09ce88aedfcf469243c4dffe
2020-12-23 06:32:29 +01:00
Alexander Couzens 412bc3494d gprs_ns2: add new vty2
Change-Id: I163279cf57e84198dc8c53e1c109f5a9474670e9
2020-12-22 16:36:19 +01:00
Harald Welte d2a61179a3 lapd_core: Don't dereference data link after sending PRIM_DL_REL
We must always send the RELEASE.{indication,confirm} last before
returning from a function.  We cannot rely on the datalink to
still be around after the call, as the SAP user might have destroyed
the data link meanwhile.

This fixes a heap use-after-free (at least) with RBS2000 when the BTS
is fully brought up and the OML data link is lost, see OS#1762

Change-Id: I8ccca8d5e5d07b666557afe12ab8ac4910ddfb00
Related: OS#1761
Related: OS#1762
2020-12-21 17:43:54 +01:00
Harald Welte c296e2921a vty: Fix left shifting out of range on signed variable
Fixes following ASan runtime errors while running vty tests:
command.c:730:27: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'

Somehow we didn't catch this one in Ie11ff18d6fd9f6e1e91a51b6156fb6b0b7d3a9a8

Change-Id: I601caf7daa947f3cf391316f1011007ef9188c90
2020-12-21 15:45:45 +01:00
Harald Welte 4eb0f16e25 fsm: Add osmo_fsm_inst_broadcast_children()
This is a helper function to broadcast an event to all of the
siblings of a specified FSM instance.

Change-Id: I2ce398741a8672d7b7c4058d056f46e2fe7353c1
2020-12-21 15:45:45 +01:00
Harald Welte b8de188b54 gprs_ns2_fr: Use OSMO_STRLCPY_ARRAY() where possible
Change-Id: I8ce461ecc36a81a4221336e82a36a69f49f89a0a
2020-12-21 11:41:55 +00:00
Harald Welte 7f01b68671 gprs_ns2_fr: Avoid stringop-truncation warning
gprs_ns2_fr.c:448:2: error: ‘strncpy’ specified bound 16 equals destination size [-Werror=stringop-truncation]
  448 |  strncpy(req.ifr_name, netif, IFNAMSIZ);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Change-Id: Ied9fd1bea091075fad266258da39e674d10d4dcb
2020-12-21 12:41:03 +01:00
Alexander Couzens 5c96f5dbc6 gprs_ns2: fr: setup the device to correct FR/LMI settings
A hdlc can be used in different modes. Also a FR device can be used
with lmi and certain settings as without it.
ns2 will use FR with no lmi in the kernel.

Related: SYS#5169
Change-Id: I04786d2b864860b08c2e1afdb199470f4b80cc3b
2020-12-20 17:16:44 +01:00
Alexander Couzens 60021a46ce gprs_ns2: fr: implement a write queue
Related: SYS#5228
Change-Id: Id6eba04d5fb744f791b333c168729bbbd28cabd9
2020-12-20 17:14:04 +01:00
Alexander Couzens 3c22f91bad gprs_ns2: don't pass the return code of reject_status_msg
When reject_stats_msg() fails the code can't do anything about it.
Stick to the original failure code and log it

Change-Id: I105363957e59c41a68835b7a9830c048dba73e93
2020-12-20 15:34:53 +00:00
Alexander Couzens 12e5e6bd78 gprs_ns2: improve handling of TLV errors on new nsvcs
The specification says the PDU should be ignored if the PDU type is
unknown.

Change-Id: I2992d06b37ed122b7ff315d4852e86acc936800b
2020-12-20 15:34:49 +00:00
Vadim Yanitskiy 2060bbb4c1 gsm_08_58: fix wrong field order in 'struct ipac_preproc_pc_thresh'
Thanks to the CLI of nanoBTS, I noticed that upper and lower RxQual
thresholds are sent in wrong order.  Only the little-endian variant
needs to be fixed, the big-endian one looks good.

Change-Id: If6ab2377bae6742f871589b529a349498775552f
Related: SYS#4918
2020-12-19 17:33:52 +01:00
Neels Hofmeyr 8fef761d14 fix strncpy bug in gprs_ns2_fr_bind()
This use of strncpy() fails to account for the terminating nul
character. Use OSMO_STRLCPY_ARRAY() instead.

(Interestingly my compiler doesn't complain about this one, though it
failed on another similar use of strncpy().)

Change-Id: Id53e940c7a39ab154966548f4173a179c5bc9151
2020-12-18 11:12:16 +00:00
Neels Hofmeyr 475a0acc64 gprs_ns2_fr.c: compiler error: replace strncpy() with OSMO_STRLCPY_ARRAY()
My gcc (Debian 8.3.0-6) 8.3.0 refuses to build this strncpy() use: it
issues the buffer length as n and thus potentially fails to account for
the terminating nul. The line after that fixes the problem, so it's not
an actual bug. Anyway, we have a policy to never use strncpy(), and have
osmo_strlcpy() and OSMO_STRLCPY_ARRAY() for this.

This strncpy() was introduced last month during first addition of
gprs_ns2_fr.c:

    commit 841817ec52
    ns2: add support for frame relay
    Change-Id Id3b49f93d33c271f77cd9c9db03cde6b727a4d30

Change-Id: I494a6fb7ccd7938a39e8956f73ec4282da38d7fb
2020-12-18 11:12:16 +00:00
Alexander Couzens 6f89c770c7 gprs_ns2: fr: fix crash when frame relay interface doesn't exists
When a frame relay interface doesn't exist gprs_ns2_fr_bind() would
detect this but still return a success.

Change-Id: I815b6ef5c3df780ac94461a05975a2b70898b01e
2020-12-18 10:52:37 +00:00
Vadim Yanitskiy d82ba90825 logging: revert color of LGLOBAL category back to white
"\033[38;5;19m" is unreadable on terminals with dark background.

Change-Id: I8ed40522b07c2028de4986d1f976609510faa894
2020-12-17 17:50:18 +00:00
Pau Espin Pedrol 946bb95af1 GPRS Cell Options (SI13): Add REL-4 CCN_ACTIVE bit
This is required in order to tell MS that osmo-pcu now supports
Network Assisted Cell Change (NACC).

Related: SYS#4909
Change-Id: I2aaa8c1107c977f711c2d7530034f57e36e3a237
2020-12-17 15:22:09 +00:00
Philipp Maier bd10c21cc4 gprs_bssgp: add IE parser/generator for RIM Routing Information
The RIM Routing Information IE (see also 3GPP TS 48.018, section
11.3.70) is used to control the flow of BSSGP rim messages at the SGSN.

Change-Id: I6f88a9aeeb50a612d32e9efd23040c9740bc4f11
Related: SYS#5103
2020-12-16 21:58:04 +01:00
Alexander Couzens 8806796976 gprs_ns2_vty: udp: fixup dialect changes
Only accept receiving ipaccess style messages when use-reset-block
is selected.
If use-reset-block is disabled allow static NSVCs.

Change-Id: Ia787528b1a6fac6bf1570c21643ef6cd8c209108
2020-12-16 21:34:03 +01:00
Harald Welte 33c3c0655b gors_ns2_vty: Fix saving of new NS2 timers
In I00e9023a6e7adc6ad48f4016fcaef189ac8b353e we introduced
two new timers, but failed to add the related value_string[]
entries.  This caused the VTY code to save something like

 timer unknown 0x8 3
 timer unknown 0x9 3

which fails to parse on re-start.

Change-Id: If5cfdf1ef68d98933985406d0ac071a0a1185646
2020-12-16 12:05:37 +01:00
Harald Welte 3a44d17a99 Fix VTY syntax for newly-introduced NS2 timers
In I00e9023a6e7adc6ad48f4016fcaef189ac8b353e we introduced two new
"timers": Number of retries for SNS-CONFIG and for SNS-SIZE.

Yet, the VTY syntax only added one string (tsns-prov-retires), probably
dating back to an earlier version.

Change-Id: I25fa579c7d68a8e4cb1175ae2245f009ab40fda7
2020-12-16 12:04:44 +01:00
Alexander Couzens bac5b0153b gprs_ns2: on ns2_create_vc parse the tlv before using it
reject_status_msg require a parsed tlv. Otherwise an
uninitialized tlv is passed.

Change-Id: I82cab518966b8b49c3522ff5f7b6f82d1027a526
2020-12-15 11:56:29 +00:00
Alexander Couzens c782cec663 gprs_ns2: add gprs_ns2_fr_bind_role() to retrieve the fr role
Change-Id: I277b805e588ba68536789b4a64a428ea0b31728a
2020-12-15 11:46:45 +00:00
Alexander Couzens 22c26e0610 gprs_ns2: make nsvc argument const
The nsvc isn't change. It can be const

Change-Id: Ie5052f02781d7fdc639456c6f02515a927cee1f3
2020-12-15 11:46:45 +00:00
Alexander Couzens 90ee963570 gprs_ns2_sns: introduce SNS Size/Config retries
According to 3GPP Size and Config procedure can
have retries in case the timeout of the procedure runs out.

Change-Id: I00e9023a6e7adc6ad48f4016fcaef189ac8b353e
2020-12-15 11:46:45 +00:00
Alexander Couzens 81ae0aa67f gprs_ns2_sns: use different binds for the initial connection
In case the first bind is not working the SNS would never build a
succesful connection to the SGSN. Iterate over all binds by
using an offset.
Instead of tracking the binds use an offset instead of a direct pointer.
This might result in skipping the order of the next bind.

Change-Id: I4a0a0608dac6ad8b5769ada2a14ca23f61eb0bcb
2020-12-15 11:46:45 +00:00
Alexander Couzens e769f5226b gprs_ns2_sns: rework IP-SNS initial remote
The IP-SNS requires at least one initial remote address of the SGSN.
However it should be multiple initial remote address instead of a single
in case the interface might fail.
Rework the SNS to support multiple initial remote addresses.

Change-Id: I71cdbfb53e361e6112fed5e2712236d797ef3ab2
2020-12-15 11:46:45 +00:00
Alexander Couzens 4755879fbe gprs_ns2: add gprs_ns2_free_nsvcs() to free all NS-VC of a NSE
Change-Id: I909443b540dbf75146297f1d7f94940690be6c0d
2020-12-15 11:46:45 +00:00
Alexander Couzens ebcbd726ee gprs_ns2: rework gprs_ns2_fr_connect*()
Add gprs_ns2_fr_connect2() and change gprs_ns2_fr_connect() to
be similar to gprs_ns2_ip_connect() and gprs_ns2_connect2().

This is an API break but there wasn't yet a release with NS2.

Change-Id: I4e1374b0e979b3293302c5ed46a91a58f3a5a916
2020-12-15 11:46:45 +00:00
Alexander Couzens aaa55a663e gprs_ns2: add member name to bind
Every bind will have a unique name. Add a name argument
to all bind creating functions and require them to be unique.

This is an API break but there wasn't yet a release with NS2.

Change-Id: I8f1d66b7b3b12da12db8b5e6bd08c1beff085b3e
2020-12-15 11:46:45 +00:00
Alexander Couzens 93ad499832 gprs_ns2: move allocation of the SNS fsm into create_nse
The allocation of the SNS fsm can be done in create_nse
because the dialect is now known at that time.

Change-Id: I64e1f3dcc63d38e65bb486c9ac08d4032b7ad222
2020-12-15 11:46:45 +00:00
Alexander Couzens d923cff170 gprs_ns2: introduce NS dialects
A NS dialect describes how the NS Entity interacts with
different virtual circuits. E.g. ipaccess use reset/block on udp
and is a dynamic connection.
A single NS Entity can only support one dialect. This can be later
used to protect a NS Entity against dynamic NS virtual circuits of a
different type.

It further allows a bind to support multiple dialects at the same time.

Change-Id: Ia118bb6f994845d84db09de7a94856f5ca573404
2020-12-15 11:46:45 +00:00
Vadim Yanitskiy c8158ecfc4 protocol/gsm_08_58.h: add Osmocom specific EWMA AVG algo
Change-Id: Ib436fd8b81afdb06c6d936f6839f847a705d00e2
Related: SYS#4918
2020-12-15 09:52:42 +00:00
Vadim Yanitskiy a346c45ceb protocol/gsm_08_58.h: add ip.access Power Control structures
Change-Id: I9430bcb79c269efb4f9527f565cf4e12e4444940
Related: SYS#4918
2020-12-15 09:52:42 +00:00
Pau Espin Pedrol 0f619de715 gsm: append_eutran_neib_cell: Fix SI2quater EARFCN list
Commit bd6e7a9f2d did the initial porting
of rest_octet APIs from osmo-bsc, but introduced a bug when moving
bts->e_offset to a generic pointer independent of bts structure.
As a result, using this API from osmo-bsc makes gsm0408 unit test fail
due to bad encoding of several EARFCNs in si2quater.

Fixes: bd6e7a9f2d
Change-Id: I2bf5635b8536b11d69774d17ac1908019633e3af
2020-12-14 17:58:23 +01:00
Pau Espin Pedrol c4286ad056 si2quater: fix budget calculation for multiple EARFCNs
In rest_octets.c append_earfcn(), the unconditional bits added are 40, not 25.
Removing only 25 bits from the budget resulted in malformed SI2quater starting
with 4 configured EARFCNs, by adding more EARFCNs than fit in 20 bits.

These malformed SI2quater were also expected in gsm0408_test.c. Update the
expected SI2quater to what is being generated now. This patch passes the ttcn3
testing added in I45382f88686ca60e68569e93569fc4cfb63a0e0d, which provides some
confidence that the coding expected in gsm0408_test.c is now correct.

This commit is a cherry-pick of osmo-bsc.git 6589f7c3a8dfdaaf66dda3afa6bbb1118ec825f9

Change-Id: Icc1ece39ad162d09720e104c5cbc12b07d6771a8
Related: OS#4652
2020-12-14 17:19:30 +01:00
Pau Espin Pedrol 30bf0e6745 gsm: si13: Fix encode of EGPRS_PACKET_CHANNEL_REQUEST
Cherry-pick from osmo-bsc.git e981f17200bf3a5d5114f46d9f7515fd10b96dbb

Change-Id: I0aae385a427205cc73f60feca161e38608e608d8
2020-12-14 17:13:47 +01:00
Pau Espin Pedrol 908224c1a4 rest_octets: add Serving Cell Priority Parameters
When we add an EARFCN to to the SI2quater struct we do not add Serving
Cell Priority Parameters. This essentially causes to MS to ignore the
EARFCN because it is still undefined under which conditions the MS
should change to LTE.

This is a cherry-pick from osmo-bsc.git 295c965c063a8c431507191f6aef1ef78b720685

Related: SYS#4510
Change-Id: If9134759e9bc4ae0920800972632fd8c5dc9c2d9
2020-12-14 17:11:21 +01:00
Harald Welte 5bea72e1e0 gprs_ns2_fr: use ETH_P_HDLC instead of ETH_P_ALL
When opening the socket, use ETH_P_HLDC to restrict the socket to
packet received on HLDC interfaces.  This avoids packets from random
other (ethernet, ...) interfaces to appear before we can bind()
it to the actual hdlc-net-device we're interested in.

We still are racing against other HLDC net-devices, but those have
lower PPS and throughput ratese as 1G/10G or even higher speed ethernet
devices that might exist on the same machine.

Change-Id: I6a556e6e2d012c17a2777cc8b30fed0f318db178
2020-12-10 22:08:02 +01:00
Harald Welte 41b188b90b gprs_ns2_fr: guard against race between socket(AF_PACKET) and bind()
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
2020-12-10 22:01:33 +01:00
Harald Welte 4ed0f4e994 gprs_ns2_fr.c: Skip extraneous FIONBIO
The socket is marked non-blocking inside osmo_fd_register(), there
is no need to do it twice.

Change-Id: I2068ce8280357b14970d01e5c86de5c59c933650
2020-12-10 22:01:33 +01:00
Pau Espin Pedrol 0e61716881 bssgp: Remove newly added log line warning about NOOP
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
2020-12-10 13:39:44 +01:00
Harald Welte 1fcfce86cb bssgp_bvc_fsm: Add basic BVC flow control rx/tx support
The FSM doesn't actually implement the flow control logic,
it only decodes / dispatches and encodes messages.

Related: OS#4891
Change-Id: Ie59be6761177c43456898be9148727f15861a622
2020-12-09 22:57:53 +01:00
Harald Welte 4394bb9629 bssgp2: Encoding + Decoding functions for BVC and MS flow control
Change-Id: I9c89bb1c03550930c07aad7ff8f67129ee7a6320
Related: OS#4891
2020-12-09 22:56:07 +01:00
Harald Welte 4c0e1a1f4c logging: Assing different 8bit colors to built-in subsystems
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
2020-12-09 22:56:07 +01:00
Harald Welte 17a892ff2b gb: Add beginnings of a new BSSGP implementation
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
2020-12-09 22:56:01 +01:00
Harald Welte fde19ed579 logging: Introduce DLBSSGP logging constant
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
2020-12-09 22:50:01 +01:00
Alexander Couzens 45a25a3222 gprs_ns2_sns: correct dynamic calculation
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
2020-12-09 16:13:42 +00:00
Harald Welte dec201a606 tlv.h: Add msgb_tvlv_put_{16,32}be()
Those routines are very useful when puzzling together BSSGP messages
with 16-bit and 32bit sized IEs.

Change-Id: I033f9a708c9d7ffad91336178231dc66233e1693
2020-12-08 21:37:45 +01:00
Harald Welte a6f896232e gsm_08_18.h: Add #defines for [extended] feature bits
Change-Id: I7743cb901988c8fddd91127cfdca6e54b3d44ea8
2020-12-08 12:27:38 +00:00