Commit Graph

58 Commits

Author SHA1 Message Date
Alexander Couzens ca5ce0d849 ns2: nsvc: add a uptime/downtime to track the last state change
To show adminstrator the last state change of a nsvc add a timestamp and
show it on the vty

> show ns nsei 1234
NSEI 01234: UDP, DEAD since 0d 0h 1m 42s
[...]
  4 NS-VC:
   UNBLOCKED DYNAMIC sig_weight=1 data_weight=1 udp)[127.0.0.1]:22000<>[127.0.0.1]:23001 ALIVE since 0d 0h 0m 1s
   UNBLOCKED DYNAMIC sig_weight=2 data_weight=2 udp)[127.0.0.1]:22000<>[127.0.0.1]:23000 ALIVE since 0d 0h 0m 1s
   UNBLOCKED DYNAMIC sig_weight=2 data_weight=2 udp)[127.0.0.1]:22001<>[127.0.0.1]:23000 ALIVE since 0d 0h 0m 1s
   UNBLOCKED DYNAMIC sig_weight=1 data_weight=1 udp)[127.0.0.1]:22001<>[127.0.0.1]:23001 ALIVE since 0d 0h 0m 1s

Related: OS#5028
Change-Id: Ie3a039a209869295afa5feda39297cee81fedf22
2021-09-23 13:12:34 +02:00
Alexander Couzens a7a757f2ee gprs_ns2: nsvc: react on STATUS PDUs with cause code NSVC UNKNOWN/NSVC BLOCKED
A STATUS PDU with cause code NSVC UNKNOWN/NSVC BLOCKED informs the other
side about a state mismatch between the side.

Change-Id: Ib6a2424f3027a30f14ef0a9fc2230e6aae9a2a04
2021-09-07 20:46:04 +02:00
Alexander Couzens e7873336a2 gprs_ns2: fix a white space
Change-Id: I2207d13ae451ce49482625fac43b6ab1c0f215e8
2021-09-07 20:46:04 +02:00
Alexander Couzens f27fbf65b7 ns2: nsvc: reject UNITDATA when the remote BLOCK'ed
When the remote initiated the BLOCK the nsvc would still accept UNITDATA
over this nsvc.

Change-Id: I3ed4aa105a84e448082d3028fe844aae7720426b
2021-09-07 20:46:04 +02:00
Alexander Couzens a140d44a4f gprs_ns2: ensure the NSE becomes dead when FR link went down
The FR code is using force unconfigured to change the state of the NSVC
when the FR link goes down. The force unconfigured state didn't
notified the NSE when changing into this state.

Related: SYS#5533
Change-Id: I4d7bbbbce26f7cde99eebe96995c50b1e812e5bd
2021-07-13 07:43:06 +00:00
Daniel Willmann efa64f9429 Aggregate NSVC stats inside the NSE
Change-Id: Ifa3c85ec52bda14596e9d7a8705baa1fd4ee2010
Related: OS#4998
2021-07-09 20:35:00 +02:00
Alexander Couzens 8138c53a32 gprs_ns2_vc_fsm: reset the ALIVE response time when stopping test
Prevent showing a response time when the NSVC has failed.

Related: OS#5089
Change-Id: I5435077d35ff1ae3d743ea1b1b8ace7f0fb913cf
2021-06-25 08:12:39 +00:00
Alexander Couzens e09deb6355 gprs_ns2: fix missing notify towards the NSE when NSVC become blocked
The NSE wasn't notified when a NSVC went into the BLOCKED state from
an UNBLOCKED state.

Related: OS#5182
Change-Id: I09634e414e9bb966e6b5809b7de1b59fbabd413d
2021-06-25 08:12:39 +00:00
Pau Espin 7b894a7de0 Use new stat item/ctr getter APIs
Generated with spatch:
"""
@@
expression E1, E2;
@@
- &E2->ctr[E1]
+ rate_ctr_group_get_ctr(E2, E1)
"""

"""
@@
expression E1, E2, E3;
@@
- E2->items[E1]
+ osmo_stat_item_group_get_item(E2, E1)
"""

Change-Id: I41297a8df68e28dfc6016330ac82b0ed5dd0ebc1
2021-06-04 18:19:37 +02:00
Alexander Couzens 79a3a84b15 gprs_ns2: fix nsvc block and unblock vty command
e7dfeac8dc introduced a regression in the block/unblock check
as it was using the priv->initiate_block instead of priv->om_blocked.
The initiate_block tracks who is responsible to unblock the NSVC.

Fixes: e7dfeac8dc ("gprs_ns2_vty: print a response to vty `nsvc <nsvci> (block|unblock|reset)")
Change-Id: I516faea223e30b120a297faed10636daa554be8a
2021-04-13 12:38:44 +02:00
Alexander Couzens e7dfeac8dc gprs_ns2_vty: print a response to vty `nsvc <nsvci> (block|unblock|reset)
The vty wasn't printing anything to the user if it was a success or not

Change-Id: Idbb83ea319bbdc94177febdd66e79c49fce7fdd2
2021-04-07 16:25:35 +00:00
Alexander Couzens 5b72247dde gprs_ns2: nsvc_fsm: reorder notification st_alive_on_enter()
The start_procedure() can't be called after ns2_nse_notify_unblocked()
because ns2_nse_notify_unblocked() might free the nsvc.
Otherwise the fsm will do use-after-free on the NSVC memory.

Related: SYS#5416
Change-Id: If97dfd123eefd71fc6c3fe886a243a21784aeeb4
2021-04-06 14:30:19 +00:00
Alexander Couzens 7619ed4304 gprs_ns2: fix memory leaks when receiving SNS or invalid packets
Change-Id: I8834d3f092e6cbe4f527e95e1eebd8133a386207
2021-03-29 21:26:46 +00:00
Alexander Couzens 27e5873c8d gprs_ns2: add vty command `nsvc <nsvci> reset`
Change-Id: I436dd0367e83548acfc8f8e36ae4707496a252d9
2021-03-24 15:42:45 +00:00
Alexander Couzens 6cf65d9d81 gprs_ns2: rework logging of Rx and Tx NS PDU
Introduce 2 new logging sub systems for signal and unit data.
Unify log messages so all log messages look similiar.
Log also Rx PDUs. Ensure dropped Tx packets (BLOCK/RESET on SNS)
contain *Tx*.

Change-Id: I34b8fde2955ecc010d1dcd9512e1bba9211e2c0d
2021-03-24 15:42:45 +00:00
Harald Welte 5e4083166a gprs_ns2: Actually start Tns-test after SNS-CONFIG creates NS-VC
the previous commit fixed the state transition, but also caused
neither Tns-alive nor Tns-test to run

Change-Id: I07ea3fd5cec3d4acf4051930a1a3c746d6fd597c
2021-03-24 01:04:21 +01:00
Harald Welte c51ddf27b4 gprs_ns2_vc_fsm: In IP-SNS/ALIVE mode, initial state is ALIVE/UNBLOCKED
Only when the ALIVE procedure fails, we mark a NS-VC as RECOVERING.

Change-Id: Ieb860827c2149306b135c0e6c8b3cd3bbb78851e
2021-03-24 01:04:21 +01:00
Harald Welte a39b2592a0 gprs_ns2: Remove any references to DNS; we use DLNS in NS2.
Related: OS#5058
Change-Id: I1f047e022a029d5f982deae0b30fec9e5a00d1ac
2021-03-04 13:35:14 +01:00
Alexander Couzens f46ebcd3ae gprs_ns2_vc_fsm: remove debug line of the alive_timer
The log line sneaked in when fixing the alive ms

Fixes: ab0e8646c4 ("gprs_ns2_vc_fsm: use CLOCK_MONOTONIC for alive elapsed timer")
Change-Id: Iffe367b240f47c39232bbc26991c19752a1c75ad
2021-02-15 03:45:35 +01:00
Alexander Couzens fa4121de2f gprs_ns2_vc_fsm: reset the alive elapsed timeout everytime
The alive elapsed timeout was only set once on the start of the
test procedure but not every time an ALIVE PDU was sent.

Fixes: OS#4997
Change-Id: I029696dfff21919f97ac4c33cdd82162b5ab1555
2021-02-12 08:57:29 +00:00
Alexander Couzens ab0e8646c4 gprs_ns2_vc_fsm: use CLOCK_MONOTONIC for alive elapsed timer
gettimeofday can jump and the comment says it should not be used for elapsed timer.

Related: OS#4997
Change-Id: I41989d8f9f82f4d1f7b97f11577653699365c8ae
2021-02-12 08:57:24 +00:00
Harald Welte b339cbb3ef ns2: Name NSVC FSM events consistently
Reading a log line like this:

<0026> gprs_ns2_vc_fsm.c:808 GPRS-NS2-VC(FR-hdlcnet1-DLCI16-NSE02001-NSVC00001)[0x6120000024a0]{UNBLOCKED}: Received Event RESET

is very ambiguous. Does it mean we received a NS-RESET message? Does it
mean the FSM was instructed to send a NS-RESET? ...

Let's make sure the human-readable names give a very clear indication
of what exactly is happening.

Change-Id: I8b7615b3eca04212831163ff0ea4aea35069cd0e
2021-02-08 18:36:21 +01:00
Alexander Couzens d3e31102fb gprs_ns2_vc_fsm: rename ST_ALIVE -> ST_RECOVERING
ST_ALIVE isn't quite clear. This state means this NS-VC is still dead.
ST_ALIVE is used for NS-VC with vc_mode ALIVE (e.g. UDP NS-VC). It's
the first state when the remote hasn't yet answered or when
the NS-VC lost ALIVEs.

Related: OS#4958
Change-Id: I0b29e8ce6444546d90bde68b1f957f1013238784
2021-02-03 14:37:41 +01:00
Alexander Couzens 2f8f7b62b3 gprs_ns2_vc_fsm: reset ALIVE N counter when restarting the test procedure.
Otherwise a NS-VC would flap between ALIVE and UNBLOCKED state.

Related: OS#4959
Change-Id: Id98629bd65f92103e0e571ec388c58b02cb2ccb5
2021-02-03 11:08:00 +01:00
Harald Welte 6a9ec42a95 ns2: Stop test procedure when going into unconfigured state
When we're unconfigured and not yet started, we should not transmit
NS-ALIVE.

Change-Id: Ida3685e42a753899f1bf177eefcc23352ec7440d
Related: OS#4999
2021-02-02 11:37:48 +00:00
Harald Welte 7fe8d71fee ns2: Don't automatically re-start FSM at FORCE_UNCONFIGURED
There are use cases in which the NS-VC FSM should go back to
unconfigured _without_ being re-started immediately.  Let's permit
the caller to do that.

Change-Id: I31fe695a83d38ea1f10f5444e840633d7fa68442
2021-02-02 11:37:48 +00:00
Harald Welte d083576064 ns2: cosmetic: fix indent levels
Change-Id: Ifcb0d5ddf824cd876de91afca1021aeb4f6c3e8b
2021-02-01 09:43:13 +01:00
Harald Welte b40bf8ba3b ns2: Add a rate_ctr for each NS-UNBLOCK
We have one for BLOCK, so let's also add one for UNBLOCK.

Change-Id: I693109b7bc4d72b6803b40aae15327389aa37c69
2021-01-31 12:34:36 +01:00
Harald Welte 4c54f59aa5 ns2: Implement more rate counters
The counters had all been lost in the ns -> ns2 configuration,
let's try to implement some more of them: LOST_ALIVE, BLOCKED,
LOST_RESET.

Change-Id: I75d8637bd142722fdf9a162a2369aa9cdc980a57
2021-01-31 12:34:36 +01:00
Alexander Couzens 138b96f21c gprs_ns2: refactor: ensure all enums have GPRS_NS2_
All public enum should have the prefix GPRS_NS2_.

API change which must be synchronized with osmo-pcu,
osmo-gbproxy, osmo-sgsn.

Change-Id: I548ff12f7277cbb7e1a630a3dc02b738ce89be72
2021-01-28 11:56:37 +00:00
Alexander Couzens f7e2cace2c gprs_ns2: drop the public prefix gprs_ from all static functions/structs/..
Change-Id: I6ba0599e5a6d6fabf93851dd3ec7716f2ef2d840
2021-01-25 16:18:21 +01:00
Alexander Couzens 8dfc24cb47 gprs_ns2: drop prefix of all internal exposed function
All functions which are exposed by gprs_ns2_internal.h should not contain
the public prefix gprs_. Internal function should only contain ns2_ prefix.

Change-Id: Icecc5a918902cd10efac72bbac20780d39aab272
2021-01-25 16:09:23 +01:00
Alexander Couzens 3f576ab486 gprs_ns2_vc_fsm: check NSVCI match the NSE
The NSVCI must match the PDUs. The only exception is a RESET with
dialect ipaccess. However those will be handled later.

Change-Id: I0ebdd4f4135b03a7d44a93aff3846c8ec19f333b
2021-01-25 15:35:14 +01:00
Alexander Couzens 43771df63f gprs_ns2_vc_fsm: check NSEI match the NSE
The NSE must match the PDUs. The only exception is a RESET with
dialect ipaccess. However those will be handled later.

Change-Id: I00bc04f3f46f5ae8ddd8b4b7d5479fb8e6463e1e
2021-01-25 15:35:14 +01:00
Harald Welte b3d4778efb Revert "gprs_ns2_vc_fsm: check NSEI match the NSE"
This reverts commit 842599ca62.
Closes: OS#4965

Change-Id: I96882961e179bb63e3f4095571135244148dde20
2021-01-21 12:48:46 +01:00
Harald Welte 43cb90ff5d Revert "gprs_ns2_vc_fsm: check NSVCI match the NSE"
This reverts commit 9c1e04e580.
Related: OS#4965

Change-Id: Ic26e6ee8c225266dc31850e38976460cb0e81ebd
2021-01-21 12:46:59 +01:00
Alexander Couzens 9c1e04e580 gprs_ns2_vc_fsm: check NSVCI match the NSE
The NSVCI must match the PDUs. The only exception is a RESET with
dialect ipaccess. However those will be handled later.

Change-Id: I8518bdb03e9e33b04b77a2a346d04c5d29544a6c
2021-01-20 17:50:55 +01:00
Alexander Couzens 842599ca62 gprs_ns2_vc_fsm: check NSEI match the NSE
The NSE must match the PDUs. The only exception is a RESET with
dialect ipaccess. However those will be handled later.

Change-Id: Ic8fc49d850490feb0ff69171a6b0881ae8696c0b
2021-01-20 17:47:10 +01:00
Harald Welte f294974e05 ns2: Unify logging context via log macros
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
2021-01-20 16:42:33 +00:00
Alexander Couzens 191c2d7de9 gprs_ns2_vc_fsm: fix transitions for ALIVE state
Alive can never reach RESET. However ALIVE -> ALIVE is allowed.

Change-Id: Ic414d7ca96b1ec6db1665cd4c072c7ebbee787f1
2021-01-20 14:59:28 +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 5443ff8af3 gprs_ns2_vc_fsm: fix spaces and remove wrong comment
Change-Id: I52799d8ce8244fae7512a6e14a3cf2408a218c2d
2021-01-18 10:47:47 +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 6f3b738c74 gprs_ns2: don't start unconfigured fsm via FORCE_UNCONFIGURED
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
2020-12-23 06:32:29 +01:00
Harald Welte e24a5b559c ns2: Accept NS-UNBLOCK-ACK in UNBLOCKED state
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
2020-12-08 12:27:38 +00:00
Daniel Willmann ed0c982079 ns2: Add a function to set the NSVC FSM back to unconfigured
The function gprs_ns2_vs_force_unconfigured() resets the NSVC state back
to the initial value when it was first started. This can be useful for
testing.

Related: SYS#5002
Change-Id: If96d56b19959372af4eba009661be19e985b4d51
2020-11-20 15:38:00 +01:00