aboutsummaryrefslogtreecommitdiffstats
path: root/src/gprs
AgeCommit message (Collapse)AuthorFilesLines
2018-07-16Add optional TearDownInd IE in PDP DEACT REQ towards PCUPau Espin Pedrol2-6/+7
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-13vty: Add cmd to disable echo loop explictlyPau Espin Pedrol1-0/+17
Change-Id: I0598427257533ce8ae9e9afa787293d7c98fed15
2018-07-13Disarm T3395 when dettaching mmctx from pdpctxPau Espin Pedrol2-3/+11
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-13osmo-sgsn: ping GGSN periodically and check for restart counterPau Espin Pedrol3-2/+53
Before this commit, echo req/rsp logic was implemented in libgtp but never used in osmo-sgsn. This commit adds a timer which periodically sends a GTP ECHO Request to every GGSN if there's at least one pdpd context associated with it. This way by checking the restart counter in the ECHO Reply it can be known if the GGSN was restarted. In this case, logic already present in osmo-sgsn will terminate all pdp contexts associated with that GGSN. Change-Id: I9d714726785407859f26bbef052cd0efc28e8dae
2018-07-13Maintain per ggsn pdp ctx listPau Espin Pedrol2-13/+14
This way we can easily track all pdp context associated to a specific ggsn, which is useful to handle some scenarios, such as the one implemented in next commit, in which specs references that GSNs should ping only other GSNs with at least one pdp ctx in common. So the list of pdp ctx per GGSN is really useful too (and cheap computationally) to check if we should arm or disarm the echo procedure timer. So this commit can be seen as a preparation for next commit. Change-Id: I3bbcc0883df2bf1290ba8d4bd70db8baa494087a
2018-07-09sgsn_libgtp.c: Log pointer of deleted contextPau Espin Pedrol1-1/+1
Change-Id: I8a4627b54090e72f86a9c5a781670be52522062b
2018-06-20Drop all references of unused MGCPPau Espin Pedrol1-2/+1
Change-Id: I1c023d773bf196d41b4251ca7011a82969acb613
2018-06-15gb_proxy: Add ctrl interface and nsvc-state, gbproxy-state commandsDaniel Willmann3-0/+104
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-05gprs_gmm: Cancel Location: use detach type IMSIAlexander Couzens1-1/+1
The detach type network side is defined as - Reattach required - Reattach not required - IMSI detach (after VLR failure) IMSI detach seems to be more close. Howeever the standard isn't clear about this. Change-Id: I27da6dc5165819cccd1ae0a98b132b45a01f38bb
2018-06-01gb_proxy: tallocate memory for gbproxy cfg so it can be a talloc ctxDaniel Willmann1-8/+14
Change-Id: Iad7cde5c08daacc3f5c4175d21d89fad25a5c3d7
2018-05-23gprs_gmm: make extract_subscr_msisdn extract_subscr_hlr publicAlexander Couzens1-2/+2
Change-Id: I54168e1a58dd36b38c53c13bbb5cdb4311f34410
2018-05-23gprs_gmm: make functions relating to GMM Attach Request publicAlexander Couzens1-5/+5
GMM Attach Request will be handled in it's own file and will use those functions. Change-Id: Ic90d77f7b0bacd2a8e2e409e82d676772d352749
2018-05-22gprs_subscriber: gsup_auth_error: reject MS in all casesAlexander Couzens1-0/+1
There is no way to recover from "PROTOCOL_ERRORS". As long the error_cause is not set, the SGSN won't send out a GMM Request Reject. Fixes: TTCN: SGGN_Tests.TC_attach_auth_sai_reject Change-Id: Iefe8f05686ef4acac721f3c0672910704f3b0ff8
2018-05-02GMM: dont reply to GMM_DETACH_REQ with POWER OFF when MS is unknownAlexander Couzens1-0/+7
Change-Id: I1d1cf64500f1295ab58d157d4d4dab16fcddbbf3
2018-05-01GERAN: allow GSM SRES on UMTS AKA challengeNeels Hofmeyr2-22/+21
Store the established security context type (GSM or UMTS) instead of the boolean flag is_authenticated. Provide the previous boolean query with thin sgsn_mm_ctx_is_authenticated() function. Knowing which security context was established will be necessary for OS#3224, i.e. using the proper ciphering key, which is not yet tested properly, and probably not correct at this stage. This change will make new SGSN_Tests.TC_attach_umts_aka_gsm_sres pass. Related: OS#3193 OS#3224 Change-Id: I36807bad3bc55c0030d4f09cb2c369714f24bec7
2018-04-30log two RA Update Request failure causesNeels Hofmeyr1-0/+5
Change-Id: Ic9c8a492abf5a707b37d9c8888c59be6e51541b8
2018-04-30auth+ciph: log is_r99 and auth typesNeels Hofmeyr1-2/+4
Change-Id: I9679b7c174df186e05171a059a6b4d870a6f16e6
2018-04-16use osmo_init_logging2(), fix regression test memleaksNeels Hofmeyr3-3/+3
Particularly gbproxy_test.c had various mem leaks, which (will) show up with gcc (Debian 7.3.0-15) 7.3.0 address sanitizer. Fix those leaks to verify that we don't have memleaks in the production code. Change-Id: Ia4204c8b3d895b42c103edecb61b99d3d22bd36f
2018-03-16compiler warnings: use enum ranap_nsap_addr_enc, constify local varNeels Hofmeyr1-1/+1
Use the proper enum ranap_nsap_addr_enc instead of int, and properly exclude that member when we're building without Iu support: sgsn_vty.c:1323:31: error: passing argument 2 of ‘ranap_iu_vty_init’ from incompatible pointer type [-Werror=incompatible-pointer-types] ranap_iu_vty_init(SGSN_NODE, &g_cfg->iu.rab_assign_addr_enc); Add const to a local var to silence compiler warning retrieving TLVP_VAL: gprs_gmm.c:1657:18: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers] uint8_t *mi = TLVP_VAL(&tp, GSM48_IE_GMM_ALLOC_PTMSI); ^~~~~~~~ Change-Id: I1168ce6425c31db3f6c3bf1f3682ae96b028c59b
2018-03-15osmo-gbproxy: use 'osmo-gbproxy.cfg' as default config nameNeels Hofmeyr1-3/+27
Like we did in osmo-sgsn in If804da17a7481e79e000fe40ae0d9c4be9722e61, move from 'osmo_gbproxy.cfg' to 'osmo-gbproxy.cfg' as default config file name. Still look for the legacy file name to not break old setups. Change-Id: I9448908d94a23001f04b6334a78739a839b91313
2018-03-15implement support for 3-digit MNC with leading zerosNeels Hofmeyr8-76/+84
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-06vty: absorb command explanations from osmo-gsm-manualsNeels Hofmeyr1-15/+38
The osmo-gsm-manuals/vty/sgsn_vty_additions.xml contained many command explanations that are redundant with the VTY online doc. Some however are more verbose / easier to understand. Absorb these into the online VTY doc here. This matches the removal in osmo-gsm-manuals change-id I71863e5056ad369d2055e9882a52a00fa999ab04. Change-Id: I35984014424412e91437b7ed71576aef3819cb1e
2018-02-14Add talloc context introspection via VTYHarald Welte3-0/+9
This requires libosmocore with Change-Id I43fc42880b22294d83c565ae600ac65e4f38b30d or later. Change-Id: I50eb1c5a28efbe4542e177ce3d0a236e75eecdd0
2018-02-13sgsn_libgtp.c: Fix typos and whitespacePau Espin Pedrol1-4/+4
Change-Id: Ic223cf378a83051603f58dacf087cc59d9f03890
2018-02-08mandatory depend on libc-ares and libgtpAlexander Couzens1-6/+0
Both library are required to build osmo-sgsn. The optional dependency was correct when osmo-sgsn was part of openbsc. Change-Id: Id608165ae490cb6c84aac1fe70412b2cb2b2587b
2018-01-30gtphub: check for gsn_addr_from_sockaddr() errorMax1-1/+3
Change-Id: I2d80b5a488e7daa0bc8f57ea304e0e1f10f6c1f5 Fixes: CID182472
2018-01-27gtphub: check for gsn_addr_from_sockaddr() errorsMax1-2/+6
Previously the return value was ignored. Check it and log error message. Change-Id: If6babdad650dc6a84e6a784fc8d3c5abe146ecc1
2018-01-19Use gsm48_encode_ra() for RAI encodingMax3-9/+9
It has stricter type signature which increase the chance of spotting misuse either via compiler warning or with automated scan. This also paves the way for gsm48_construct_ra() deprecation in libosmocore. Change-Id: I2c0f082dc7214ed57a40dad0788e34b838dfac97 Related: OS#1640
2018-01-12gtphub: make rate_ctr uniqueMax1-8/+25
* compute unique rate counter index when allocating new gtphub tunnel * propagate rate counter allocation error to upper layers * log and gracefully handle tunnel allocation error Change-Id: I0e07f95c36de369bcd0691b8d0fd47c844abe5da Related: OS#2757
2018-01-11gprs_llc: tx dl ud: make mismatching LLE not crash osmo-sgsnNeels Hofmeyr1-2/+9
On 34c3, osmo-sgsn keeps restarting. At least once, it hits the assertion that this patch replaces with an error message, to not disrupt operation. Change-Id: I07a40960920dbc594192530c3a145f9a5d2a9c81
2018-01-08Fix RAI constructionMax1-2/+2
The gsm48_construct_ra() expect 6-byte buffer while ra_id.digits is 3-byte buffer. The function fills in LAC and RAC as well so we should pass entire struct, not just 'digits' part which only store MCC/MNC. Related: OS#1640 Change-Id: I3bfda930012c792452f9fd695ed7acf46365f1df Fixes: CID57877, CID57876
2018-01-07gprs_gmm: Convert warning message to pragma messagePau Espin Pedrol1-1/+1
This way we can enable -Werror in builds to disallow new compilation warnings being introduced. Change-Id: If2b9a618f4219df9e013095beff52c20aacbc79e
2018-01-07cosmetic: gprs_gmm: Remove trailing whitespacePau Espin Pedrol1-2/+2
Change-Id: Ie2466268fbc4699a366856d467660b17e3f7e307
2018-01-07gprs_gmm: Remove unused variablePau Espin Pedrol1-2/+2
Fixes following compilation warning: osmo-sgsn/src/gprs/gprs_gmm.c: In function ‘gsm48_rx_gmm_service_req’: osmo-sgsn/src/gprs/gprs_gmm.c:1786:10: warning: variable ‘ciph_seq_nr’ set but not used [-Wunused-but-set-variable] uint8_t ciph_seq_nr, service_type, mi_len, mi_type; ^~~~~~~~~~~ Change-Id: If0819026a99f45df96ee6de26a71c16128e79cb8
2017-12-27Migrate from OpenSSL to osmo_get_rand_id()Max5-38/+38
This avoids potential licensing incompatibility and makes integration of Debian packaging patches easier. The libosmocore version requirements are fine already but for jenkins tests to pass we have to have Ic77866ce65acf524b768882c751a4f9c0635740b merged into libosmocore master. Related: OS#1694 Change-Id: I2b687b7f07ef05bbd861b8479cad5a958a3dde92
2017-12-26Use connection id when allocating rate countersMax1-3/+5
Due to recent libosmocore's change we can't allocate rate counters with the same name and index which are already allocated. This causes sgsn_mm_ctx_alloc_iu() failure for multiple subscribers. Fix this by using conn_id parameter from ranap_ue_conn_ctx. Change-Id: I1062ffdcac96c82269cab6f4e7ae50e28dc3aa44 Related: OS#2757
2017-12-26cosmetic: use macro for gtphub plane iterationMax1-1/+1
Change-Id: If82fcd9f6509da60e6f0d916fe107de1b38bfd18
2017-12-20Remove dead codeMax1-4/+0
Get rid of ifdefs around old unused code to improve readability. Change-Id: Ia80cf845b624d520d67143b61c9de3d49074cb8c
2017-12-20Replace '.' in counter names with ':'Max3-3/+3
The '.' is illegal character in counter names, as they are exported via CTRL interface, where '.' has a special meaning that cannot be used by strings comprising the variable name. Change-Id: I4eb6851d3577f5942ae1a9ab28d3b3ca7ab8e208
2017-12-20gsm48_rx_gmm_att_req: fix error handling: don't clean up NULL llmeNeels Hofmeyr1-1/+1
Change-Id: I78903d0846568d4e98b6e43e62bbe3c329b5bc68
2017-12-20gprs_gmm: segfault: gracefully handle failure to alloc contextNeels Hofmeyr1-0/+4
This counter allocation error I hit uncovers a segfault when allocating an MM context fails in the GSM_MI_TYPE_TMSI case: DRANAP <001a> ../../../src/osmo-iuh/src/iu_client.c:509 handle_co_initial(dir=1, proc=19) DRANAP <001a> ../../../src/osmo-iuh/src/iu_client.c:229 RNC 23: new LAC 24358 RAC 22 DMM <0002> ../../../../src/osmo-sgsn/src/gprs/gprs_gmm.c:1271 MM(---/ffffffff) -> GMM ATTACH REQUEST MI(3427325924) type="GPRS attach" DLGLOBAL <001d> ../../../src/libosmocore/src/rate_ctr.c:195 counter group 'sgsn:mmctx' already exists for index 0 DMM <0002> ../../../../src/osmo-sgsn/src/gprs/gprs_sgsn.c:272 MM(/00000000) Cannot allocate counter group Program received signal SIGSEGV, Segmentation fault. gsm48_rx_gmm_att_req (llme=0x0, msg=0x555555886950, ctx=0x0) at ../../../../src/osmo-sgsn/src/gprs/gprs_gmm.c:1375 1375 ctx->p_tmsi = tmsi; Fix it with a bit of code already present for the GSM_MI_TYPE_IMSI case just above the segfault. Change-Id: I49aa95b610f2faec52dede2e4816da47ca1dfb14
2017-12-05Show GTP version for PDP context in vtyMax1-2/+2
Change-Id: Id1692e99ae0d2b78e9473f6139e6e430fcd6a607
2017-12-05Fix display of GTP addressesMax1-5/+5
Previously we've tried to convert addresses manually which lead to wrongly displayed GTP addresses (e. g. '4.0.0.0' instead of '127.0.0.2'). Use libgtp function for conversion to fix it. Change-Id: I695a9c9497d675564a088b002299096e0dcd267d
2017-11-29Add vty cmd 'cdr trap' to send CDR through CTRL ifacePau Espin Pedrol3-27/+69
Default behavior is to have them disabled, and can be explicitly disabled too by using 'no cdr trap' cmd. Tested with osmo_ctrl.py that messages are send successfully: TRAP 0 cdr-v1 20171129125950222,901700000015254,357737055592090,555,0,5,,pdp-periodic,2731,127.0.0.2,127.0.0.1,internet,176.16.222.3,20793,10045,1 Related: OS#2360 Change-Id: I1d144d87effd934d991257a65e19cf046a938907
2017-11-29sgsn_cdr: Split log formatting into a snprintf functionPau Espin Pedrol1-30/+51
This function is going to be re-used to send TRAP messages over CTRL interface. Related: OS#2360 Change-Id: I0d87df578db1d8c220fd63376e03866895d2aa0d
2017-11-28Replace '.' in counter names with ':'Pau Espin Pedrol1-14/+14
'.' is an illegal character in counter names, as they are exported via CTRL interface, where '.' has a special meaning that cannot be used by strings comprising the variable name. Change-Id: Ie7734cc42151581897d220b445984448ceb57aed
2017-11-24use default point-code as listed on Point_Codes wiki pageNeels Hofmeyr1-1/+2
see https://osmocom.org/projects/cellular-infrastructure/wiki/Point_Codes Change-Id: Ie11f1dfcdd5889d44fefe6cc10472ef1a794cc64
2017-11-21Replace '.' in counter names with ':'Harald Welte1-23/+23
'.' is an illegal character in counter names, as they are exported via CTRL interface, where '.' has a special meaning that cannot be used by strings comprising the variable name. Change-Id: Iec382ec4ee54beb2937431f5a9d8d1171224eebb
2017-11-01vty: skip installing cmds now always installed by defaultNeels Hofmeyr3-3/+0
vty_install_default() and install_default() will soon be deprecated. Depends: I5021c64a787b63314e0f2f1cba0b8fc7bff4f09b Change-Id: Iee1b582a62921cb3205de01ff87d94881e8d411b
2017-11-01change default config filename to osmo-sgsn.cfg, not osmo_sgsn.cfgNeels Hofmeyr1-2/+26
All other Osmocom programs I know of have a default config file using a dash. Comply. Be backwards compatible: when a legacy osmo_sgsn.cfg exists but no osmo-sgsn.cfg, use the old config file instead. (Verified to work by manual tests.) Change-Id: If804da17a7481e79e000fe40ae0d9c4be9722e61