Commit Graph

53 Commits

Author SHA1 Message Date
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
Daniel Willmann eb9edbab54 osmo_io: Remove osmo_iofd_read/write_enable/disable
This API is not really used or needed, so remove it.
See discussion in https://gerrit.osmocom.org/c/libosmocore/+/33084

Change-Id: I0dbc14a8cbbdc7b6e4688942c0dac865bbd72c8b
2023-06-07 15:04:47 +02:00
Daniel Willmann 3ed87720b3 osmo_io: Don't make msg in write_cb const
This was discussed in a previous change, but the change was merged
as-is.

Change-Id: I8b4a2dd7a336dea5c52c9da6e78bbc4d5f2a02f8
2023-06-07 15:00:02 +02:00
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 f6ef9ba1e9 gb: ns2: Rename parameter name in gprs_ns2_nsvc_by_sockaddr_bind()
The old name seems to describe that this function can only be used in
incoming message paths, but it can be used in transmitting context too,
so the param is actually a remote address.

Change-Id: I3f45a4ef339cadd47920ee3b36c38628b38221f6
2023-04-27 17:52:16 +02:00
Alexander Couzens 20ed591036 gprs_ns2_udp: don't start the NSVC fsm for SNS
The SNS code will always create NSVC on it's own. The only case
when the SNS dialect allows dynamic NSE/NSVC is on the SGSN side when accepting
dynamic NSE and receiving the first SNS SIZE. In this case the NSVC FSM must not be started yet.
Prevents sending NS_ALIVE before the SNS configuration has been
finished.

Change-Id: I86275c99432262b3c19c1ded9a77090b74303bc8
2021-08-13 09:55:51 +00:00
Alexander Couzens d794806719 gprs_ns2: rework id strings of nsvcs
Ensure all nsvcs ids are unique as UDP ids might not be unique when
multiple NSVCs connect to the same remote endpoint (multiple binds).
Change the format of all ids to look similiar.
FR: NSE11-NSVC23-FR-fr0-DLCI13.
UDP: NSE11-NSVC-UDP-10.0.0.1:23000-192.168.1.1:24000
UDP: NSE11-NSVC23-UDP-10.0.0.1:23000-192.168.1.1:24000
UDP: NSE11-NSVC66-UDP-[fd01::1]:23000-[fd03::2]:24000

Change-Id: I618e263e73fcc64d4e46b57aa3a2cb2783837907
2021-06-05 15:46:13 +00: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 485b3f7c85 ns2: migrate from osmo_sock_set_dscp() to OSMO_SOCK_F_DSCP()
The latter is much more compact than the former.

Change-Id: I2a24c0cbb17fad8ed84297267dcd63730efbc014
2021-04-29 15:54:59 +02:00
Harald Welte 628f534817 gprs_ns2: Fix yet another DSCP vs. TOS mix-up
This is a follow-up to I64fee56b04d0ecd128bf661699d5071817ea96ec,
due to code duplication there was another code path that manually set
the IP_TOS socekt option that I missed in the first patch.

Related: OS#5136
Change-Id: I4bb22d0f67984077706b694eb7e75327b41b6fcf
2021-04-29 09:02:25 +00: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
Alexander Couzens 8bd63b667e gprs_ns2: vty: remove a white space in `show binds`
Change-Id: Ia3579ec5599f5f5c58eebab03f1ed9e17f171177
2021-03-31 06:00:44 +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 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 7bb39e368d gprs_ns2: ensure no duplicate UDP NSVC can be created
Change-Id: I58a95817e2730bbbaa851a43a5b072d1de2db037
2021-02-19 10:41:50 +00: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 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 c80a874932 gprs_ns2: unify the handling of **result when bind already present.
All bind function should work in the same way.
Also fixing a null pointer assignment if no **result is giving.

Change-Id: Idd0c2190d2af39804c18c4786a997079db9a4330
2021-02-03 14:37:54 +01:00
Harald Welte bdfb8b9104 ns2: Memory allocation failures are ENOMEM, not ENOSPC
ENOSPC is used with non-volatile (disk) storage, while ENOMEM is
customarily used for RAM allocation failures.

Change-Id: Ia4c16d8278dc30c7cc69169b18428cda5272738d
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
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
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
Alexander Couzens ea37724b3c gprs_ns2: allow to use free_vc() with NULL
Usually talloc_free() and other free functions in osmocom allows
to be called with NULL which is then ignored.

Change-Id: If7b0c6916a29d4611d0a40c388414076eb83e6b5
2021-01-19 19:33:41 +01:00
Alexander Couzens 55bc86931e gprs_ns2: add assert on most bind calls
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
2021-01-19 19:33:41 +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 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 1e72df0208 gprs_ns2_udp.c: Fix typo - it's a DSCP and not a DCSP
also, acronyms are typically all-caps.

Change-Id: Ia12d1fd66348f0b317405f46589f041045c513a2
2020-12-01 18:21:17 +01:00
Harald Welte 96ec84a035 gprs_ns_vty: Unify display of NSVCI on VTY in 'show ns entities'
Change-Id: I2915b47a5fc4ed9ac16f611c9e9f71dc0955426a
2020-12-01 18:01:43 +01:00
Alexander Couzens aac9016570 ns2: move link layer type into NSE
Even it was in theory possible to mix NS-VC ll types within
a NSE. This is an unrealistic configuration.
Further more to select the correct load sharing mechanism
the NSE must know the correct link layer.

Change-Id: I18dfd40a2429cd61b7c4a3dad5f226c64296f7d8
2020-11-24 03:53:22 +01:00
Alexander Couzens 24a14ac80c ns2: move LL into public api
Also fix prefix. GPRS_NS -> GPRS_NS2.
In preparation to move LL into upper layer.

Change-Id: I3b5e0d51ce69b095095e5160ca0cf0d4534db1b8
2020-11-24 03:53:22 +01:00
Alexander Couzens c06aa710d0 ns2: check if ns_vc_alloc() fails in bind_connect()
Change-Id: I82c984b9808451a72a62ff03b0495a1d09473e1c
2020-11-20 08:51:19 +00:00
Alexander Couzens cce8828238 libosmocore: change the memory management of NS2
Until now NS2 always free'd it's own memory. Even when the msg
was sent as primitive to the upper layer.
Change the memory ownership when sending a primitive to the upper layer.
The upper layer has to free the msg buffer.

Merge together with: I180433735bfbb3375c41318d7a7709d5845199ba (osmo-pcu)

Change-Id: Id844d7acbcab102a7dc472d608a5e97a748ecb43
2020-11-03 22:37:45 +00:00
Alexander Couzens d420ea9dce gprs_ns2: add gprs_ns2_ip_vc_equal()
Compare the NS-VC with the given parameter

Change-Id: I3a0cd305fd73b3cb9ec70246ec15ac70b83e57f2
2020-10-12 15:13:43 +00:00
Alexander Couzens d33512b997 gprs_ns2: gprs_ns2_ip_vc_remote() the nsvc can be also const
Change-Id: Ia000f535f18f21b41038f2ce7721f0fb59f6a093
2020-10-12 15:54:21 +02:00
Alexander Couzens 979f5f5449 gprs_ns2: add gprs_ns2_ip_vc_local() return the local sockaddr
Change-Id: I65a739772596015b90473045d32d4934d924e43f
2020-10-12 15:54:21 +02:00
Alexander Couzens c4229a458c gprs_ns2: rename gprs_ns2_ip_vc_sockaddr -> gprs_ns2_ip_vc_remote
It's more clear which part of the address is returned.
In preparation to add a gprs_ns2_ip_vc_local.

Change-Id: I6110ff573362961c713a990da7ef3f3dbedf6c57
2020-10-12 15:54:21 +02:00
Alexander Couzens 9a4cf275b2 gprs_ns2: const the return value of gprs_ns2_ip_vc_sockaddr / gprs_ns2_ip_bind_sockaddr
The sockaddr should not be changed.
free and create the bind/nsvc if the address should be changed.

Change-Id: I371ac2361b569e36722b02fc9cd82ec8da2fa9e3
2020-10-12 13:08:42 +00:00
Alexander Couzens 6090b1db4b gprs_ns2: gprs_ns2_ip_bind() check if the bind already exists
To prevent adding the same bind twice. It also returns
the bind in **result.

Change-Id: Ib816f14c387cc6ff86f9c0057daded1d72cee0f5
2020-10-12 13:08:42 +00:00
Alexander Couzens 4f60845552 gprs_ns2: add gprs_ns2_ip_bind_by_sockaddr() to search for binds by sockaddr
Change-Id: I48c3f1a82574eee0a49e6941cf9e1365c2302d3b
2020-10-12 13:08:42 +00:00
Vadim Yanitskiy a07f25e3ba gprs_ns2: make struct osmo_sockaddr pointers const
Using the 'const' qualifier allows the compiler to spot some
programming errors and further optimize the code.

Change-Id: I0df6a00ac1830bd64a10b9336b827e113fa772bb
2020-10-09 15:24:09 +00:00
Pau Espin aa83d4110b gprs_ns2_udp: Avoid dangling freed struct in list if binding fails
Change-Id: Ic54434b7cfc40136788257e768cae7a2b5d5bc79
2020-10-09 14:20:13 +02:00
Alexander Couzens 22f34710d9 ns2: vty: on `show ns` add information of NS binds
Change-Id: I6cef42749555e577d5573f2ed8b8bce4cf842a98
2020-10-05 14:23:33 +00:00
Alexander Couzens 772ca6195e ns2: fix a msg leak when receiving REJECTED messages
Change-Id: I7edc53c29c3dd09c395a275ceb8648b8eb19c06c
2020-09-26 19:58:50 +00:00
Alexander Couzens 1301012837 ns2: refactor handle_nsip_read/handle_nsfrgre_read
Might be more readable.

Change-Id: Ib2dbcae55a8c7a973cfa1123784f509708de7f3b
2020-09-25 09:46:31 +00:00
Alexander Couzens ffd49d0757 ns2: ns2_recv_vc: remove unused parameter nsi
Change-Id: I0dbc079e83d37de01a4260442363ed5fdcd51d28
2020-09-25 09:45:24 +00:00