Commit Graph

41 Commits

Author SHA1 Message Date
Daniel Willmann d71aa6bf20 gbproxy_peer: Add rate counters when forwarding packets fail
Change-Id: I7fa972ba843993dac84241c04d66d5b7e2a0b40f
2022-03-03 18:15:24 +00:00
Daniel Willmann f9902c5c05 gbproxy: Remove duplicate struct gprs_ra_id handling
The ra_id as well as the cell_id are already present in struct
gbproxy_cell which is reachable from bvc->cell. Remove the ra_id in
struct gbproxy_bvc and also remove some unused/unneeded code. The FSM
reset_notif callback already takes care of updating the cell.

Related: OS#4894
Change-Id: Ibc9f42a60706612c17e5f8f0468c7faced5ae4c8
2021-11-12 16:32:28 +01:00
Daniel Willmann dc763fdf39 gbproxy: Avoid sending STATUS on unexpected BLOCK_ACK
Handle SGSN BVCs that are gone from the BSS differently.

The previous patch removed the gbproxy_bvc on the SGSN-side after it was
gone on the BSS-side. This caused a STATUS response to BVC_BLOCK_ACK messages
that should be valid. Instead of removing the BVC this patch marks it as
inactive so we can still handle BVC_BLOCK_ACK correctly, but ignore
other messages - especially BVC_RESET from the SGSN.

Related: SYS#5628. OS#5236
Change-Id: Ic9f34a27412d6e15ca1198ee140f66a076b5c6b6
2021-09-29 11:35:06 +02:00
Daniel Willmann a631a3a268 gbproxy_peer: Free a cell as soon as no BSS BVC uses it
This patch adds gbproxy_cell_cleanup_bvc() which removes the bvc pointer
to the cell. If the BSS BVC of this cell is removed it frees the whole
cell (removing all the SGSN BVC pointers to the cell). The SGSN-side
BVCs are blocked at this point and will only be reestablished if this
BVC is reset again from the BSS.

Before this patch cells were never freed and might accumulate over time.
They would only be reused if the bvci matched that of a previous cell.

Related: OS#4960
Change-Id: Ib874cbebcea58fa4bf15e1ff40fe11601573e531
2021-07-16 19:15:09 +02:00
Daniel Willmann f024eeb9e7 gbproxy: Forward MS_REGISTR_ENQ/_RESP correctly
We need to save the BSS NSE <-> IMSI mapping to correctly route the
answer.

Related: OS#4472
Change-Id: I1908bbe8db11271dbd3f45b0d9f1bc0bfe48f239
2021-07-09 19:04:56 +02:00
Daniel Willmann 361d0b566a gbproxy: Add usage flag to the imsi_cache
This is only used for the imsi cache entries for now. Further uses will
be added in subsequent commits.

Related: OS#4472
Change-Id: I4a4b8c99eb97f6bb5387d0f26aecd861e07d9914
2021-07-09 19:04:47 +02:00
Daniel Willmann 37518b3409 Don't route messages to an SGSN if it is down
If an SGSN in a pool is down we expect the messages to instead be sent
to a different SGSN in the pool. That SGSN will not necessarily know
what to do with those messages, but it should (implicitly) detach that
UE so that it can reattach at the new SGSN. Otherwise UEs on a failed
SGSN would simply stop working as the messages would never be forwarded
anywhere.

Fixes: OS#4952
Change-Id: I3f794659866e1f31496a39ca631b3b042a60aa27
2021-05-28 17:20:44 +02:00
Daniel Willmann a16ecc34cc Remove osmo-sgsn relics
* include/osmocom/sgsn -> gbproxy
* (unused) tests specific to osmo-sgsn

Change-Id: I3704760e8936bdd005a3f73727de5f2b3e8774a0
2021-03-10 13:52:07 +01:00
Daniel Willmann 04075ec198 gb_proxy.h: Use pragma once instead of ifndef
Change-Id: I7eb3b1cbd78c25112abf7d526a2aa42bd952c7c9
2021-03-10 12:11:03 +00:00
Daniel Willmann 429c43ce45 Remove some outdated TODO/comments
Change-Id: Icd72ed92585f5701d293807022255b06e5641005
2021-03-10 11:27:13 +00:00
Daniel Willmann a8b61659e6 Add SDU length for an NSE (== BSSGP PDU size)
Prepare tracking the SDU from NS. Initialize with a conservative default.
The value is not yet updated, that will happen in a later patch.

Related: OS#4889
Depends: I5016b295db6185ec131d83089cf6c806e34ef1b6 (libosmocore.git)
Depends: I9bb82ead27366b7370c9ff968e03ca2113ec11f0 (libosmocore.git)
Change-Id: Ic1080abde942ec5a2ae7cdee0ffe716a2fbddb1e
2021-02-16 16:39:45 +01:00
Philipp Maier e4597ece46 gb_proxy_peer: Require ra_id and cid in gbproxy_cell_alloc
pass raid and cell id directly as parameter to gbproxy_cell_alloc so
that we do not need to fill tas parameter to gbproxy_cell_alloc so that
we do not need to fill the struct members later.

Change-Id: Ic7deae5ccf839b941d70557d28451d52f32cebbb
Related: SYS#5103
2021-02-09 22:45:27 +01:00
Daniel Willmann fccbef0a28 gb_proxy_peer: Add Function to get gbproxy cell by cell id
Change-Id: I3403736eed9d6819634c26db0b90393ac6f4416a
Related: SYS#5103
2021-02-09 13:32:52 +01:00
Philipp Maier da3af94bf8 gb_proxy: simplify raid data storage
Instead of storing the raw ra_id in its unparsed binary form, store it
as a parsed struct. Also store the cell-id on cell allocation for later
use.

Change-Id: Ib58b9188e3ce4bd3fdadb03f158d56b29778387c
Related: OS#4894
2021-02-09 13:32:31 +01:00
Oliver Smith 29532c2a06 === Split osmo-gbproxy from osmo-sgsn ===
Adjust the build system, packaging etc. to split osmo-gbproxy into its
own git repository. Remove tests and configs that aren't related to
osmo-gbproxy.

Related: OS#4992
2021-01-29 16:57:29 +01:00
Daniel Willmann c8a500983a gbproxy: Implement IMSI cache
When SGSN pooling is enabled we need to route some responses based on
IMSI back to the correct SGSN, e.g. PAGING_PS_REJECT.

The IMSI cache keeps track of this IMSI <-> NSE(SGSN) mapping.

Change-Id: If0a8d6cc1d63f2fb2c395cc5d4373a915bc2cb87
Related: OS#4951, OS#4472
2021-01-17 13:51:57 +01:00
Daniel Willmann 77493b1b26 gbproxy: Implement TLLI cache and use it for SUSPEND/RESUME
When routing a SUSPEND/RESUME we need to keep track of where it came
from so we can send the (N)ACK back to the correct BSS. Use the TLLI
which is present in both messages to cache and retrieve the correct BSS.

A timer runs every two seconds and expires entries that are older than
the timeout (hardcoded to 5 seconds for now).

Related: SYS#4865, OS#4472
Change-Id: I42adf70f560d2bb358a9e1c7614281e8d2967568
2021-01-11 15:09:05 +01:00
Daniel Willmann b387c1ee93 gbproxy: Add VTY command to override the node selection function
This is mainly useful when testing SGSN pooling

Change-Id: I2894320413dbd0b9aec9a9bc9b88ce7cdeed206b
Related: SYS#5115, OS#4472
2021-01-04 18:33:52 +01:00
Daniel Willmann a648f3c676 gbproxy: Add config option to name an SGSN
This is useful for logging and configuration to identify an SGSN by name

Change-Id: I2a3410dd9bebb242957e13a63ed70e447204203c
Related: SYS#5115, OS#4472
2021-01-04 18:33:52 +01:00
Daniel Willmann d4ab1f98bd gbproxy: Add SGSN pooling support
Change-Id: I58b9f55065f6bd43450e4b07cffe7ba132b1fd9b
Related: OS#4472
2020-12-29 16:41:29 +01:00
Daniel Willmann ee834af5d9 gbproxy: Add SGSN NRI configuration
In order to support SGSN pooling we need to configure the various NRI
parameters such as the bitlen, NULL NRI, and which NRIs are assigned to
which SGSN.

Related: OS#4890, OS#4472
Change-Id: Id67592aa7712e5e04e7264b2fb8f26d57eb7e69e
2020-12-29 16:38:49 +01:00
Harald Welte 209dc9fa73 gbproxy: Implement scaling of BVC flow control in SGSN pool
When there are multiple SGSNs inside a pool, we need to decide
how much of the per-BVC capacity advertised by the BSS in its
BVC-FLOW-CONTROL we should announce to each of the pool members.

A conservative approach would be to advertise 1/num_sgsn, but
there may also be use case where over-provisioning (announcing more
than an equal share of the capacity) is useful.

Hence, let's introduce "pool bvc-flow-control-ratio <1-100>" in order
to allow the administrator to decide.

Related: OS#4891
Change-Id: Ibe5addf657e7237499ca0205bacfe999ecd1e771
2020-12-12 19:12:18 +01:00
Harald Welte cfc7e8e8b9 gbproxy: Introduce new DOBJ log category; log object allocation/release
Related: OS#4472
Change-Id: I43bcbcda8667d193e7a17fd8e8e9109597b01484
2020-12-10 18:06:34 +01:00
Harald Welte e520964dc2 gbproxy major rewrite for SGSN pool support
Rewrite of a large part of osmo-gbproxy in order to prepare
for SGSN pool support.  The amount of changes are of such fundamental
nature that it doesn't make sense to try to split this into hundreds
of individual changesets.

Related: OS#4472
Change-Id: Ie0746f17927a9509c3806cc80dc1a31d25df7937
2020-12-10 18:05:52 +01:00
Harald Welte 7a0c9ddab0 gbproxy: Remove patching, TLLI-tracking and SGSN2 support
Those features were introduced a long time ago for one specific use
case at one specific user, and they are not needed anymore.  They
complicate the code base significantly and are hard to maintain with
all the upcoming modifications regarding SGSN pool supoprt.

Change-Id: Id9cc2e1c63486491ac5bb68876088a615075fde6
2020-12-05 14:05:36 +01:00
Harald Welte 8b4c794679 gbproxy: convert nse->bvcs from llist_head to hashtable
For the common lookup-by-bvci, this should reduce the computational
complexity significantly.

Depends: libosmocore.git I8ef73a62fe9846ce45058eb21cf999dd3eed5741
Change-Id: Ic8e9279fd61a3c514fc3203429f36a468f0e81d3
2020-12-05 13:55:06 +01:00
Harald Welte d2fef95945 gbproxy: convert bss_nses from llist_head to hashtable
For the common lookup-by-nsei, this should reduce the computational
complexity significantly.

Depends: libosmocore.git I8ef73a62fe9846ce45058eb21cf999dd3eed5741
Change-Id: Idbb6a362332bb6e3ce22102e7409ae80d0980f44
2020-12-05 13:49:37 +01:00
Harald Welte 2b7b1bbbdc gbproxy: Rename gbproxy_cfg.nses to gbproxy_cfg.bss_nses
We will soon also have a list of sgsn-side NSEs, and we need to
differentiate those.

Change-Id: If5accec0c70c01b88927ea07beba6f6488bd9d5a
Related: OS#4472
2020-12-05 12:08:10 +01:00
Harald Welte 560bdb37cc gb_proxy: Rename gbproxy_peer to gbproxy_bvc
I cannot really read the code while it contains its historical weird
naming.  A "peer" used to be a strange amalgamation of NSE + BVC,
while in reality we can have any number of BVC on top of each NSE.

We recently started to split the peer into a gbproxy_nse_peer + gbproxy_peer.
This takes it one step further and renames gbproxy_peer to gbproxy_bvc,
as that's really what it is.

Change-Id: Iae01067282a6401f6af4cab731202872d2cdb080
2020-12-05 12:06:42 +01:00
Daniel Willmann 8f407b12a6 gbproxy: Add BVC log filters
Since gbproxy doesn't use bssgp_rcvmsg from libosmocore we need to
implement our own filtering.

Change-Id: I4d1b57b89990945d307f27a58a7f630be0253d5b
Related: SYS#5232
2020-12-04 01:31:05 +01:00
Daniel Willmann 066c4cb8c5 gbproxy: Add logging macros for NSE and BVC
Change-Id: Ibb2bcf3344bdc750869223b4c4861b4bbc6f417c
Related: SYS#5233
2020-12-02 17:17:17 +01:00
Daniel Willmann 559edac17a gbproxy: Separate function to move gbproxy_peer to different nse
Change-Id: I0a8b1e4b78384ea99d50109f050ca501b18ba5d9
Related: SYS#5226
2020-11-30 18:30:35 +01:00
Daniel Willmann e50550e409 gbproxy: Add NSE peer that can have multiple gbproxy_peers
We want this level of indirection to support multiple BVCs per NSE. The
current code assumes that an NSE only has one BVC which breaks messages
on the signalling BVC which should only be sent once to an NSE
regardless of the number of BVCs it contains.

Change-Id: I97cc6c8f8c0f1b91577ab8f679c4ae217cc88076
Related: SYS#5226
2020-11-30 18:30:35 +01:00
Alexander Couzens 951e133d17 Port gbproxy to NS2
Since NS2 has a different abstraction we mock up the prim send/recv
functions and don't test NS like the old tests did.

Related: SYS#4998
Change-Id: Iecfd0408a35a11638d254c1db3c1d477b1a11524
2020-11-06 18:45:05 +01:00
Harald Welte bec7041161 gb_proxy: cosmetic: Use 'bool' in data structures where applicable
If we ever only use 0/1 in an 'int', we should have used 'bool'.

Change-Id: I63876f52d5de87e4c99d92669270fd1f487e217c
2019-04-24 15:43:26 +02:00
Harald Welte 4a8769a057 gb_proxy.h: Add missing comments; improve comments
When the patching and routing features were introduced, a lot of the
new structures were not documented at the same level as the pre-existing
code.  Let's fix that.

Change-Id: I61bdd3b1cec037bce825c234a8a274b70629adc8
2019-04-24 15:43:26 +02:00
Pau Espin e0d647fccb gbproxy: Add new VTY-managed timer: link-list clean-stale-timer
This timer allows periodically cleaning up stale links in link-list of
each gbproxy_peer. Previous to this patch, this kind of cleanup
(gbproxy_remove_stale_link_infos) was being done only as a consequence
of external events being triggered, such as a message from that peer
being received.
It was found in a production network agreggating several BSS that some
of them were offline for a longtime but gbproxy was still caching big
amounts of really old link_info for the NSEI assigned to those BSS,
because since they were probably turned off abruptely, no new messages
were received from it which would trigger the cleanup.
As a consequence, it has been observed that a timer to periodically
clean up old entries (link-list max-age) is requird in case w don't
receive messages from that NSEI periodically.

Related: SYS#4431
Change-Id: Ic777016f6d4f0e30fb736484774ca46878f17b7a
2018-08-17 14:13:47 +00:00
Pau Espin 0248524df0 gbproxy: Add VTY parameter: link stored-msgs-max-length
It was discovered in some prod setups that some TLLIs can maintain quite
long queues of msgb in case its IMSI is not acquired and the tlli is not
pruned due to link-list max-{age,length} being set to 0. As a result,
the osmo-gpbroxy steadly increases the list size of maintained TLLIs, and
some TLLI was found without IMSI catching already 1211 msgb.

Let's allow setting a maxiumum length for the queue storing those msgb
in a per TLLI base. If the limit is reached, oldest msgb are removed
before adding a new one.

Depends: libosmocore Change-Id I33b501e89a8f29e4aa121696bcbb13d4b83db40f

Related: SYS#4297

Change-Id: I4473be8604f80302df03ffdd5a13280dc072f824
2018-08-17 14:13:24 +00:00
Daniel Willmann 13404b7fe0 gb_proxy: Add ctrl interface and nsvc-state, gbproxy-state commands
This patch adds a control interface to osmo-gbproxy as well as the first
two commands to query the state of each NSVC and gbproxy peer.

The "nsvc-state" command replies with
nsei, nsvci, local state, role, remote state of all NSVCs.

The "gbproxy-state" command replies with
nsei, bvci, mcc, mnc, lac, rac, and state of each peer.

Entries are separated by a newline '\n' character. If there are no
entries an empty list is returned. This behaviour is similar to that of
the subscriber-list-active-v1 command in osmo-sgsn.

$ ./osmo_ctrl.py -d 127.0.0.1 -p 4263 -g nsvc-state
Got message: b'GET_REPLY 23 nsvc-state 101,101,DEAD,BLOCKED,SGSN,DEAD,UNBLOCKED\n'
$ ./osmo_ctrl.py -d 127.0.0.1 -p 4263 -g gbproxy-state
Got message: b'GET_REPLY 4871085901306801158 gbproxy-state '

Change-Id: I82c74fd0bfcb9ba4ec3619d9fdaa0cae201b3177
Ticket: OS#3281, SYS#4235
Sponsored-by: On-Waves ehf
2018-06-15 07:33:46 +00:00
Neels Hofmeyr 6179f0ca36 implement support for 3-digit MNC with leading zeros
Add 3-digit flags and use the new RAI and LAI API from libosmocore throughout
the code base to be able to handle an MNC < 100 that has three digits (leading
zeros).

Note that in gbproxy_test.ok, 0-0 changes to 000-000 instead of 000-00, because
the parsed ra buffer is 000000 which results in 000-000, while 00f000 would
result in 000-00. IOW this is expected.

Change-Id: I7437dfaa586689e2bef0d4be6537e5577a8f6c26
2018-03-15 19:18:14 +01:00
Neels Hofmeyr 4b4c586f03 move include/openbsc to include/osmocom/sgsn
Change-Id: I281ef585fffc2644682c8282224fb1c2da5ca795
2017-09-06 16:47:47 +02:00