Commit Graph

12 Commits

Author SHA1 Message Date
Pau Espin 35f0e664bf Split out GPRS SM layer into its own file
Change-Id: Ie61d22e7868af6de73cdf9c731f07130b282599d
2019-09-03 15:22:15 +02:00
Pau Espin ccd1252bd7 Introduce FSM mm_state_iu_fsm
Implement TS 23.060 6.1.2 Mobility Management States (Iu mode) using
osmocom FSM and drop old implementation.
Most of the logic on each state is still kept in gprs_gmm.c, will be
inserted into the FSM later.

Change-Id: I4c9cf8c27194817c56e8949af0205e1cc14af317
2019-09-02 11:44:58 +02:00
Pau Espin 02514bc592 Introduce FSM mm_state_gb_fsm
Implement TS 23.060 6.1.1 Mobility Management States (A/Gb mode) using
osmocom FSM and drop old implementation.
Most of the logic on each state is still kept in gprs_gmm.c, will be
inserted into the FSM later.

Change-Id: I04004423e993107374d5a3549b8a93ac169251dd
2019-09-02 11:44:58 +02:00
Pau Espin 0b72240799 Split enum gprs_pmm_state into Iu and Gb counterparts
Those two state sets are not part of the same state machine, and are
used in different scenarios, so let's split them and handle them in Gb
and Iu specific parts of struct sgsn_mm_ctx. This is required in order
to improve related code (for instance, use osmocom fsm).

Change-Id: I6100d607da316da0595886c6968704dd9ccfbde9
2019-09-02 09:42:21 +00:00
Pau Espin 8333ef10c9 Move llc->MM/SM Gb specific glue code to its own file
Now that we have RANAP/Iu handling specificities in its own file, let's
have also Gb specific glue code for messages coming from llc up to MM/SM
layer in its own file. This way same entry points in gprs_gmm.c are used
by Gb and Iu: gsm0408_rcv_gmm() (for MM) and gsm0408_rcv_gsm() (for SM).

Change-Id: Iaf57922a0970c1d03f6f1d6337d27ae3d4aaf32c
2019-09-02 09:42:21 +00:00
Pau Espin 6dfb5fef40 Move lots of Iu/ranap specific code into its own file
RANAP related functionalities were splitted among several files
(gprs_gmm.c, gprs_sgsn.c and sgsn_libgtp.c). Let's move it into its own
file to shrink complexity/size of existing files.
It also allows to keep a lot of conditionally enabled code (BUILD_IU)
and its dependencies (osmo-iuh) together.

Change-Id: I549042aaff045a378de77d657cc396ee08f22f33
2019-09-02 09:42:21 +00:00
Alexander Couzens f7198d7dbb gprs_gmm: introduce a GMM Attach Request FSM
The old GMM Attach Request handling used a recursive function
which can not handle certain states and is quite complex and hard to
extend.

The new FSM handles such request in a FSM and can be called multiple
times.

Change-Id: I58b9c17be9776a03bb2a5b21e99135cfefc8c912
2018-09-13 13:51:37 +00:00
Pau Espin 89895b027d Add optional TearDownInd IE in PDP DEACT REQ towards PCU
According to 3GPP TS 24.008 Section 6.1.3.4, the tear down indicator IE
maybe included in the DEACTIVATE PDP CONTEXT REQUEST message in order
to indicate whether only the PDP context associated with this specific
TI or all active PDP contexts sharing the same PDP address and APN as
the PDP context associated with this specific TI shall be deactivated.

As we don't permit/support establishing multiple PDP contexts using
the same APN and PDP address, it shouldn't really make any difference.
Nevertheless, we want to clear everything, so let's include it.

Change-Id: Ia9bc2d0e93362a8473eac5cf4c7e8ffa41c79e5b
2018-07-16 15:16:53 +02:00
Pau Espin 8c7d259061 Disarm T3395 when dettaching mmctx from pdpctx
In sgsn_pdp_ctx_terminate, a pdp ctx is terminated and the mm ctx is
detached. However, T3395 may still be armed and then pdpctx_timer_cb
will trigger, and attempt to use the pdp->mm ctx which was already
detached (set to NULL) when calling
gsm48_tx_gsm_deact_pdp_req()->mmctx2msgid().

Following list of log lines shows the scenario+crash, in which osmo-sgsn
is trying to deactivate the ctx all the time but the PCU doesn't ACK it,
and then at some point the PDP context is forced released.

osmo-sgsn/src/gprs/gprs_gmm.c:2294 MM(901700000015254/d7e9ab95) <- DEACTIVATE PDP CONTEXT REQ
osmo-sgsn/src/gprs/gprs_gmm.c:1464 MM(901700000015254/d7e9ab95) -> GMM DETACH REQUEST TLLI=0xd7e9ab95 type=GPRS detach Power-off
osmo-sgsn/src/gprs/gprs_gmm.c:313 MM(901700000015254/d7e9ab95) Cleaning MM context due to GPRS DETACH REQUEST
osmo-sgsn/src/gprs/gprs_sgsn.c:332 MM(901700000015254/d7e9ab95) Dropping PDP context for NSAPI=5
osmo-sgsn/src/gprs/gprs_sgsn.c:434 PDP(901700000015254/0) Forcing release of PDP context
osmo-sgsn/src/gprs/gprs_sndcp.c:508 SNSM-DEACTIVATE.ind (lle=0x62100001bca0, TLLI=d7e9ab95, SAPI=3, NSAPI=5)
osmo-sgsn/src/gprs/sgsn_libgtp.c:310 PDP(---/0) Delete PDP Context
osmo-sgsn/src/gprs/gprs_gmm.c:2294 MM(---/ffffffff) <- DEACTIVATE PDP CONTEXT REQ
osmo-sgsn/src/gprs/gprs_gmm.c:305:25: runtime error: member access within null pointer of type 'const struct sgsn_mm_ctx'

Program received signal SIGSEGV, Segmentation fault.
0x0000555555698c1b in mmctx2msgid (msg=0x61d0000172e0, mm=0x0)
    at /home/pespin/dev/sysmocom/git/osmo-sgsn/src/gprs/gprs_gmm.c:305
305             msgb_tlli(msg) = mm->gb.tlli;
(gdb) bt
 #0  0x0000555555698c1b in mmctx2msgid (msg=0x61d0000172e0, mm=0x0)
    at osmo-sgsn/src/gprs/gprs_gmm.c:305
 #1  0x00005555556b170a in _gsm48_tx_gsm_deact_pdp_req (mm=0x0, tid=0 '\000',
    sm_cause=38 '&')
    at osmo-sgsn/src/gprs/gprs_gmm.c:2297
 #2  0x00005555556b1a2e in gsm48_tx_gsm_deact_pdp_req (pdp=0x6140000008a0,
    sm_cause=38 '&')
    at osmo-sgsn/src/gprs/gprs_gmm.c:2311
 #3  0x00005555556b876c in pdpctx_timer_cb (_pdp=0x6140000008a0)
    at osmo-sgsn/src/gprs/gprs_gmm.c:2717
 #4  0x00007ffff355eb3e in osmo_timers_update ()
    at libosmocore/src/timer.c:257
 #5  0x00007ffff356255c in osmo_select_main (polling=0)
    at libosmocore/src/select.c:254
 #6  0x00005555556f17cb in main (argc=3, argv=0x7fffffffe298)
    at osmo-sgsn/src/gprs/sgsn_main.c:531

Change-Id: I2120e53ade6cabad37f9bd99e6680a453411821b
2018-07-13 11:51:52 +02:00
Alexander Couzens 8007be41fe gprs_gmm: make extract_subscr_msisdn extract_subscr_hlr public
Change-Id: I54168e1a58dd36b38c53c13bbb5cdb4311f34410
2018-05-23 16:19:52 +00:00
Alexander Couzens d4788cdf65 gprs_gmm: make functions relating to GMM Attach Request public
GMM Attach Request will be handled in it's own file and will
use those functions.

Change-Id: Ic90d77f7b0bacd2a8e2e409e82d676772d352749
2018-05-23 16:19:52 +00:00
Neels Hofmeyr 396f2e69a0 move include/openbsc to include/osmocom/sgsn
Change-Id: I281ef585fffc2644682c8282224fb1c2da5ca795
2017-09-06 16:47:47 +02:00