Commit Graph

6549 Commits

Author SHA1 Message Date
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 9151b4a7d5 gbproxy: Add "show gbproxy cell ..." VTY command
This allows the user to inspect CELL related gb-proxy state.

Change-Id: Iad1e8bbc358df9a3b3392404a70445a169dfebd5
2020-12-22 19:33:34 +00:00
Daniel Willmann 98b1b45b17 gbproxy: Fix confusing log message in gbprox_relay2nse
This function is now used to transmit messages in both directions,
BSS->SGSN and SGSN->BSS.
Print the actual direction in the logs

Change-Id: I31682156dfe88f7ca121a711968e625caed8bd5e
Related: OS#4472
2020-12-22 12:32:16 +01:00
Daniel Willmann 1e7be5d1f5 osmo-gbproxy: Initialize all hash_maps
Change-Id: I9578af77a7b2f61b57c918a703768ca20221c294
Related: OS#4472
2020-12-21 18:44:08 +01:00
Alexander Couzens ec323bd6bd sgsn: check for NULL of gprs_subscr_get_or_create()
gprs_subscr_get_or_create() can return NULL if no memory can
be allocated. Detected by the compiler on Ubuntu s390x.

Signed-off-by: Steve Langasek <steve.langasek@ubuntu.com>
Signed-off-by: Alexander Couzens <lynxis@fe80.eu>

Change-Id: I86b3652d46bdd581fe6cbab16b52395a0daaa082
2020-12-15 11:57:16 +01:00
Harald Welte befe1c35af gbproxy: rename vty command "show gbproxy ..." to "show gbproxy bvc ..."
we have other objects to show, and the orthogoanl way to do this is
to rename the existing one.

Change-Id: I7836a37533a2de81720acedda712d61f429df12c
2020-12-14 12:21:17 +01:00
Harald Welte c6ecfadaaf gbproxy: Improve VTY state introspection
* allow to print not only BSS-side BVCs, but also SGSN-side
* differentiate between SIG and PTP BVC
* print the actual BVC FSM state name instead of just UNBLOCKED/nothing

Change-Id: I8e09a9dc296b15094d191b0451d04457c815d116
2020-12-12 19:12:52 +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 d10afca811 gbproxy: Add FSM related VTY commands
Change-Id: Id84ce52722d705eb25a12ee6f108ad3107a9f8d2
2020-12-12 17:33:49 +01:00
Harald Welte df690e819b gbproxy: Fix segfault when receiving PAGING for unknown destination
The 'nse' variable had been used both as the input argument of the
SGSN-side NSE, as well as a loop iteration variable.  Let's separate
this clearly.

Closes: OS#4904
Change-Id: I375a219cd72eb11a9a0cb7d55a3efb7b83b771ac
2020-12-12 16:16:57 +01:00
Harald Welte 664c24e30e gbproxy: (Re)allocate SGSN-side PTP BVC even if CELL already exists
After a SGSN-side RESET of the SIG-BVC, all PTP BVC on the SGSN side
are gone.  However, the CELLs and the BSS side BVCs continue to exist
(as there may be other SGSNs).

So if a PTP-BVC RESET from the BSS side arrives in such a situation,
and we can find a matching CELL, we still need to check if we need
to create any SGSN-side PTP BVCs instead of simply being happy with
the CELLs already existing.

Change-Id: I1d1562e421082fa4399c73ac31290e4c95718e49
Closes: OS#4903
2020-12-12 15:18:05 +01:00
Harald Welte ee0cc81a1a gbproxy: Copy RA-ID from BSS side BVC to CELL and SGSN-side BVC
Change-Id: I18669f269c4a959fcfa51885aafb719b662a7f8a
Related: OS#4894
2020-12-12 15:17:33 +01:00
Daniel Willmann 06331ac863 gbproxy: Fix bvci check in gbprox_rx_ptp_from_*
The check for bvci in _rx_ptp_from_* was always false.

Change-Id: I16a0284ba3201c146c307db6997a416589d7e693
Related: OS#4472
2020-12-10 18:11:47 +01:00
Harald Welte 85a4027fd0 gbproxy: Implement handling of BVC Flow Control
We must locally terminate + acknowledge any inbound BSSGP-FC-BVC,
and ourselves trigger the transmission of BSSGP-FC-BVC to each
SGSN in the pool.

Related: OS#4891
Depends: libosmcoore.git Ie59be6761177c43456898be9148727f15861a622
Change-Id: Ib6495e5de4bfcf748a98e08743d1a8f2565f8b69
2020-12-10 18:09:21 +01:00
Harald Welte dbef0aa210 gbproxy: Don't create an extra msgb copy for SGSN DL SIG
That copy may have made sense while we were doing patching/buffering,
but we're not doing any of that anymore.

Related: OS#4472
Change-Id: I207a869ffac8bf60104f80f9ed58faf0021e5e95
2020-12-10 18:08:58 +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 4bd3e49eb3 gbproxy: Use "(nsei << 16) | bvci" as rate_ctr_group index
As we now have gbproxy_bvc on both the SGSN and the BSS side
with the same BVCI, using the BVCI alone will no longer render
unique indexes.

Related: OS#4472
Change-Id: I13f3c9e69562a56ad7d3742fdeb2ba48f134fdaa
2020-12-10 18:06:06 +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
Daniel Willmann 822714d287 mm_state_gb_fsm: Handle implicit detach from mm_standby
Change-Id: I63d04a2dcdc17b4df6616c515641c435d919c787
Related: OS#2737
2020-12-10 15:25:51 +00:00
Harald Welte 4e15cf4670 migrate to DLBSSGP as log sub-system for BSSGP
Change-Id: I69ee10b6fad1da2053cf6f3ae99d3ecf62a144ce
Depends: libosmocore.git Change-Id I506190aae9217c0956e4b5764d1a0c0772268e93
2020-12-10 15:42:15 +01:00
Harald Welte c169de4fa8 gbproxy: Log FSM timeouts
Change-Id: I5c48e42083ab6f8622808457ca3f017adf35cdff
2020-12-07 18:30:01 +01:00
Harald Welte ec0f801dbe gb_proxy: Use osmo_tlv_prot_parse() to validate mandatory IEs
We recently introduced code to libosmocore which allows us to validate
the mandatory IE presence (and length) in a generic way.  Let's use it.

Change-Id: I0ea3f5f9566d9bf5a8429c3ee748e3e90cda6cd7
Depends: libosmocore.git I7e4226463f3c935134b5c2c737696fbfd1dd5815
2020-12-07 18:22:20 +01:00
Harald Welte 815f798251 gbproxy: use gbprox_relay2peer() whenever possible
gbprox_relay2peer() is a small wrapper around gbprox_relay2nse(),
but as it manages the transmit error counter, we should use it whenever
possible.

Change-Id: I85ab49ca0a25dd7c54b88c4fdc8838843e6d2209
2020-12-07 18:22:20 +01:00
Harald Welte 278dd27b8b gb_proxy: Introduce more validation / constraint checks
* ensure the BSSGP PDU header length before reading pdu_type field
* ensure we never process uplink PDUs in downlink and vice-versa
* ensure we never proceses PTP PDUs on SIGNALING BVCI and vice-versa

Change-Id: I6e40aed0283f1a0860ab273606605f7fb28717cf
Depends: libosmocore.git I7e4226463f3c935134b5c2c737696fbfd1dd5815
2020-12-07 18:22:20 +01:00
Harald Welte d09ffc2b89 gbproxy: Delete gbproxy_test
The test is actually performing invalid operations such as
sending empty NS packets without even a BSSGP header - and assumes
that gbproxy should route those.

Given that we have a much more comprehensive tset suite in
GBProxy_Tests.ttcn in osmo-ttch3-hacks.git, it makes sense to remove
the testsuite.  It may contain many more wrong assumptions, or
assumptions that no longer hold true with the "gbproxy 2020".

Change-Id: I053aebab6bf5d0ee955f2221bf27925b36140cf3
2020-12-07 18:22:20 +01:00
Harald Welte a0f7073f7a gb_proxy: cosmetic: Use function rather than open-coding is_sgsn
Change-Id: Id41d74ebd41e5084377a986f4a1acd53cae12bc1
2020-12-05 17:50:50 +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
Harald Welte 173a182d03 gb_proxy: Use TLVP_PRES_LEN instead of TLVP_PRESENT
With TLVP_PRESENT we only check if a tiven TLV/IE is present,
but don't verify that it's length matches our expectation.  This can
lead to out-of-bounds reads, so let's always use TLVP_PRES_LEN.

Change-Id: I1519cff0f6b2fe77f9a91eee17e0055d9df1bce6
2020-12-05 11:44:39 +01:00
Harald Welte f9e149b058 gbproxy: Send BVC-STATUS if BSS sends us BVC-RESET without mandatory IEs
Change-Id: I198ca70f5e0947735f76d32cd9d3eed159349a94
2020-12-05 11:44:38 +01:00
Daniel Willmann 5b89771fe2 gbproxy: Delete gbproxy_nse in delete-gbproxy-peer VTY command
The gbproxy_nse is created when the signalling BVC is resetted. When
we delete all bvcs of an nsei we need to remove it as well.

Change-Id: I997b29fef93188565f81bd403bc68840473958c3
Related: SYS#5002
2020-12-04 17:49:19 +01:00
Daniel Willmann f6a36cca6f gbproxy: Allow gbproxy_nse_free(NULL)
Calling free() with a null-pointer is usually supported and does
nothing. Change gbproxy_{peer,nse}_free() to reflect that behaviour.

Change-Id: Ia32084f81ca8f8cb9ddea3adabd4b44fd766f1c7
2020-12-04 17:49:19 +01:00
Daniel Willmann 4becbcbe18 gbproxy: Add newline to log message
Change-Id: I91a076872b5d744a237f6d325857b95362455e8d
2020-12-04 01:31:05 +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
Harald Welte 324f065fa9 gbproxy: Cosmetics: use longer lines
Change-Id: I9426bf4be2faa0da7848cb102b20cc539948b3f5
2020-12-02 23:06:37 +01:00
Harald Welte 314647b0be gb_proxy: Slightly restructure processing of BSS-originated BVC-RESET
* explicit else clause rather than implicit
* don't continue processing if mandatory BVCI missing from message

Change-Id: I038576b91ae1ece149149d8663de7b8495d24e06
2020-12-02 23:03:22 +01:00
Harald Welte 7df1e5a757 gbproxy: Move BSS-side BVC-RESET processing to its own function
The switch clause was getting a bit too long/nested, let's add
a separate gbprox_rx_bvc_reset_from_bss() function.

Change-Id: If262566e275cca96035045d1194ce102c0942eb6
2020-12-02 23:01:47 +01:00
Harald Welte 7479c4da94 gb_proxy: Broadcast SGSN-INVOKE-TRACE and OVERLOAD
Both BSSGP messages appear from the SGSN in downlink on BVCI=0.

We must send a copy of this message to each of the BSS side NSEs.

Change-Id: Ia19791b143989eb1490f461d88b9edbd8e3b82be
Closes: OS#4875
2020-12-02 22:45:42 +01:00
Daniel Willmann 65bfbaf40d gbproxy: Add todos encountered while going through the code
Change-Id: I8c3a788f008d3cb2d067d974c2b1b9ca45185d8d
2020-12-02 22:42:48 +01:00
Daniel Willmann 3696dce679 gbproxy: Change generic LOG messages so BVCI/NSEI fmt is consistent
We actually need to alter our compiler flags to avoid -Werror=trigraphs
creating trouble:

gb_proxy.c: In function ‘block_unblock_peer’:
gb_proxy.c:875:37: error: trigraph ??) ignored, use -trigraphs to enable [-Werror=trigraphs]
  875 |   LOGP(DGPRS, LOGL_ERROR, "BVC(%05u/??) Cannot find BSS\n",
      |

Fixes: SYS#5233
Change-Id: I93296353dd964602699480faae1248096e331c6a
2020-12-02 22:42:42 +01:00
Daniel Willmann 5e595cadf7 gbproxy: Use LOG macros for NSE/BVC
Change-Id: If445f18bc8390c338b5aeb9085951ea392e68b3a
Related: SYS#5233
2020-12-02 17:47:49 +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
Harald Welte 95cf9fbfa4 gb_proxy: More precise + readable log messages
* use string representations instead of magic numbers whenever possible
* make text actually describe the specific case, rather than copy+paste
* proper order (foobar indication) not (indication ..... foobar)

Change-Id: I232038da26a9963763c5fc9051b87c9182b27d94
2020-12-01 11:56:57 +00:00
Pau Espin 7345af835d gmm: Introduce comment to ease addition of Network feature support IE later
Change-Id: I131cba3de3c80c61d5549e7c31b4eacaaeddb040
2020-12-01 11:47:58 +00:00
Pau Espin bdbdcaf38e gmm: fix build without define PTMSI_ALLOC
Change-Id: Idcac01c4634af81ef884dc2b1b20dec3f8d12236
2020-12-01 11:47:58 +00: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 76205715c1 gbproxy: Only send paging to each matching NSE once
Fixes: SYS#5226
Change-Id: Ia33e7816b354266b9d2659ef96b798db60c134f3
2020-11-30 18:30:35 +01:00