Commit Graph

82 Commits

Author SHA1 Message Date
arehbein 80006472ad ns2: Improve code consistency
- Use defines instead of repeating string literals
 - Use enum for indexing same data everywhere consistently

Related: OS#5915
Change-Id: I11c926dd4125c6657ae3cd21d8038f161d9fd9c3
2023-12-14 01:12:26 +01:00
Daniel Willmann 3236fdffd6 ns2: Add VTY option to change the max write queue size for UDP
Ensure that existing binds are updated as well.
In some cases the default max length of the osmo_io txqueue could be too
small. Set it to 128 by default and add a VTY option to change it for
an NSI (program-wide).

Change-Id: I993b87fd6b83b3981f5e293f70b931075afec715
Related: SYS#6550
2023-08-30 09:18:35 +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 d13faaa968 gprs_ns2: add vty `nse <0-65535> restart sns`
Allow to restart SNS procedure and initiate a SNS-SIZE procedure with Reset.
SGSN side SNS restart will stop answer on ALIVE and is sending NS STATUS
invalid protocol state.
BSS side SNS restart will send a SNS Size procedure to reset the state.

Change-Id: Icb55d8449908d348ab10572eebcf971737fba00d
2022-08-06 17:12:07 +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 5e040bf1f1 gprs_ns2_vty: dump_nsvc: change output depending on NSVCI
If the NSVCI is valid, there is no signalling or data weight defined (internally this is 1).
For NSVC with NSVCI don't print the signalling or data weight.
For NSVC without NSVCI, don't print NSVCI at all.

Related: OS#5180
Change-Id: Iaadc806a9136436468e2b02eb0bc1f4570a10ecc
2021-07-06 09:50:23 +00:00
Alexander Couzens 56287d26fe gprs_ns2: use gprs_ns2_free_bind() to clean up a bind
gprs_ns2_free_bind() takes care of all required steps to clean up a bind.
The driver->free_bind() operation only cleans up the driver internal state
but not NSVCs and other generic things.
Fixes a crash when free'ing a bind from the vty which has active NSVCs.

Related: OS#5195
Change-Id: I0a2ad22905bcacb929b9b5f5b034af0da3081826
2021-07-06 11:21:30 +02:00
Alexander Couzens d5cd8c61cb gprs_ns2: use llist_add_tail to keep order
When configuring multiple NSE/BINDs the order of the configuration
should be keeped.

Related: OS#5181
Change-Id: Ibbc03f0780b49543b5bd97ee059f11cfd6c2a126
2021-06-25 08:12:39 +00:00
Alexander Couzens 15596899a3 gprs_ns2: vty: fix removing a bind from a SNS
Return 0 after removing a bind. Otherwise the vty would return a
wrong error to the user.

Change-Id: I088c18abafc82ae7bd7b8c487ad9e9b448c42ba9
2021-05-23 10:32:40 +00:00
Harald Welte 5782fec9ff ns2: change the 'priority' setting name to 'socket-priority'
This has been changed based on feedback from Pau Espin in osmo-mgw,
and for consistency we also adjust it here.  No backwards compat
needed as it was just introduced yesterday.

Change-Id: I88989dc17c8996609b895c43012f8cca98aa81dc
2021-04-29 21:29:48 +02:00
Harald Welte d99e4eee2b ns2: Allow setting the socket priority for a UDP bind
Change-Id: Ifdfa086ce1c8d62b256abb3454b70cf53da9dcdb
2021-04-29 19:55:34 +02:00
Harald Welte c96d716606 ns2: Fix setting the DSCP value.
DSCP is a 6-bit value (0..63) stored in the upper 6 bits of what was
formerly known as TOS bits.  We must
* make sure the user can only specify 0..63
* shift the value by two bits when using the IP_TOS socket option

We achieve the latter by using the recently-added osmo_sock_set_dscp()
helper.

Change-Id: I64fee56b04d0ecd128bf661699d5071817ea96ec
Closes: OS#5136
2021-04-27 21:57:52 +02:00
Harald Welte 069967be86 ns2: Dump frame relay state to VTY during "show ns"
When doing a "show ns", let's also dump the state of the frame
relay network, with all its links and DLCs (if any).

Change-Id: I798af3e97dc014b6e0fcde86560a1809852f7510
Related: OS#4877
2021-04-25 21:09:23 +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 27e5873c8d gprs_ns2: add vty command `nsvc <nsvci> reset`
Change-Id: I436dd0367e83548acfc8f8e36ae4707496a252d9
2021-03-24 15:42:45 +00:00
Alexander Couzens 1dd9cbf45e gprs_ns2: dump_nsvc: correct indention
As both `show ns entities` and `show ns binds` looking similiar
correct the indention.

Change-Id: I55794188bec7e62f0341188dbf23ac04006974fe
2021-03-24 15:42:45 +00:00
Alexander Couzens 0ea4a4e0c4 gprs_ns2_vty: make the `show ns entities` and `show ns binds` look similiar
`show ns binds` prints a count of NSVCs. Add the same line
to `show ns entities`.

Change-Id: I15c58a1c0fe94dda728afb29e7e5ca41e3fa8966
2021-03-24 15:42:45 +00:00
Alexander Couzens 3e539ed127 gprs_ns2_vty: hide dynamic NSE information when ask for persistant only
dump_nse() should only print persistant NSE when persistant_only
argument is set. A NSE can be persistant or dynamic configured.
Depending on the NSE all NS-VC must be the same as the NSE.

Change-Id: Ibd2c6962eda39a850ab61cf347063934378d2fdc
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
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 42e3646a98 gprs_ns2_vty: Permit VTY configuration of bind->accept_sns
Related: OS#3373
Change-Id: Ifb52cd245b10bf47d42d57d167d6d6c02b12ee12
2021-03-24 00:30:23 +01:00
Harald Welte 579699bc2d gprs_ns2_vty: Allow creating NSE in sgsn-role
Change-Id: I694fa6c80d04d13cb1afaae93a9ae43b6dfd2207
Related: OS#3373
2021-03-24 00:30:22 +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 2230a91711 gprs_ns2_vty: Clarify VTY help string wording
Change-Id: I7d70f8cc811c2f4aabf9fc00e4e612dfc4b031d3
2021-03-05 17:08:00 +01:00
Alexander Couzens 7bb39e368d gprs_ns2: ensure no duplicate UDP NSVC can be created
Change-Id: I58a95817e2730bbbaa851a43a5b072d1de2db037
2021-02-19 10:41:50 +00:00
Alexander Couzens bf5d0dbdec gprs_ns2_vty: add optional argument signalling and data weights to `nsvc udp`
A static configured UDP NSVC can have signalling and data weights

Related: SYS#5354
Change-Id: Id363937c64e786c55e3136401ebdb44052415e0f
2021-02-19 10:41:50 +00:00
Alexander Couzens 6b9d232421 gprs_ns2: rework IP-SNS binds
Introduce a `ip-sns-bind BINDID` vty command within a `nse` vty object.
The ip-sns-bind defines the binds which will be used by the dynamic
configuration with IP-SNS.
This is only the first part which only uses the binds when doing a
new SNS configuration.
The outgoing add procedure will be supported in a later patch
when the SNS fsm supports outgoing procedures.

This is a behaviour change of the API and must be synchronized with
the osmo-pcu. Otherwise SNS won't work with osmo-pcu.

Related: SYS#5354
Change-Id: I9ab8092bf286e7d90e92f5702a5404425e959c84
2021-02-19 10:41:50 +00:00
Daniel Willmann 64db6366fd ns2: Fix incompatible VTY configs when writing config
It seems like we still don't have NS2 VTY tests running in libosmocore
so this only got caught once osmo-sgsn/osmo-gbproxy builds failed.

Change-Id: Id3cd407b05457a4703ee38c4b1b1b65800bbd30e
Related: OS#4887
2021-02-12 12:25:30 +01:00
Alexander Couzens b7921738be gprs_ns2_vty: use strcmp() instead of strncmp()
Otherwise substring wouldn't be detected.
E.g. local vs local2

Change-Id: I183b5176a1d8a295b7551ad186b3565adeb3d5e7
2021-02-12 08:57:34 +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 3e2e4a017a gprs_ns2_vty: fix memory leak of vty_binds
They never got freed, only removed from the vty_bind queue.

Change-Id: I100897c32dc152f9acbb322782fae49b1f0bc030
2021-02-09 16:48:03 +01:00
Alexander Couzens 5fa431ccd5 gprs_ns2: rename vty-command ip-sns -> ip-sns-remote
In prepration to introduce more commands e.g. ip-sns-bind rename the ip-sns-remote

Related: SYS#5354
Change-Id: Ida979f3b9daa5f7280a629441e4006a7635653b0
2021-02-09 16:48:03 +01: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 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
Daniel Willmann 9043205cd9 ns2: Fix assert when removing a bind listen
Change-Id: I3edd1e838f7516d9224045710047419039aa0ec0
Fixes: OS#4977
2021-01-29 11:37:41 +01:00
Alexander Couzens 260cd52bd0 gprs_ns2: correct vty config write
The vty configuration was wrong when any other node was
in between the vty configuration (e.g. gb or ss7).
The vty code doesn't have a relation between parent and child node.
It wasn't detected because this only happened in the sgsn.
The pcu doesn't have any binds defined.

Change-Id: I8a3d67d41baca36b4d1a951a574cd41e556355c5
2021-01-28 20:32:51 +01:00
Alexander Couzens e43b46e018 gprs_ns2: introduce gprs_ns2_vty_init_reduced() for the PCU
The gprs_ns2_vty_init_reduced() call initialized the ns2 vty without
configuration nodes (except timeout). The PCU can be only configured
by the BTS/BSC. It should not configured by vty.

Change-Id: I4437da74bd48ba64d3f16ea67afc26c45b6d3ac9
2021-01-28 13:54:32 +01:00
Alexander Couzens da1bf8e835 gprs_ns2: drop gprs_ns2_vty, rename vty2 -> vty
Drop the vty(1) code and replace it with vty2. The vty(1) was only
used as intermediate to not develop a vty while developing a new
code base behind. Users of gprs_ns2_ has to use the new vty code.

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

Change-Id: Ic2059e75d8ede8e5c29c4fef6be608ed79c8a97c
2021-01-28 13:54:24 +01:00
Pau Espin caf5317412 Revert "gprs_ns2: drop gprs_ns2_vty, rename vty2 -> vty"
This reverts commit b306094448.

It was merged too quickly and patches for projects using related
features are not yet prepared.

Change-Id: I8a2aaf74a47de8f4f0adb37d16426d199788e3fe
2021-01-28 13:38:23 +01:00
Alexander Couzens b306094448 gprs_ns2: drop gprs_ns2_vty, rename vty2 -> vty
Drop the vty(1) code and replace it with vty2. The vty(1) was only
used as intermediate to not develop a vty while developing a new
code base behind. Users of gprs_ns2_ has to use the new vty code.

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

Change-Id: I8c3f2afecc74b78f7f914f7dce166cbcb63444eb
2021-01-28 11:56:37 +00: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 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
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 280ed789a8 gprs_ns2: fix force-unconfigured for IP-SNS NSE
The IP-SNS need to do a reselection of the IP-SNS remote
for testing. Freeing all nsvc will force this.

Change-Id: I367c215a830c02eae2a470cba314828b5e0fb5c9
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
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
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