Commit Graph

62 Commits

Author SHA1 Message Date
Daniel Willmann fa3a9ce9fd gpsr_ns2_udp: Use osmo_io_fd instead of osmo_fd
Change-Id: Id776d2d9f35c304620f3d5b94492148dd987f5a0
2023-05-16 08:04:23 +00:00
Pau Espin 5c7eaa671a gprs_ns2_fr: use osmo_netdev to monitor and operate network device
As a result libosmogb doesn't depend directly on libmnl anymore, but
through libosmocore.

Change-Id: Ib0e499e09c50135a5c4a361332d6120f660a1a45
2023-02-02 10:21:17 +00:00
arehbein 0d9b6b0e31 gb/vty: Show if NSVC is blocked locally by O&M/vty or by remote
Related: OS#5085

Change-Id: I0e8a12c3e54b701c9e697d50de1c9cb0bcc817e0
2022-10-27 18:35:30 +02:00
Alexander Couzens d802f9ae6e ns2: message: allow to pass a foreign NSVCI to STATUS PDU
To answer correct on a BLOCK PDU with a different NSVCI, the
STATUS PDU needs also a NSVCI parameter.

Change-Id: I373eb48697097cdfa45748a091c11f7b3f0345fa
2021-10-08 05:43:46 +00:00
Alexander Couzens 67cfc5dc9a ns2: message: BLOCK/BLOCK ACK allow to use a given NSVCI instead of using the nsvc nsvci
The BLOCK and BLOCK ACK PDUs can be send over a working NSVC to inform
the NSE that a NSVC is blocked.

Change-Id: I6189229fdc1f054e86811bc60cb7646e1f758a78
2021-10-08 05:43:46 +00:00
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 2c64c257c8 ns2: nse: add a uptime/downtime to track the last state change
To show adminstrator the last state change of a nse add a timestamp and
show it on the vty

> show ns nse 1234

NSEI 01234: UDP, ALIVE since 0d 0h 0m 16s
 FSM Instance Name: 'GPRS-NS2-SNS-SGSN(NSE01234-SNS)[0x6120000012a0]', ID: 'NSE01234-SNS'
  Log-Level: 'DEBUG', State: 'CONFIGURED'
  Timer: 4
 Maximum number of remote  NS-VCs: 8, IPv4 Endpoints: 2, IPv6 Endpoints: 0
 [...]

Related: OS#5028
Change-Id: I8143080a3c5c9a55d37dfad44ba2ac6561daa216
2021-09-23 13:12:34 +02:00
Alexander Couzens 1f3193d344 gprs_ns2_sns: implement local change weight procedure
When changing the bind ip-sns weight, initiate a
SNS CHANGE WEIGHT procedure to inform the other side.

Related: OS#5036
Change-Id: Icec4dabb46bc198f68f91bfe09ba279fbe68d454
2021-09-04 00:00:48 +02:00
Alexander Couzens f074659520 gprs_ns2: don't use llist_for_each when freeing an element
The problem are recursive execution because a free generates an event which could
allow the use to free a nsvcs while the llist_for_each() is still running.

Change-Id: I902557fb6e56e6588728a46e43a9cbe3215d5c68
2021-09-04 00:00:48 +02:00
Alexander Couzens 83f06cea0a gprs_ns2: use an event to free the nsvscs when using SNS
Otherwise there could be recursive loop when free'ing NSVCs which
in the end create an event which the SNS want to free the NSVCs a
second time

Change-Id: Ie99ba5fe8a84519fe8a8c0abdf875606715ab7f6
2021-09-04 00:00:48 +02:00
Alexander Couzens 175eb7be1b gprs_ns2: move sns_event into internal.h to direct emit events
When other parts of ns2 requires to emit an event to the SNS fsm it would
need a proxy function because the events are private to the
SNS file. To circumvent creating multiple proxy function make the events
available via a header file.

Change-Id: I8e3fae4367c112b5a71bffb33c302d903855cddc
2021-09-04 00:00:48 +02:00
Alexander Couzens 41589a3e7a gprs_ns2: add recursive anchor to protect against double free
When free'ing a NSE/NSVC/BIND ensure there can't be a double
free by using a free anchor in the struct.

Recursive free's can happen when the NS user reacts on an event
(e.g. GPRS_NS2_AFF_CAUSE_VC_FAILURE) and calls the free().
Or when the user free's a NSVC when the NSE uses SNS as configuration,
the fsm tries to free it again.

Change-Id: If9823aadaa936e136aa43e88cee925ddd5974841
2021-08-13 09:55:51 +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 27a5592205 gprs_ns2: add functions for SNS add/del/change-weight messages
Related: OS#5036
Change-Id: Ib9492e213e82c18c7dcce6ba7d64e897b4c74796
2021-04-18 06:38:34 +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 75b6188974 gprs_ns2: always use the same method to print NSVCs
The binds also print a list of associated NSVC when
dumping the bind.
However the binds using their own representation of
printing the NSVC which is different to `show ns entities`.
Use the same function to print NS-VC.

Before:
  NSVCI 00000: udp)[127.0.0.1]:23000<>[127.0.0.1]:22000
After:
  NSVCI none: UNCONFIGURED DYNAMIC data_weight=1 sig_weight=1 udp)[127.0.0.1]:23000<>[127.0.0.1]:22000

Change-Id: If31ec6c1c07dc134ab1ddeb915bc89747c7be048
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 c962a2efc3 gprs_ns2: Add comments explaining the nsvc->sns_only field
Change-Id: I16009a1b03d8027de2be56b7d5013b755c9550fd
2021-03-24 00:30:23 +01:00
Harald Welte d164ef80f9 gprs_ns2_sns: Allow VTY configuration of default binds for IP-SNS
In the IP-SNS SGSN role, we need to inform the BSS of our local
IP endpoints.  For statically configured NSEs, those are explicitly
stated on a per-NSE level.

For dynamically created IP-SNS NSEs, we are adding a new VTY
command, using which the administrator can configure which binds
should be advertised as IP endpoints to such BSS.

Change-Id: Id01c29b07e9203c9305f2129361a4f5aaefa2c52
Related: OS#3373
2021-03-24 00:30:23 +01:00
Harald Welte 5b034fbab0 gprs_ns2: Introduce gprs_ns2_create_nse2() for SGSN side SNS
gprs_ns2_create_nse() doesn't allow the caller to specify if the
BSS or the SGSN role of IP-SNS shall be implemented.  Add
gprs_ns2_create_nse2() to fix that.

Change-Id: I6db8c36f7c69b592d7d0fbcf323804f7e9912be2
Related: OS#3373
2021-03-24 00:25:56 +01:00
Harald Welte 4f1274614e gprs_ns2_sns: Support for SGSN-side IP-SNS
This adds the core functionality of implementing the SGSN-side of IP-SNS
inside a new FSM.  The SGSN-side FSM shares states, events, structures
and code with the BSS-side whenever possible.

Note that this commit does not yet use the SGSN-side FSM, that is part
of subsequent commits.

Closes: OS#3373
Change-Id: I780413ffacd9cb71f64cc38057aae781eeb59b2b
2021-03-23 11:57:16 +01:00
Harald Welte 06d9bf910b gprs_ns2: Encapsulate setting NSE dialect
Setting the NSE dialect possibly involves the creating (or destruction)
of a IP-SNS FSM.  Encapsulate that, rather than having every caller
re-implement that.

Change-Id: I24fdc26fbcfda039bd58ea166f4d5c2fd1801da1
2021-03-10 12:23:09 +00:00
Harald Welte 7d0daac1ce gprs_ns2: Pass peer/remote sockaddr argument to ns2_create_vc()
This is a preparation towards auto-creating SNS NS-VCs in SGSN role

Related: OS#3373
Change-Id: Idf92712079cd9b7e4ff2cf8df314b372d63e6e52
2021-03-04 13:35:14 +01:00
Alexander Couzens 4f1128fcbd gprs_ns2: inform the NS user (BSSGP) about the MTU of a NSE
The BSSGP layer needs to know the MTU of the NS UNIDATA payload.
The MTU can be 0 if the NSE doesn't contain any NSVC.
Every status indication will contain the mtu value.
The MTU in the status indication contains the maximum transfer
unit of a BSSGP message. From NS side the maximum SDU.

Related: OS#4889
Change-Id: I5016b295db6185ec131d83089cf6c806e34ef1b6
2021-02-16 16:29:47 +01:00
Alexander Couzens e052c411e2 gprs_ns2: fix comment of alive NS-VC
There is no active NS-VCs only alive or dead.

Change-Id: Idb5d2ae4a99a472e38601ff841b8046ecf89d1bc
2021-02-15 10:40:54 +00:00
Alexander Couzens c470476923 gprs_ns2: add signalling & data weights for UDP binds
Allow to assign a signalling and data weight to UDP binds.
Those weights will be used when doing dynamic configuration over
IP-SNS.
This is only the first part which only uses the assigned weights
when doing a new SNS configuration.
The outgoing change weight procedure will be supported in a later patch
when the SNS fsm supports outgoing procedures.

Related: SYS#5354
Change-Id: I5133e4229377d44772a9af28628a2bc420fea34b
2021-02-12 03:34:32 +01:00
Alexander Couzens be7cecc753 gprs_ns2_sns: rework tracking of NS-VC unblocked/alive state
The SNS must know when all NS-VC have failed. Further more
there might be a corner case when the SNS configuration succeeds but
no NS-VC comes up afterwards.

Related: OS#5355
Change-Id: Ie72da9adeefe0c2850d49a9208b2d0a4556f9101
2021-02-09 15:42:01 +00:00
Harald Welte 76346079e8 ns2: Introduce a per-bind stat_item group with backlog length
The backlog length indicates the instantaneous length of the backlog.

Change-Id: I1c55b4619b1221d7e607ace58649323407faf86b
2021-02-01 09:39:29 +01:00
Harald Welte 97ccbf71b3 ns2: Rename nsi->rate_ctr_idx to nsi->nsvc_rate_ctr_idx
We will soon get another of those indexes.

Change-Id: I68a2ef3b48097f524831dd04821824b21d6d1e18
2021-02-01 09:39:29 +01:00
Harald Welte c3aa8f903a ns2: Move to one common/shared ns2_bind_alloc()
Avoid code duplication between three different drivers by sharing
the "core" of the bind initialization in a new, shared ns2_bind_alloc().

Change-Id: I535fc68e94fcd695de827dd922706adc1c5a2cb7
2021-02-01 09:39:29 +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 f22ae5af5f ns2: count number of dropped packets / bytes on transmit
Differentiate between successfully transmitted packets/bytes,
and pacets/bytes that were dropped (i.e. overflow of net-device)

OsmoNSdummy# show ns nsvc 1001 stats
 NSVCI 01001: UNBLOCKED PERSIST data_weight=1 sig_weight=1 fr)netif: hdlc1 dlci: 1001
  NSVC Peer Statistics:
   Packets at NS Level  ( In):       36 (0/s 8/m 32/h 0/d)
   Packets at NS Level  (Out):    23344 (170/s 20556/m 13119/h 0/d)
   Dropped Packets      (Out):    30692 (230/s 27056/m 17221/h 0/d)
   Bytes at NS Level    ( In):      262 (0/s 24/m 250/h 0/d)
   Bytes at NS Level    (Out): 32741312 (238680/s 28849400/m 18391024/h 0/d)
   Dropped Bytes        (Out): 43014628 (322920/s 37986624/m 24101344/h 0/d)

Change-Id: If21906ff5379038f7be10cf48c68d1f756dd7c1e
2021-01-31 12:34:36 +01:00
Harald Welte 3d5eaee726 ns2: Use named array initializers to avoid mistakes
It's always a bad idea to have an array of descriptions that's indexed
by an enum, without using named initializers.  It's too easy to get
inconsistencies.

Change-Id: Id0ebd2a202a465ca0298f4245f1fb5c495235fc8
2021-01-31 12:34:36 +01:00
Alexander Couzens 2e1a3a982a gprs_ns2: remove api call gprs_ns2_dynamic_create_nse
The call was only introduced as workaround for the first implementation
of vty. There is no need for this anymore. The configuration can
just add "accept-ipaccess" to the bind to allow creation of dynamic
ipaccess NSE.

Change-Id: Ie924ead6da17657f3da334068c8ada82c8845495
2021-01-28 13:54:32 +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 ba5a9927b6 gprs_ns2: drop GPRS_ prefix of gprs_ns2_cs
gprs_ns2_cs is a privat enum while GPRS_ should only used
for public enums.

Change-Id: I79be92ca716366c2e07ea061c08d95bea817a8c7
2021-01-25 16:03:23 +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
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
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
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
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
Alexander Couzens 8a2a1a4959 gprs_ns2: rework frame relay load distribution function
For frame relay the traffic will be even distributed across
all NS-VCs. Do not differentiate between signalling and
data traffic.

Change-Id: I6c060941db335a7a6a555ac8d1b9269fa8fb2023
2020-12-26 18:43:08 +01:00
Alexander Couzens 412bc3494d gprs_ns2: add new vty2
Change-Id: I163279cf57e84198dc8c53e1c109f5a9474670e9
2020-12-22 16:36:19 +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 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 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 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 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
Harald Welte 53a2fde368 Integrate libmnl (minimal netlink) library with libosmocore select loop
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
2020-12-02 21:04:51 +00:00