Commit Graph

6525 Commits

Author SHA1 Message Date
Neels Hofmeyr 1ba0df26dc cosmetic: rename subscr_conn_from to complete_layer3_type
'subscr_conn_from' could mean anything: from what, RAN type? BSS identifier? MM
action? Clearly name it as the Complete Layer 3 kind it represents.

Related: OS#3122
Change-Id: I6263a80e6db01c2ca48df6c58b05e2fd19347057
2018-04-03 02:13:09 +02:00
Neels Hofmeyr 4d3a66b3f8 cosmetic: rename gsm_subscriber_connection->conn_fsm to ->fi
Match osmo-bsc's naming of the subscriber connection's FSM instance; 'conn->fi'
makes more sense anyway than 'conn->conn_fsm'.

BTW, an upcoming commit will do away with the legacy from libbsc/libmsc duality
and firmly glue the conn allocation to the fi.

Related: OS#3122
Change-Id: If442f2ba78d9722b1065ec30c9a13f372b6a8caa
2018-04-03 02:13:04 +02:00
Neels Hofmeyr ae73d2b16f cosmetic: rx_bssmap: read message type once into local var
Instead of referencing msg->l3h[0] all the time, use local variable msg_type.

Related: OS#3122
Change-Id: If70c9fa00edd462d3470bded6eb2c6521e4d9234
2018-04-03 02:12:09 +02:00
Neels Hofmeyr 9fe52e4af3 test_reject_concurrency: missing assert
I broke this test during dev and saw the failure being noticed only in the next
test when DTAP is expected again. Verify success right there, instead.

Change-Id: Ifdde3a6fa5835203c34c40db77761f2e90c0d5ff
2018-04-03 02:09:39 +02:00
Neels Hofmeyr 80d1101153 drop some dead definitions (gsm_data.h, gsup_client.c)
Change-Id: Icad01d0ad8fa68293160bc56543b9c3dcafc50bb
2018-04-02 23:59:50 +02:00
Neels Hofmeyr 08b3828995 use osmo_init_logging2() with proper talloc ctx
Since the logging allocations now also show up in the root context report, some
tests need adjusted talloc checks.

In msc_vlr_tests, also output the number of talloc blocks before tests are
started to show that the number didn't change after the tests.

Change-Id: Iae07ae60230c7bab28e52b5df97fa3844778158e
2018-03-30 23:20:03 +02:00
Neels Hofmeyr 053e27528c gsup_test_client: gsupc_read_cb: fix uninitialized value 'io'
Change-Id: Idb3ca50009e25c8e10bcbd15e430caf6de18a040
2018-03-26 19:09:07 +02:00
Pau Espin 7fdfad2f5d contrib: osmo-msc.service: Depend on osmo-mgw.service
Change-Id: Ia50eb02843bf6d145040fbe5032071a3be7b0794
2018-03-23 15:58:06 +01:00
Neels Hofmeyr a6ac98b6aa remove empty libcommon-cs
Change-Id: If6afda250986b12781ae579323985615621ed75c
2018-03-22 17:11:30 +01:00
Neels Hofmeyr 79e580b6ff dissolve libcommon-cs: move gsm48_* code to libmsc, drop sms_next_rp_msg_ref()
Move gsm48_* functions from common_cs.c to libmsc/gsm_04_08.c.

Drop sms_next_rp_msg_ref(), it is just a bunch of bloat around "next_rp_ref++".
Apply the "++" instead, in gsm_04_11.c.

libcommon-cs is now empty, to be removed in subsequent commit.

Change-Id: Ibc410803ce8e273b626124ab9fc934f04df3ae50
2018-03-22 17:10:49 +01:00
Neels Hofmeyr 55014d0509 dissolve libcommon-cs: move gsm_network_init() to libmsc
Move to libmsc/osmo_msc.c (for lack of a better place and reluctance to create
an own file just for gsm_network_init()).

Change-Id: I2279eee4db6f6687726bfd55841b3748d4930f15
2018-03-22 17:07:59 +01:00
Neels Hofmeyr 67fa909494 dissolve libcommon-cs: mv a_reset.c to libmsc
Change-Id: I2936dadf1ec91b39796b6012d5e6c5db39e0bd34
2018-03-22 17:07:36 +01:00
Neels Hofmeyr 8ea65b3270 rename libcommon to libgsupclient
All that is left in libcommon now are the GSUP and OAP client implementations.
These are duplicated in osmo-sgsn.git and make sense to remain somewhat
separate from libmsc. So now they get their own little lib.

Change-Id: Ic71aa119c233b6a0ae169a5b2a53819903d2be82
2018-03-22 17:07:13 +01:00
Neels Hofmeyr 9d74425e27 dissolve libcommon: drop gsm_data.c, move code to libmsc
classmark_is_r99() is only used in gsm_04_08.c, move there as static.
rrlp_mode_* is only used in msc_vty.c, move there as static.
Move ran_type_names[] to msc_ifaces.c.

Change-Id: I5381c72af6841829fbc65940fd7d6f4d5cf583df
2018-03-22 17:06:51 +01:00
Neels Hofmeyr 7a2f58ea63 dissolve libcommon: drop gsm_subscriber_base.c, move vlr_subscr_* to vlr.c
Change-Id: Ia69890da68b8afa8a2a4e8ab58ec5c4a4ba9d06a
2018-03-22 17:06:28 +01:00
Neels Hofmeyr c01e90933f dissolve libcommon: move talloc ctx into msc_main.c, drop talloc_ctx.c
Drop tall_bsc_ctx; in mncc_sock_init(), talloc the mncc_sock_state from
gsm_network.

In tests or utils, move from using an extern tall_bsc_ctx to a local root
context pointer.

Change-Id: I92c252be1d1e7634f1653de47d37c99d77d9501c
2018-03-22 17:06:05 +01:00
Neels Hofmeyr 6a8b9c70fc dissolve libcommon: drop debug.c
Apply more concise logging categories in each main scope. The bulk goes to
msc_main.c, obviously, while tests and utils get a slimmed down bunch of
logging categories.

Change-Id: I969a0662ba273f3721b6820d02151b7a5b8014b8
2018-03-22 17:05:42 +01:00
Neels Hofmeyr 34fd0c69a3 dissolve libcommon: drop unused bsc_version.c
Change-Id: I23f31b1dc265d153598ee9006cae3adaf3cebd2f
2018-03-22 17:04:59 +01:00
Neels Hofmeyr 84a1f7aa80 cosmetic: msc_vty.c: use static gsmnet instead of gsmnet_from_vty()
Now that all VTY definitions are in the same file, we no longer need
gsmnet_from_vty(). Just have one static struct gsm_network *gsmnet populated by
msc_vty_init() and use it in all VTY functions.

Change-Id: I5cb3712a4f4245feb62d42f1b041fe94de5fac1b
2018-03-22 16:52:58 +01:00
Neels Hofmeyr 7c075a2f74 dissolve libcommon,libcommon-cs: clean up vty definitions
From openbsc.git, we still have osmo-msc's VTY definitions spread across
various places. Combine:

- Move the go_parent_cb() and is_config_node() to msc_main.c, drop
  common_vty.c.
- Move all of vty_interface_layer3.c into msc_vty.c.
- Move all of common_cs_vty.c into msc_vty.c.
- Move bsc_vty_init_extra() into msc_vty_init().
- Drop some unused definitions

No functional nor cosmetic changes have been made in the moved code, plain
copy-paste moving (even though the unidiff might look like edits in some
places). I might have adjusted some blank lines though.

Change-Id: Ia818c00ab613a19a34080b160d763b55c19f76b1
2018-03-22 16:52:27 +01:00
Neels Hofmeyr d6a769b51c trans_free: tear down conn when last transaction is done
In trans_free(), call subscr_conn_release_when_unused(), so that we are sure to
clean up after the last transaction is done.

This fixes an error where a conn lingered after a CC failure, because that code
path forgot to trigger cleanup.

Rationale: so far we were triggering the release check after each DTAP dispatch
(compl_l3 and "normal" DTAP), which is sufficient for properly closed
transactions. We also need a check for when a timeout clears an erratic trans.

Adjust test expectation of test_call_mo_to_unknown_timeout to show that the
error is now fixed.

msc_vlr_test_reject_concurrency now sees an additional release checking event
when the SMS transaction is done, which is expected and does not affect the
test otherwise.

Related: OS#2779
Change-Id: I46ff2e9b09b67e4e0d79cccf8c04936f17281fcb
2018-03-22 04:35:28 +00:00
Neels Hofmeyr 3cffc2055d cosmetic: gsm_04_08.c: drop unused struct gsm_lai
Change-Id: I3236841b1701dc902754d4a388c7806b0685a91e
2018-03-21 18:07:20 +00:00
Philipp Maier a2f633184b cosmetic: remove unused variable
Change-Id: Ic19d0401557d506d104b82f88b4dcf72055d62e1
2018-03-21 16:23:58 +01:00
Harald Welte 8a991edd36 a_iface: If L3/DTAP returns error in COMPL L3, close SCCP connection
It's pretty amazing that we print error messages anrd return error
codes, but nobody ever looks at the error code and/or closes the
connection.  Let's change that.

Change-Id: Iec693d8012a7816d1ded8206c2d979ac0546fb6e
2018-03-18 23:00:27 +01:00
Harald Welte 4de011561f a_iface_bssap: Treat inbound RESET as implicit RESET ACK
If both sides are sending RESET at the same time, they are not aware
of each other.  This leads to synchronization problems in wich
the remote side is transmitting e.g. a COMPL L3 INFO after receiving
a RESET ACK, but before even receiving or processing the RESET in
the inverse direction.  So let's treat receiving a RESET as an implicit
RESET ACK to any RESET we may have sent.

Change-Id: I0ae34fbb3735592bb7cffa5aaf421b14a8acc90e
2018-03-18 21:47:15 +00:00
Harald Welte 5060f563c6 BSSAP: Return error code if COMPL L3 with no or too short L3 payload
Change-Id: Ie3bf1351ed11a9eb261737c2da0361e632e7b6e5
2018-03-18 21:55:37 +01:00
Pau Espin 9fac985972 msc_mgcp.c: Fix several wrong ptr printf fmt
Fixes several of these type of warnings:
include/osmocom/core/fsm.h:123:38: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 9 has type ‘char *’ [-Wformat=]
   LOGP((fi)->fsm->log_subsys, level, "%s{%s}: " fmt, \
                                      ^
src/libmsc/msc_mgcp.c:277:71: note: format string is defined here
    "CRCX/RAN: creating connection for the RAN side on MGW endpoint:0x%x...\n", mgcp_ctx->rtp_endpoint);
                                                                      ~^

Change-Id: I17b7bed8fc39612286ba66f250b6b26da01d38c0
2018-03-17 01:54:34 +01:00
Philipp Maier 04d6ddb299 msc_mgcp: to not access higher layers after release
The higher layers (gsm_04_08.c) are informed errors occur. But it
is not checked if the call was already released. If an error occurs
after the call control stack calls msc_mgcp_call_release() then
the higher layers might already have cleaned up and the code
accesses memory that is already freed (trans)

- fix use after free by guarding the call to mncc_tx_to_cc()

Change-Id: I78f1b6a9149488a4ad3f120c1e190a83c07d4b89
Related OS#2881
Related OS#2882
2018-03-16 18:51:27 +00:00
Neels Hofmeyr eb1cfdb263 msc_vlr_tests: add CC Release test and test to catch OS#2779
These tests helped to debug issue OS#2779. Now that they're here we might as
well keep them.

The test test_call_mo_to_unknown shows that an MS answering to the Release
Request works as it should: the conn is torn down.

The test test_call_mo_to_unknown_timeout currently expects the error: the conn
remains active if the CC Release times out. This bug and the test expectations
will be fixed in I46ff2e9b09b67e4e0d79cccf8c04936f17281fcb.

Change-Id: Ic3c84520bff8c3fc82512d03ff6ab97d21b8fb7a
2018-03-15 14:24:57 +00:00
Neels Hofmeyr e9e2f5cde6 cosmetic: rename conn_fsm "bump" event to "release_when_unused"
The naming of "bump" was short and made sense to me at the time of writing, but
it is keeping pretty much everyone else at a distance, no-one intuitively gets
what it is supposed to mean.

Clarify by renaming to "release_when_unused".

Adjust test expectations.

Change-Id: I4dcc55f536f63b13a3da29fff1df5fe16751f83a
2018-03-15 14:24:57 +00:00
Neels Hofmeyr 12e17be1a0 cosmetic: msc_vlr_tests: enable CC logging in debug
There are a number of bad failures in CC teardown handling we're solving. It
helps to see CC logging in the msc_vlr_tests.

Change-Id: I56ac269d46b48b6b85efad81c4d2343bfc41ea90
2018-03-15 14:24:57 +00:00
Neels Hofmeyr fe718bc760 cosmetic: vlr_auth: log decision to send UMTS or GSM AKA challenge
Also indicate in msc_vlr_test_gsm_authen.c that we're indeed sending no
capability to do R99 in the Classmark 1 during LU request.

Change-Id: Id79a77ca1f218d55dad21d9dd3de92445fb5d6bf
2018-03-15 14:24:57 +00:00
Philipp Maier c813355a73 cosmetic: remove disabled (debug) code gsm_04_08.c
gsm_04_08.c seems to contain some lines of old debug code that
is commented out. Presumably the commented lines are a leftover
from a debug session.

- remove those commented code lines

Change-Id: Ifb84e4b0696fef1326c3f9ebc8427581057db44f
2018-03-15 11:16:17 +00:00
Stefan Sperling be7e069810 use libosmocom to parse cell identifier in bssmap_rx_l3_compl()
Use the new gsm0808_dec_cell_id_list2() API to decode the cell
identifier in the bssap COMPLETE LAYER 3 information message.

Also, actually compare the MCC-MNC in WHOLE_GLOBAL and LAI_AND_LAC
cell identifiers to the network configuration, and drop messages
with mismatching MCC-MNC (addresses OS#2980).

Related: OS#2847
Related: OS#2980
Change-Id: I855477507e4d65fb9890da0ceea26dd2c4dfaf82
2018-03-15 10:42:07 +01:00
Philipp Maier a2353c69cc mcgp: let the MGW allocate the MGCP endpoint
osmo-msc still uses endpoints that are allocated locally by the
MGCP-Client. Since osmo-mgw now supports the more comfortable,
dynamic variant we should make use of it.

- Replace the endpoint numer allocation by the client with a
  wildcarded CRCX. Use the endpoint that is assigned by the
  MGW.

Related: OS#2710
Change-Id: Iee3e446b6689626516f01c521abe3d4603cd3e13
2018-03-14 21:08:30 +00:00
Philipp Maier 3a77652cd7 msc_mgcp: use more conceise error msg on truncation
When a truncation check (osmo_strlcpy()) fails handle_error()
is called with MGCP_ERR_NOMEM as cause code. Which finally
results in an "out of memory" message. MGCP_ERR_NOMEM is only
used for failed truncation checks, so it makes sense to choose
a message that describes the cause of the problem better.

- rename MGCP_ERR_NOMEM to MGCP_ERR_TOOLONG
- replace error message string

Change-Id: Ifedb85c1933a30b2aa491b495119919f45782e2c
2018-03-14 21:04:50 +00:00
Neels Hofmeyr 5c56bc5761 trans_free: safeguard against a still running CC timer on free
Make sure to deactivate trans.cc.timer when freeing a CC transaction.
Log an error if should be necessary.

This prevents a segfault when we receive a BSSMAP Clear Request from BSC during
an ongoing CC operation. The BSSMAP Clear Request currently triggers immediate
freeing of the conn, while we should still do a graceful release first. While
this patch does not fix the underlying error, it does prevent the MSC from
crashing due to a stale timer, whatever the cause might be.

Related: OS#3062
Change-Id: I86b666f23402a6d94af2d903e514770d1fd5157f
2018-03-14 14:17:53 +01:00
Philipp Maier addf63b523 mgcp: be sure that pending mgcp transactions are canceled before free
When the FSM reaches ST_HALT it frees itsself and all context
information but it is not ensured that there are still pending
MGW transactions that might hit late and eventually cause a use after
free situation.

- if an MGW transaction is still pending, cancel it.

Change-Id: I8ff55e48a95cc4c556a97ad2593bad1cc1aa69bd
2018-03-14 13:55:04 +01:00
Philipp Maier 4eef20bdbc msc_mgcp: fix mgw timeout handling
When the MGW does not respond to an MGCP message then the mgcp FSM
terminates, but the CC handler (gsm_04_08.c) is not informed. This
lets the CC handler think that the MGCP connection would be successful,
so it also does not take any action to release the non functional
connection.

- make sure the CC handler is always informed on any kind of
  error, especially on MGW timeouts

Change-Id: I3fcd0d71fad53274e82f6d87c80042d06283bc5d
Related OS#2881
Related OS#2882
2018-03-14 10:56:06 +01:00
Stefan Sperling 3a74128ccc restore sending of optional MM info messages
Since commit 2483f1b050 the function
gsm48_tx_mm_info() was not called anymore. No MM info messages were
transmitted to phones even if MM info messages were enabled via VTY.

With this commit, we call gsm48_tx_mm_info() after successfully
processing an IMSI ATTACH location update.

Change-Id: Ice5963d84253eb8c803cd2dfa8b25a4db5382827
Related: OS#2850
2018-03-13 21:13:27 +01:00
Stefan Sperling 621c729d8d Track libosmocore API change in osmo-msc.
struct gsm0808_cell_id_list in libosmocore is deprecated by
https://gerrit.osmocom.org/#/c/6509/

This updates the only API user I am aware of.

Change-Id: I67377270cf3b081ac5dc9cd7b4dc28f74143753a
Depends: Ib7e754f538df0c83298a3c958b4e15a32fcb8abb
2018-03-13 15:50:18 +01:00
Neels Hofmeyr fa10eda6d7 vlr_ciph_result: fix use after free of imeisv
Define the struct vlr_ciph_result member .imeisv not as a char* but a char[] of
appropriate length, to avoid the need to point to external memory.

Thus fix a use-after-free in msc_cipher_mode_compl(), which defined the
imeisv[] buffer in a sub-scope within that function, so that the .imeisv
pointer was already invalid when fed to vlr_subscr_rx_ciph_res().

Did you notice that the commit summary rhymes?

Closes: OS#3053
Change-Id: I90cfb952a7dec6d104200872164ebadb25d0260d
2018-03-13 01:29:04 +01:00
Neels Hofmeyr 620ba9369d configure: add --enable-werror
Provide a sane means of adding the -Werror compiler flag.

Currently, some of our jenkins.sh add -Werror by passing 'CFLAGS="-Werror"',
but that actually *overwrites* all the other CFLAGS we might want to have set.

Maintain these exceptions from -Werror:
a) deprecation (allow upstream to mark deprecation without breaking builds);
b) "#warning" pragmas (allow to remind ourselves of errors without breaking
   builds)

As a last configure step before generating the output files, print the complete
CFLAGS and CPPFLAGS by means of AC_MSG_RESULT.

Change-Id: I0528dcb14bf79d0920905a718cc2edea1434c0e5
2018-03-13 00:03:27 +00:00
Neels Hofmeyr a7fd88ce1b msc_vlr_tests: add test_a5_3_not_supported
See also change-id I72a1dbb30e0a39dbf4b81c7e378d5607b62e10d3 in
osmo-ttcn3-hacks.git, which adds a similar test to the MSC_Tests.ttcn suite.

Writing this test helped me fix the issue faster, why not keep it now that it's
there.

Related: OS#2947
Change-Id: Iba56556207cf6e79e6531b0e7dd3eaec28fb5eaa
2018-03-10 23:21:34 +01:00
Neels Hofmeyr a9099bc99a cosmetic: vlr_auth_fsm: log RAN and size along with SRES/RES
Change-Id: Ib0f9f573ffac2302fbd3ee28f48ccd8fce5fe286
2018-03-10 22:23:13 +01:00
Neels Hofmeyr 11d2ce3e34 cosmetic: vlr_auth_fsm: clarify decision on UMTS AKA or GSM AKA
The code deciding on whether UMTS AKA is used was cascaded and convoluted. By
flattening the decisions, they become easier to read and possibly catch more
weird corner cases / log information more clearly.

- First decide what AKA the RES length reflects.
- Then decide whether all prerequisites for UMTS AKA are satisfied.
- Finally, on UTRAN, turn down the auth if we don't have UMTS AKA, and neatly
  log all of the potential causes.

One corner case that should never occur is that the UMTS AKA RES length is
actually the same length as the GSM AKA SRES. If this nevertheless occurs, log
this as an error, though not turning down authentication because of it. (The
effect is that we would favor UMTS AKA when it has a res_len == sizeof(sres)
and would not succeed to GSM AKA. At least the log will tell us why, now.)

Adjust an expected test output, trivial logging difference.

Change-Id: I43f7f301ea85e518bac91f707391a53182e54fab
2018-03-10 22:23:13 +01:00
Neels Hofmeyr 31adcae654 msc_vlr_test_umts_authen: test response with only SRES half of RES
Change-Id: I0e9099625bd9d3de3db5ee29fbf81b2d8a30071d
2018-03-10 22:23:13 +01:00
Neels Hofmeyr c6d20dd5a2 msc_vlr_test_umts_authen: test response with too long RES
Change-Id: Ie5473f06fc2d04c6a9f343da5764ec95b292a5f9
2018-03-10 22:23:13 +01:00
Neels Hofmeyr 15ed426df2 msc_vlr_test_umts_authen: test response with too short RES
Change-Id: Ia1bc57b3dc1f3c3c654ba2d907b16ba925cd03e8
2018-03-10 22:23:13 +01:00
Neels Hofmeyr d97821f8e5 cosmetic: gsm48_rx_mm_auth_resp(): log 'UMTS AUTH', not 'R99 AUTH'
Change-Id: Iba43c685cbe238d96175267e9cc954b2f2f3e7fc
2018-03-10 22:22:56 +01:00