The NSVCI must match the PDUs. The only exception is a RESET with
dialect ipaccess. However those will be handled later.
Change-Id: I8518bdb03e9e33b04b77a2a346d04c5d29544a6c
The NSE must match the PDUs. The only exception is a RESET with
dialect ipaccess. However those will be handled later.
Change-Id: Ic8fc49d850490feb0ff69171a6b0881ae8696c0b
Let's avoid open-coding the printing of log context and rather rely on
log macros to prefix each log line with the relevant context. This
helps log readability, log post processing whether by grep or more
sophisticated tools.
Change-Id: I946c0e77686d91efc5afb62031e1ac1033a9a586
When the length field is written the function writes the lower and the
higher half of the length at the same position, so the higher half is
overwritten with the lower half, this is wrong.
Change-Id: I3cce0b2796793554a421fd3ce8e749c52d22eaea
Related: CID#216670
Related: SYS#5103
The current version of libosmocore only supports NACC related RIM
application containers. If the parser detects a different application
container it returns with EINVAL. Unfortunately this means that the
caller can not distinguish if there is a lack of support or a real
parsing error.
Change-Id: Ib5ada3554c04259764352888cf95bc4460cb2a54
Related: SYS#5103
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
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
A BLOCK message can be received when waiting for a UNBLOCK message
in state BLOCK
Related: SYS#5208
Change-Id: Ie7b34b3ef04aa28304143191222324e1a3786cb2
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
Usually talloc_free() and other free functions in osmocom allows
to be called with NULL which is then ignored.
Change-Id: If7b0c6916a29d4611d0a40c388414076eb83e6b5
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
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
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
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
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
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
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
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
The vty command is used for test cases to reset NSE state.
So dynamic NSE shouldn't present.
Related: SYS#5208
Change-Id: I0a4f35c974c8c3b79c48f2f56170722c95254332
48.016 7.2: says an UNBLOCK pdu should be answered with UNBLOCK_ACK on
already unblocked NSVC
Related: SYS#5208
Change-Id: Ic92e99b2607d1e54ecb4668667065502a55a2ce0
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
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
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
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
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
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
When a dahdi device hasn't been set up yet, ioctl IF_GET_PROTO fails
with invalid argument.
Also fix the device check to skip ioctl's if the device is also in the
correct state.
Change-Id: I398d056546e35465a2944e1b4a86a8c93b3e5f7a
For frame relay the traffic will be even distributed across
all NS-VCs. Do not differentiate between signalling and
data traffic.
Change-Id: I6c060941db335a7a6a555ac8d1b9269fa8fb2023
The IP-SNS need to do a reselection of the IP-SNS remote
for testing. Freeing all nsvc will force this.
Change-Id: I367c215a830c02eae2a470cba314828b5e0fb5c9
IP-SNS NSVC are unconfigured and not started when the IP-SNS is doing the SNS configuration.
If those NSVC would be started it would result in unsolicitated NS-Alive PDUs.
Change-Id: Ifec7288dbe71f10109e8b5c3849bf8f23ac7b557
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
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
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
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
When a frame relay interface doesn't exist gprs_ns2_fr_bind() would
detect this but still return a success.
Change-Id: I815b6ef5c3df780ac94461a05975a2b70898b01e
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
Only accept receiving ipaccess style messages when use-reset-block
is selected.
If use-reset-block is disabled allow static NSVCs.
Change-Id: Ia787528b1a6fac6bf1570c21643ef6cd8c209108
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
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
According to 3GPP Size and Config procedure can
have retries in case the timeout of the procedure runs out.
Change-Id: I00e9023a6e7adc6ad48f4016fcaef189ac8b353e
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
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
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
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
The allocation of the SNS fsm can be done in create_nse
because the dialect is now known at that time.
Change-Id: I64e1f3dcc63d38e65bb486c9ac08d4032b7ad222
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
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
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
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
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
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