Commit Graph

61 Commits

Author SHA1 Message Date
Harald Welte a08aeac9dd Don't permit anything bug HNB (de)registration until HNB is registered
UE registration or other HNBAP procedures should only happen once the
HNB is registered.

Change-Id: Iaa62ce89f4ffbff868309bfb8b1df7ebcca5c44a
2022-09-12 09:08:54 +02:00
Harald Welte 6fc9fad8b7 Don't process RUA messages if HNB is not registered
Related: OS#5676
Change-Id: I85442e8adfefadc3bf3ed795eaef7677eb0b36e9
2022-09-12 09:08:54 +02:00
Harald Welte 5db9c06a61 Avoid NULL-pointer de-reference for SCTP connection without HNB context
Let's print a WARNING rather than OSMO_ASSERT() until we're sure we've
caught all code paths that would remove the hnb_context.

This fixes any related crashes by simply discarding received messages
whenever there's no HNB-context around.

Closes: OS#5676
Change-Id: I1eedab6f3ac974e942b02eaae41556f87dd8b6ba
2022-09-12 09:08:54 +02:00
Harald Welte be501f3119 hnbgw_rx_hnb_deregister: Don't call hnb_context_release()
Don't release the HNB context as there's plenty of code that
assumes there's always a HNB context associated with a SCTP connection.

Instead, simply unset the hnb_registered flag in the context when
processing a HNB_DE-REGISTER.

Related: OS#5676

Change-Id: Id5c4f5c900ea049f54afbf58edb84b4dc00b1dcb
2022-09-12 09:08:54 +02:00
Harald Welte d28771a1b5 cosmetic: Fix typos
it's "successful", not" "successfull".

Change-Id: Ic421ed6835a9ffca6af34779f0ea648bb12e2fe1
2022-09-12 08:15:58 +02:00
Max 0c5878fa9d Set working directory in systemd service file
By default systemd will execute service with root directory (or home directory for user instance) which might result in
attempts to create files in unexpected place. Let's set it to 'osmocom' subdir of state directory (/var/lib for system instance) instead.

Related: OS#4821
Change-Id: I3133dc7a687550901841755461db6020ee96d6b1
2022-08-30 19:48:37 +07:00
Neels Hofmeyr 9ea431123d fix regression: in RUA, do PFCP only when enabled
Tested in ttcn3, by test cases not ready for submission (would require
enabling/disabling PFCP while osmo-hnbgw is running).
ttcn3 tests in I511e758807e0512c18f3f9e0a8c4699b9a3f5992

Related: SYS#6093
Change-Id: I39b9632f8524a9f3455c1a2d7611bfe8ba07c2fd
2022-08-29 16:57:28 +02:00
Neels Hofmeyr b08b19c990 debian,RPM: package with PFCP support
- depend on libosmo-pfcp
- configure --enable-pfcp

Related: SYS#5895
Change-Id: I54dfe600d45541fecbb4c05bf75f147934c230f0
2022-08-27 16:02:51 +00:00
Harald Welte 791babf40e packate the new osmo-hnbgw-pfcp.cfg example config file
In I62c4935bcc7f684bfe850f88f1b80e8970e0e098 we added a new example
config file, but didn't actually package it in dpkg or rpm packages
yet.  This also lead to package build failures like:

[   39s] RPM build errors:
[   39s]     Installed (but unpackaged) file(s) found:
[   39s]    /usr/share/doc/osmo-hnbgw/examples/osmo-hnbgw/osmo-hnbgw-pfcp.cfg

Change-Id: I7c5c346f67f003b2cc5d74e812441c3704b133ef
2022-08-26 11:53:33 +00:00
Daniel Willmann d129e0c86e hnbgw_hnbap: Fix memory leaks in HNBAP handling
* Use osmo_stream closed_cb to call hnb_context_release() in all cases
* Also call hnbap_free_hnbregisterrequesties() when sending hnb register
  reject

Related: OS#5656
Change-Id: I3ba02b0939413c67bc8088ea1a8f2252fc2bda31
2022-08-23 18:15:02 +02:00
Daniel Willmann 2dfeb1e218 Install show talloc-context VTY commands
Related: OS#5656
Change-Id: Ia4b0023028405ce065f618f536c92ea2bcd0ce15
2022-08-23 17:51:51 +02:00
Oliver Smith 0a5e2b3643 rpm spec: add osmo-hnbgw-pfcp.cfg
Fix for:
  Installed (but unpackaged) file(s) found:
  /usr/share/doc/osmo-hnbgw/examples/osmo-hnbgw/osmo-hnbgw-pfcp.cfg

Related: OS#5654
Change-Id: Ia05323a627719a7fff7c232aa3e5cc8766f9a8e1
2022-08-22 12:04:11 +02:00
Neels Hofmeyr 9f654da0aa example cfg: tweak logging
Change-Id: Idaf75d64d28264a29b67439c6bbcae8ad6981f7e
2022-08-18 16:17:53 +02:00
Neels Hofmeyr f7df74fc48 manual: explain the PFCP port
Change-Id: I383befb226caa49e4a2577657806aef1ee11faa3
2022-08-18 16:17:53 +02:00
Neels Hofmeyr a0d528ef31 manual: update IuCS/IuPS protocol stack chart
We use SCCP/M3UA now, not SUA.

Change-Id: I4496a6ffdda511875208bebbe68dbc9e69541fc0
2022-08-18 16:17:53 +02:00
Neels Hofmeyr d8de11b430 manual: update overview chart with PFCP
Change from ascii art to the dotty chart, taken from the osmocom.org
wiki. No need to keep a separate representation here.

Change-Id: Ifd8843aeb8ff28fec53323c8fb37b10d4d1f2f9b
2022-08-18 16:17:53 +02:00
Neels Hofmeyr 598ebb6943 manual: add missing bit on the MGCP port
Change-Id: Ic18180793f0c1497b020e5f4a8cd34d6b519b85f
2022-08-18 16:15:36 +02:00
Neels Hofmeyr 1ce5148996 add example osmo-hnbgw-pfcp.cfg
Change-Id: I62c4935bcc7f684bfe850f88f1b80e8970e0e098
2022-08-18 16:15:36 +02:00
Neels Hofmeyr 941008e785 ps_rab_fsm: check use cb success
Related: CID#275413 CID#275410 CID#275409
Related: SYS#5895
Change-Id: Idcb3d6796326b059280b0e552eb36067ba15b3ac
2022-08-17 14:33:33 +00:00
Neels Hofmeyr ca2c5b9067 optimize: decode PS msgs only when PFCP is enabled
For the benefit of skipping decoding of all PS RANAP and RUA messages,
introduce code dup: decode CS and PS separately.

Related: SYS#5895
Change-Id: Ifb57bad6a0d5ff263e4c6c3facc51620e110e7d2
2022-08-17 14:33:33 +00:00
Vadim Yanitskiy c5b7106f8d configure.ac: do not require unused dlopen
Change-Id: Ia23cee40fd63f708e7a7391417ec8604f51a20a7
2022-08-16 23:44:08 +07:00
Neels Hofmeyr e6201765cf build: add --enable-pfcp, make PFCP dep optional
Related: SYS#5895
Change-Id: I6d50c60bccda767910217243bdfb4a6fad1e39c1
2022-08-09 17:57:43 +02:00
Neels Hofmeyr 44f5a336a8 reduce code dup in handle_cn_data_ind()
Change-Id: I4bca25d1643693cf3a9d3c49f35b29ff1dce0859
2022-08-08 20:20:34 +00:00
Neels Hofmeyr 1496498713 add ps_rab_ass FSM to map GTP via UPF
Related: SYS#5895
Depends: If80c35c6a942bf9593781b5a6bc28ba37323ce5e (libosmo-pfcp)
Change-Id: Ic9bc30f322c4c6c6e82462d1da50cb15b336c63a
2022-08-08 20:20:34 +00:00
Vadim Yanitskiy b7ff03e5be tests/ranap_rab_ass: fix potential NULL pointer dereferences
Change-Id: I16fea7b2a8cb1d693e01c91d7633550e2e599ceb
Related: CID#275345
2022-07-30 05:48:41 +07:00
Neels Hofmeyr 223aeda282 ranap_rab_ass_req_encode(): return msgb
ranap_rab_ass_req_encode() forms a msgb, then copies the data to a
buffer provided by the caller. Instead, just return the msgb. This
removes one unnecessary memcpy() and simplifies some code.

In ranap_rab_ass_test.c, actually ensure the correct size of the
returned data. See also the fix of expected test data in patch
Ifb98a52e56db1227a834c0d7b7a260314d9f547e

Related: SYS#5895
Change-Id: I85e715326e1d8f4f301f82f78da109f1a7a92f30
2022-07-27 15:45:18 +02:00
Neels Hofmeyr a82c8d2425 fix test_ranap_rab_ass_resp_decode_encode
There is an extra zero octet at the end of the test data, which does not
get encoded back. The test currently does not detect this, but will in
upcoming patch I85e715326e1d8f4f301f82f78da109f1a7a92f30.

Related: SYS#5895
Change-Id: Ifb98a52e56db1227a834c0d7b7a260314d9f547e
2022-07-27 15:45:16 +02:00
Neels Hofmeyr 05aaccc42d mgw_fsm: move MGCP timeout to mgw_fsm_T_defs
For the tdefs used by libosmo-mgcp-client, passed via
osmo_mgcpc_ep_alloc(), do not use the separate mgw_tdefs. Instead, move
X2427 to mgw_fsm_T_defs. This makes X2427 VTY configurable.

Related: SYS#5895
Change-Id: I2aa67121c20dc3da5fd937a02b6747468622f317
2022-07-27 15:44:51 +02:00
Pau Espin 7eb89ec9fe hnbgw_cn.c: Guard against null ss7 ptr during init
Fixes: Coverity CID#272989
Change-Id: Ic787d52a3c2e73ac272735a33b20bb94e29fad95
2022-06-29 18:50:30 +02:00
Pau Espin 44dfe698fa Bump version: 1.2.1.25-7893-dirty → 1.3.0
Change-Id: I5283bfcdcee218d2db25cd10b9a17ffe2129efb6
2022-06-29 12:42:35 +02:00
Harald Welte 7893028ef6 update URLs (git -> https; gitea)
Change-Id: Ic9da2fbbc473b1ac5bc4e29c8dd77533455930d4
2022-06-18 14:02:41 +02:00
Pau Espin 62fb1dea61 mgw_fsm: Simplify cleanup paths
Let's have a unified way of freeing the FSM instance once it was
allocated, otherwise it's far more difficult to understand and maintain.

Change-Id: I8883e737fa112cff57834abae7ef272388a54edb
2022-06-15 11:55:21 +02:00
Pau Espin 304f7646c9 mgw_fsm: Fix error path accessing uninitialized fsm ptr
The error handling of the error path was wrong. Let's remove the "fi"
variable to avoid more of such errors. Furthermore, add an assert to
clarify for the reader that the map->mgw_fi will be freed before
allocating a new FSM instance below.

Change-Id: I9d3bca552bfa77f5e18f75bedad8d422f74df1f8
2022-06-14 18:41:48 +02:00
Pau Espin 87e03208af mgw_fsm: Change macro to not use local variables implicitly
This is misleading for readers since it may access variables which may
be uninitialized or in a wrong state. Furthermore, we want to pass some
other variable name in a follow up patch.

This effectively allows the compiler to warn about uninitialized used of
a fi var in line 661.

Change-Id: Id694f51bb2918fd27da87b3f4a905727cd7f5de6
2022-06-14 18:40:11 +02:00
Pau Espin de8b170d1a cosmetic: mgw_fsm: Fix typo in log
Change-Id: I80aa61a288ab37c51510af67c784498f5949fc50
2022-06-14 18:07:52 +02:00
Pau Espin 1d1839a34b mgw_fsm: Improve logging
Change-Id: I14785b6bc798c3bae8c552bccb55ca4fa9f2f416
2022-06-14 18:07:32 +02:00
Pau Espin 8c7aae87b0 mgw_fsm: Mark structs as static const
Change-Id: Ie62f28587c08296429c0dabda7b6add67ffa010c
2022-06-14 17:46:56 +02:00
Neels Hofmeyr ff2fbdf998 fix segfault in error handling for mgw_fi == NULL
In mgw_fsm_handle_rab_ass_resp(), a NULL mgw_fi is handled as error,
but the error handling fails to return. The function continues to
dereference mgw_fi. Add missing return.

Related: SYS#5995
Change-Id: I3e98dc3a00145ec1f71c678bbf45debfd4276237
2022-06-10 11:40:33 +02:00
Neels Hofmeyr 2c91bd66a1 add option to send SCCP CR without payload
It is reported that a third-party SGSN is rejecting SCCP CR when the
SCCP message part exceeds a certain length. The solution is to first
send an SCCP CR without payload, and send the payload in a DT later.

Add config option

  hnbgw
   sccp cr max-payload-len <0-999999>

If the RANAP payload surpasses the given length, osmo-hnbgw will first
send an SCCP CR without payload, cache the RANAP payload, and put that
in an SCCP DT once the SCCP CC is received.

The original idea was to limit the size of the entire SCCP part of the
message, but I'm currently not sure how to determine that without
copying much of the osmo_sccp code. I figured using a limit on the RANAP
payload is sufficient. To avoid the error with above third-party SGSN,
the easy solution is to set max-payload-len to 0, so that we always get
a separate SCCP CR without payload.

Related: SYS#5968
Related: I827e081eaacfb8e76684ed1560603e6c8f896c38 (osmo-ttcn3-hacks)
Change-Id: If0c5c0a76e5230bf22871f527dcb2dbdf34d7328
2022-06-07 22:51:26 +02:00
Neels Hofmeyr afbcae6366 tweak comments in rua_to_scu()
Change-Id: I227a5e6b869da453fa72ff0eebaa1e95aa9625e6
2022-06-07 22:51:25 +02:00
Neels Hofmeyr da9d08c94e allow calling rua_to_scu() without data
There can be SCCP primitives without payload data, e.g. an "empty" SCCP
Connection Request.

Patch 'mgw_fsm: add MGW support to osmo-hnbgw' added RANAP message
decoding that lacks a guard against NULL data. Fix that: do not try to
decode NULL data.

Related: SYS#5968
Change-Id: Id755e769e82ace7203460ea1b3c847c2c90d41bf
2022-06-07 22:50:37 +02:00
Neels Hofmeyr 0ca9567fb2 use osmo_select_main_ctx(), tweak log in handle_cn_conn_conf()
Upcoming patch adds to this function. Let me first combine those four
LOGP() to a single one, use proper osmo_sccp_addr_to_str_c(OTC_SELECT).

To be able to use OTC_SELECT, switch hnbgw.c to osmo_select_main_ctx().

Related: SYS#5968
Change-Id: I1e0ea0a883e8cf65e6cfb45ed9b6f3d8fb7c59eb
2022-06-07 18:09:19 +02:00
Philipp Maier be9ed71631 ranap_rab_ass: check for more than one RAB assignment req
The spec permits RAB AssignmentRequests with multiple RABs at a time.
Even though one voice call is assigned only one RAB in practice. Since
the current FSM implementation only supports a 1:1 scenario, lets check
if the MSC really assigns only one RAB and block RAB Assignments that do
not fit in this scheme.

Change-Id: I0f1d868fd0b4dc413533d6fcc5482862825181be
Related: OS#5152
2022-02-28 10:22:16 +01:00
Philipp Maier d1f4b9b9a1 mgw_fsm: release call when FSM is not created
While the FSM is created the RAB Assignment Requests is checked and
parsed. In case of failure the context is freed, but the CN is not
informed about the problem. The RAB AssignmentRequest will then most
likely time out. However, lets make sure the call is released by re
requesting an IU Release.

Change-Id: I1904f7e95d86bbcecee14f8721bd4075d0e33ab4
Related: OS#5152
2022-02-25 15:12:18 +01:00
Philipp Maier b5508f98ef osmo-hnbgw.cfg: use local port 2729 as default for MGCP client
There are several osmo processes that talk to osmo-mgw via
osmo-mgcp-client. The sample config for osmo-bsc suggest 2727 and the
sample config for osmo-msc suggests 2728 as local port default. To make
it less likely for users to get port collisions whlie setting up their
networks we should use a different port for osmo-hnbgw. Lets use 2729.

Change-Id: I55179c2bff3e6ef0e54fee6b1b90fc76f541e58e
2022-02-25 15:12:18 +01:00
Philipp Maier 9e46544486 running.adoc: explain MGW configuration
OsmoHNBGW now requires a co-located OsmoMGW instance. Lets add add some
info on how to configure it.

Change-Id: Id47f4f365cee78ce28d1534c4e3e98a59bdb0621
Related: OS#5152
2022-02-24 11:29:09 +01:00
Philipp Maier 7dd3a61b57 overview.adoc: update network diagram
The network diagram in the manual lacks the recently added
co located MGW.

Change-Id: Ica1782a407f6b944aa26748b54055168f5d250c3
Related: OS#5152
2022-02-24 11:28:50 +01:00
Philipp Maier 81f1751896 mgw_fsm: add MGW support to osmo-hnbgw
osmo-hnbgw lacks support for an co-located media gateway. This makes it
virtually impossible to isolate the HNB from the core network properly.

Lets add MGCP support to osmo-hnbgw so that it can control a co-located
media gateway to relay the RTP streams between HNB and core network.

Change-Id: Ib9b62e0145184b91c56ce5d8870760bfa49cc5a4
Related: OS#5152
2022-02-24 10:51:30 +01:00
Philipp Maier e7c66defc2 ranap_rab_ass_test: cosmetic: correct test function names
The test function naming follows an older scheme, lets use the current
scheme.

Change-Id: Ib9db9d86e01551c8d9d8f8c4933025ca20ce5624
Related: OS#5152
2022-02-23 15:50:43 +01:00
Philipp Maier f5742a3bed ranap_rab_ass: add function to check if RAB is in ReleaseList
A RANAP RAB-AssignmentRelease may contain a ReleaseList. In order to
detect that a RAB is about to be released we need to be able to check if
the RAB we are dealing with is contained in such a ReleaseList.

Change-Id: I5b67cc2d35d11de7a09e66c181a1fdd5a58c75bb
Related: OS#5152
2022-02-23 15:50:43 +01:00