AgeCommit message (Collapse)AuthorFilesLines
2015-02-04sgsn: Added TODOs (TODO)jerlbeck/wip/gprs-patchingJacob Erlbeck1-0/+6
TODO: - fix and remove TODOs - add test cases for Detach(reattach) - add test cases for PDP context deletion (OW#1311) - add test cases for Cancel pending timer in sgsn_mm_ctx_free - remove this commit Sponsored-by: On-Waves ehf
2015-02-04sgsn: Add logging to connect_timer_cb (TODO)Jacob Erlbeck1-0/+3
TODO: - LOGLevel ? Sponsored-by: On-Waves ehf
2015-02-04gprs: Extend specification of GSUP cause values (TODO)Jacob Erlbeck1-10/+67
Currently, every error message contains a mandantory Cause IE just referring to GSM 04.08 for further details. This leaves the mapping from MAP User Errors to GMM Cause values undefined. It is also not specified, which GMM Cause to assume, if no User Error has been included in the MAP message. This commit makes the Cause IE conditional, it is only required if the MAP message contained a User Error. A mapping from User Errors to GMM Causes is also added. The default value for GMM Causes in GSUP error messages is now 'Network failure' to keep the impact low. TODO: - the mapping is not finished, it needs review and some values are not yet specified. Sponsored-by: On-Waves ehf
2015-02-04Revert "gprs: Block other GSUP procedures during PURGE_MS"Jacob Erlbeck4-146/+1
This reverts commit f81cacc6814dde73f203d125b0065d1451a98317. Since the PURGE MS retry mechanism had been removed, this feature is not used anymore. It just makes the code more complex. Conflicts: openbsc/include/openbsc/gprs_sgsn.h openbsc/src/gprs/gprs_subscriber.c openbsc/tests/sgsn/sgsn_test.c
2015-02-04sgsn: Select GGSN based on APNJacob Erlbeck5-6/+258
Currently the APN IE in the Activate PDP Contex Request and the PDP data that is stored with the subscriber is ignored completely. This commit adds the sgsn_mm_ctx_find_ggsn_ctx that checks the APN IE against the subscriber's PDP data entries if both are present. If there is no match, the request is rejected. If an APN IE has not been included but PDP data entries are present, the function checks all of these entries against the static 'apn' configuration to find a suitable entry. If an APN has not been determined so far and any APN is allowed, the configuration is checked with an empty APN string, to allow for default configurations based on the IMSI prefix only. If nothing of this succeeded but the request wasn't rejected either, and there is no 'apn' configuration at all or if any APN is allowed but a default configuration ist not present, the GGSN with id 0 is used (if present). Otherwise the request is rejected ('missing APN'). Ticket: OW#1334 Sponsored-by: On-Waves ehf
2015-02-04sgsn: Add sgsn_ggsn_ctx_free functionJacob Erlbeck2-0/+7
This function will be needed for testing, since the leak check would fail if the GGSN context are not cleaned up after use. Sponsored-by: On-Waves ehf
2015-02-04sgsn: Add functions to handle APN contextsJacob Erlbeck6-13/+249
This commit adds the exported functions apn_ctx_find_alloc, apn_ctx_free, apn_ctx_by_name, and apn_ctx_match to manage and retrieve APN to GGSN mappings. The following VTY commands are added to 'config-sgsn': - apn APN ggsn <0-255> - apn APN imsi-prefix PREFIX ggsn <0-255> which maps an APN gateway string to an SGSN id. The SGSN must be configured in advance. When matching an APN string, entries with a leading '*' are used for suffix matching, otherwise an exact match is done. When a prefix is given, it is matched against the IMSI. If several entries match, a longer matching IMSI prefix has precedence. If there are several matching entries with the same PREFIX, the entry with longest matching APN is returned. Ticket: OW#1334 Sponsored-by: On-Waves ehf
2015-02-04sgsn: Add PDP info to subscriber dataJacob Erlbeck4-9/+104
Currently the PDP info that is transmitted via GSUP is just parsed and then discarded. This commit adds a new data structure sgsn_subscriber_pdp_data and maintains a list of those in sgsn_subscriber_data. The PDP data is copied from an incoming GSUP UpdateLocationResult message. If that message contains the PDPInfoComplete flag, the list is cleared before new entries are added. The 'show subscriber cache' output now also shows the PDP data entries. Note that the InsertSubscriberData message is still not supported. Sponsored-by: On-Waves ehf
2015-01-31bsc/nitb: Allow to set the GPRS mode through the ctrl commandHolger Hans Peter Freyther5-14/+86
Create a control command to read and modify the gprs mode. Use the get_string_value to indicate if the value was found or not. This is useful for the ctrl interface where I didn't want to replicate "none", "gprs" and "egprs". Share code to verify that a BTS supports the mode. Related: SYS#591
2015-01-31ctrl/bsc: Fix copy and paste error and update textHolger Hans Peter Freyther3-3/+5
30f1f376383df3ae8d85e96542bf14d174c25d89 introduced new channel combinations but had a copy and paste error in the description. The jenkins system didn't run the external tests so this issue and others were not noticed until now. Fix the copy and paste and update the test result.
2015-01-31rsl: Remove unused code for channel activationHolger Hans Peter Freyther1-35/+0
The code has been unused for a long time. Let's remove it.
2015-01-31meas: Install the scenario command and test itHolger Hans Peter Freyther2-0/+25
2015-01-31meas: Add VTY documentation for the measurement commandsHolger Hans Peter Freyther1-2/+3
Document the parameters that can be passed on.
2015-01-30sgsn/test: Fix memory leak in test_subscriber_gsupJacob Erlbeck1-6/+9
Currently the MM context is not deleted when a GSUP location cancellation message is processed, because the real sgsn_update_subscriber_data function has been wrapped to a dummy implementation. This commit adds an explicit call to sgsn_mm_ctx_cleanup_free which also unassigns the LLME, so the call to gprs_llgmm_assign is removed. It also adds an assertion to check that there are no talloc'ed blocks left in tall_bsc_ctx. Addresses: == 372 bytes in 1 blocks are possibly lost in loss record 7 of 9 == at 0x402A17C: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) == by 0x4059FB8: _talloc_zero (talloc.c:354) == by 0x8055B82: sgsn_mm_ctx_alloc (gprs_sgsn.c:167) == by 0x804A336: alloc_mm_ctx (sgsn_test.c:140) == by 0x804B24D: test_subscriber_gsup (sgsn_test.c:503) == by 0x804EC99: main (sgsn_test.c:1853) Sponsored-by: On-Waves ehf
2015-01-30sgsn/test: Add checks for subscr->error_causeJacob Erlbeck1-0/+4
This commits adds a few asserts that check the value of subscr->error_cause after a GSUP message has been received. Sponsored-by: On-Waves ehf
2015-01-30gprs: Use 'Network failure' as default causeJacob Erlbeck2-0/+13
This commit adds a check after a GSUP message has been decoded whether it is an error message and does not contain a cause value. If his is the case, the cause value is set to 'Network failure', so that this cause if effectively the default value for error messages. Sponsored-by: On-Waves ehf
2015-01-30gprs/test: Fix GSUP Purge MS response messagesJacob Erlbeck1-2/+2
Currently the message types for these message types are wrong. This patch inserts the correct message types. Sponsored-by: On-Waves ehf
2015-01-30sgsn/test: Add tests for PurgeMs responsesJacob Erlbeck1-0/+30
Currently there are not any test cases for PurgeMS GSUP messages in test_subscriber_gsup. This commit adds tests for incoming PurgeMSResult and -Error messages. Sponsored-by: On-Waves ehf
2015-01-30gprs: Send GSUP error reply for requests without IMSIJacob Erlbeck1-1/+7
Currently gprs_subscr_rx_gsup_message returns immediately after it detects that an IMSI has not been given in the received GSUP message. While this is ok for responses (result or error), a request should always be answered. This commit adds code to reply with a corresponding error message ("Invalid mandatory information") when it receives a request without an IMSI. Note that the generated error message will not contain an IMSI either. Sponsored-by: On-Waves ehf
2015-01-30gprs: Support cancellation typeJacob Erlbeck3-5/+25
The cancellation type that is part of the UpdateCancellation message is currently ignored. This patch adds the missing glue between the existing GSUP and GMM support. If the type is not present or has the value updateProcedure the subcriber and MM context are siliently removed. Otherwise, a message with cause 'implicitly detached' is sent to the MS. Since the real cause is not known (the specification neither added a cause IE nor defined a static cause value), the MS may get the real cause in the following AttachRej. Added VTY commands: - update-subscriber imsi IMSI cancel update-procedure - update-subscriber imsi IMSI cancel subscription-withdraw the old form without the cause is no longer supported. Sponsored-by: On-Waves ehf
2015-01-28gprs: Handle PURGE MS ERR/RES without subscrJacob Erlbeck1-2/+29
Currently the subscr entry is no longer present, when PURGE MS ERROR/RESULT arrives. In this case, an unspecific notice is logged ('unknown IMSI'). This clutters up the logfile with notices even in perfectly normal operation. This commit changes the code path that is used when a subscr cannot be found for an incoming GSUP message. A check for PURGE MS RESULT and ERROR is added and gprs_subscr_handle_gsup_purge_no_subscr is called for these messages instead of gprs_subscr_handle_unknown_imsi. Sponsored-by: On-Waves ehf
2015-01-28gprs: Don't use subscr->keep_in_ram in normal operationJacob Erlbeck3-2/+30
Currently the keep_in_ram flag is explicitely reset in gprs_subscr_cleanup to cover the case, that the VTY 'create' sub-command has been used to create the subscriber entry. This commit completely removes keep_in_ram handling from gprs_subscriber.c and adds a VTY 'destroy' sub-command to reset the flag and remove the entry. So 'create' and 'destroy' can be used to manager sticky entries that are kept even when a location cancellation is done. Added VTY command: - update-subscriber imsi IMSI destroy Sponsored-by: On-Waves ehf
2015-01-28sgsn: Add sgsn_mm_ctx_cleanup_free for safe shutdownJacob Erlbeck4-39/+35
Currently the MM context cleanup code is distributed over several functions. sgsn_mm_ctx_free not only frees data structure but also eventually stops the timer and does the subscriber clean-up. mm_ctx_cleanup_free (gprs_gmm.c) cleans up the PDP contexts and unassign the TLLI. This commit moves the cleanup code from both functions into a new unifying function sgsn_mm_ctx_cleanup_free that cares about the clean-up of all related sub-systems. Sponsored-by: On-Waves ehf
2015-01-28sgsn: Don't allow mmctx == NULL in sgsn_update_subscriber_dataJacob Erlbeck4-33/+18
Currently, sgsn_update_subscriber_data can be called with mmctx == NULL and will find and associate the right context (if present) based on the subscriber's IMSI. This will not happen in regular use any more, since sgsn_update_subscriber_data will only be called when subscribers are used (auth mode 'remote') and in this case gprs_subscr_get_or_create_by_mmctx will already be called by sgsn_auth_request. Therefore, MM context and subscriber are always associated except for some test cases and experimental VTY usage. The current implementation of sgsn_update_subscriber_data also causes additional complexity for the deletion on MM contexts to avoid a ipossible double-free MM contexts. This commit removes the MM context <-> subscriber association code from sgsn_update_subscriber_data. That function must always be called with mmctx != NULL, now. To avoid problems with VTY and test usage, the calling subscriber function now only call sgsn_update_subscriber_data when mmctx != NULL, since the purpose of that function is to update that state of an existing MM context after subscriber data has been changed. Sponsored-by: On-Waves ehf
2015-01-27nitb: Make the last change configurableHolger Hans Peter Freyther3-0/+49
Introduce a NITB node and add the subscriber creation as config name in there.
2015-01-27nitb: Allow the network to decide if a subscriber should be createdHolger Hans Peter Freyther3-9/+23
2015-01-27gbproxy: Remove dummy definition of subscr_putJacob Erlbeck1-3/+0
The definition of subscr_put in gb_proxy_main.c will break linking if symbols from libcommon are used. Since subscr_put is in libcommon, there is no need for this dummy definition anymore. This patch removes the dummy definition. Adresses: ../../src/libcommon/libcommon.a(gsm_subscriber_base.o): In function `subscr_put': /home/jerlbeck/git/build/openbsc/openbsc/src/libcommon/gsm_subscriber_base.c:90: multiple definition of `subscr_put' gb_proxy_main.o:/home/jerlbeck/git/build/openbsc/openbsc/src/gprs/gb_proxy_main.c:56: first defined here Sponsored-by: On-Waves ehf
2015-01-27sgsn: Don't reset mm->subscr manually in sgsn_mm_ctx_freeJacob Erlbeck1-3/+1
Currently the sgsn_mm_ctx_free contains code to reset the mm->subscr field that is also present in gprs_subscr_cleanup, which is called directly afterwards. This commit modifies the code path, so that the cleanup is done by the gprs_subscr_cleanup function. The additional reference counter increment is needed, since mm->subscr->mm->subscr (which is the same like mm->subscr) will be reset (and unref'd) within gprs_subscr_cleanup. Because the local variable subscr in sgsn_mm_ctx_free is an additional pointer to the subscriber object, it is consequent to adjust the reference counter when the assignment is done. Sponsored-by: On-Waves ehf
2015-01-27gprs: Rename gprs_subscr_delete to gprs_subscr_cleanupJacob Erlbeck4-7/+7
The old name is somewhat misleading. The function is rather preparing the subscriber for a subsequent subscr_free, that is possibly invoked by a subscr_put. It detaches the subscriber from the MM context and optionally invokes a PURGE_MS procedure. Therefore the _cleanup suffix is chosen (see mm_ctx_cleanup_free). Sponsored-by: On-Waves ehf
2015-01-27gprs: Don't check for EINPROGRESS in gprs_gsup_client_createJacob Erlbeck1-1/+1
Currently, the return value of gsup_client_connect is checked whether it is < 0 and != -EINPROGESS. Since gsup_client_connect will only return a negative value on a few permanent errors (not including EINPROGRESS), rc is always != EINPROGRESS. This patch removes the explicit check againt -EINPROGRESS and just leaves the check rc < 0. Sponsored-by: On-Waves ehf
2015-01-27gb_proxy: No need to copy optargHolger Hans Peter Freyther1-1/+1
Fixes: Coverity CID 1206578
2015-01-26sgsn: Ensure 0-terminated imsi strings (Coverity)Jacob Erlbeck2-4/+4
Currently the size argument of strncpy is set to sizeof(mm->imsi) in some places. If the source IMSI string is too long, the terminating NUL byte in the static mm->imsi field gets overwritten. This patch limits the size to sizeof(mm->imsi)-1, so that the last byte of the buffer (that has been initialized to 0) is not overwritten. Fixes: Coverity CID 12065751, 12065754, 1206575 Sponsored-by: On-Waves ehf
2015-01-26gprs: Do not put the subscr in gprs_subscr_deleteJacob Erlbeck5-6/+10
Currently gprs_subscr_delete implicitely calls subscr_put, which makes the code more complex than necessary (additional subscr_get) in a few places. It also makes it more difficult to see, whether get/put are balanced within a function. In addition, the functions are not named consistently (gprs_subscr_delete vs. gprs_subscr_put_and_cancel). This commit changes the semantics of gprs_subscr_delete and indirectly of gprs_subscr_put_and_cancel to not call subscr_put on their argument, but to leave that for the caller to do it explicitely. It renames gprs_subscr_put_and_cancel to gprs_subscr_cancel to reflect that change in the name, too. Sponsored-by: On-Waves ehf
2015-01-26sgsn: Remove the "permanent" subscriber cacheHolger Hans Peter Freyther5-192/+15
The subscriber cache would help in case: * GPRS DETACH, GPRS ATTACH. In that case we might still have some cached authentication tuples we avoid another sendAuthenticationInfo request. * After a detach the cache expiry would make sure to eventually send a purgeMS to the HLR (which might be ignored). At the same time to make the cache work we will need to make sure to start and stop timers. In case we don't start we might accumulate subscribers. I am afraid that the above two benefits do not outweight the complexity of this implementation.
2015-01-26sgsn: Remove MM from the list before gprs_subscr_delete is calledHolger Hans Peter Freyther1-3/+3
Modify sgsn_mm_ctx_free to remove the entry from the list as otherwise we might double free the context from within gprs_subscriber_delete.
2015-01-26sgsn: Remove inactive LLME/MM after inactivity timeoutJacob Erlbeck11-3/+92
Currently old LLMEs and MM contexts that haven't been explicitly detached or cancelled are not removed until another request with the same IMSI is made. These stale entries may accumulate over time and severely compromise the operation of the SGSN. This patch implements age based LLME expiry, when the maximum age has been reached, the corresponding MM context is cancelled. If such an MM context doesn't exist, the LLME is unassigned directly. The implementation works as follows. - llme->age_timestamp is reset on each received PTP LLC message - sgsn_llme_check_cb is invoked periodically (each 30s) - sgsn_llme_check_cb sets the age_timestamp to the current time if it has been reset - sgsn_llme_check_cb computes the age and expires the LLME if it exceeds gprs_max_time_to_idle() Ticket: OW#1364 Sponsored-by: On-Waves ehf [hfreyther: Fix typo in comment LMME -> LLME]
2015-01-26gprs: Use a macro value to set the 'Periodic RA update timer'Jacob Erlbeck1-2/+5
Currently the T3312 timer is directly set as encoded value when generating the Attach/RAU Accept messages. This patch adds GSM0408_T3312_SECS and uses it to set the information element's value. Sponsored-by: On-Waves ehf
2015-01-26gprs: Add 'Negotiated READY timer value' IE to Attach/RAU AcceptJacob Erlbeck1-2/+12
Currently this optional IE is omitted, so that the optional 'Requested READY timer value' of the corresponding Request message is used by the MS (or the default value if this IE is not used). This patch extends gsm48_tx_gmm_att_ack and gsm48_tx_gmm_ra_upd_ack to always include the IE set to the default value of T3312 (44s, see GSM 04.08, table 11.4a). Ticket: OW#1364 Sponsored-by: On-Waves ehf
2015-01-26gprs: Add GPRS timer conversion functionsJacob Erlbeck5-1/+123
Currently, all GPRS timer values are hard-coded. To make these values configurable in seconds and to show them, conversion functions from and to seconds are needed. This patch adds gprs_tmr_to_secs and gprs_secs_to_tmr_floor. Due to the limited number of bits used to encode GPRS timer values, only a few durations can be represented. gprs_secs_to_tmr_floor therefore always returns the timer value that represents either the exact number (if an exact representation exists) or the next lower number for that an exact representation exists. Sponsored-by: On-Waves ehf
2015-01-26gprs: Return 0 from gsup_client_connect if ok or retry timer enabledJacob Erlbeck1-1/+4
Currently the gsup_client_connect return 0 if the call to ipa_client_conn_open was successful and -errno otherwise. This makes it difficult for the caller to determine, whether the the whole operation has been cancelled (currently on EBADF, ENOTSOCK, EAFNOSUPPORT, EINVAL) or whether the GSUP client will retry to connect after a timeout. This will cause gprs_gsup_client_create to destroy the GSUP client object, even if the error might be temporary. This patch changes the function to return 0 if (and only if) ipa_client_conn_open was successful or the retry timer has been started. Since the return value 0 doesn't guarantee, that a subsequent call to gprs_gsup_client_send will succeed, this shouldn't break anything. Sponsored-by: On-Waves ehf
2015-01-21osmux: Initialize the socket only onceHolger Hans Peter Freyther1-3/+5
The per BSC code didn't guard against the init already having been executed. This lead to: Adding a osmo_fd that is already in the list. <000b> bsc_nat_vty.c:1200 Setting up OSMUX socket So a new socket got created and the old one leaked. Luckily Linux appears to allow to bind multiple times so we were able to just read from the new one. Use the same guard that is used on the MGCP MGW. Re-order the log message to say "Setting up" before we actually do that. I manually verified that osmux_init is called at most once. The log message was spotted by Roch
2015-01-21debian: Fix dependenciesJacob Erlbeck1-2/+2
The dependecies do not match the current package names or are missing: Build-Depends: - renamed libgtp-dev -> libgtp0-dev - added libosmo-netif-dev Depends: - renamed libgtp -> libgtp0 Other run time dependencies might still be missing and have to be installed manually. This is taken from Holger's e744ebd17c3761b5cad81d718d0349f2f820ec66. In addition, the build-dependency on libgtp-dev is replaced by libgtp0-dev.
2015-01-21mgcp: Honor the rtp IP_TOS settings for OsmuxHolger Hans Peter Freyther4-4/+7
Honor the IP_TOS settings for Osmux as well. Re-use the RTP setting as it makes sense to classify the audio packets the same way. Fixes: OW#1369
2015-01-20sgsn: Restructure the 'update-subscriber' commandJacob Erlbeck2-39/+12
This patch drops the following commands: - update-subscriber imsi IMSI insert authorized <0-1> - update-subscriber imsi IMSI commit since they are already covered by the 'update-location-result' sub-command, except that this command doesn't create an new entry if none is found with the given IMSI. It adds the following command: - update-subscriber imsi IMSI create which can be used to create a new entry. Sponsored-by: On-Waves ehf
2015-01-20sgsn: Fix vty_out newlinesJacob Erlbeck1-11/+21
Currently '\n' is used to end lines in the VTY output string constants instead of inserting VTY_NEWLINE. This leads to incorrect line starts in error messages. This patch fixes that accordingly. Sponsored-by: On-Waves ehf
2015-01-20sgsn: Add SGSN_ERROR_CAUSE_NONE and use it instead of 0Jacob Erlbeck5-9/+29
Currently an error_cause of 0 is being used to indicate normal operation. Albeit this is not a defined GMM cause, the value is not explicitly reserved. This commit adds the macro SGSN_ERROR_CAUSE_NONE and uses it for initialisation (instead of relying on talloc_zero) and comparisons. The value is set to -1 to be on the safe side. The VTY code is updated to set the error_cause when using the 'update-subscriber imsi IMSI update-location-result CAUSE' command. Sponsored-by: On-Waves ehf
2015-01-20sgsn: Fix access to subscr in sgsn_auth_update (Coverity)Jacob Erlbeck1-1/+1
Currently the access to subscr->sgsn_data->error_cause is not protected against subscr == NULL like it is done in other code paths of sgsn_auth_update. This commit adds a conditional to avoid a NULL-dereference. Fixes: Coverity CID 1264589 Sponsored-by: On-Waves ehf
2015-01-20sgsn/test: Make assert_substr safer (Coverity)Jacob Erlbeck1-2/+3
Currently, if assert_subscr were called with subscr == NULL, the later call to subscr_put might fail, as Coverity has complained. In addition, the call to subscr_put would free the subscr object if it were in the cache with a refcount of 0 at the time assert_substr was called. This patch adds a check for the subscr being non-NULL and reorders the checks, so that the subscr_put comes last. Fixes: Coverity CID 1264590 Sponsored-by: On-Waves ehf
2015-01-20sgsn: Fix P-TMSI generator's distance of equal valuesJacob Erlbeck1-2/+26
Currently sgsn_alloc_ptmsi uses rand() to get a new P-TMSI and then sets to upper 2 MSB. Therefore there is no lower limit of the distance between 2 identical P-TMSI. This patch changes the implementation to discard any random value above 2^30 and to generate a new random number in that case until a fitting number is found (or a repetition limit is reached). This way, all number below 2^30 within the PRNG's period are used. Ticket: OW#1362 Sponsored-by: On-Waves ehf
2015-01-20gprs: Support the full cancellation procedureJacob Erlbeck2-5/+35
Currently no GSUP LocationCancellationResult message is sent back to the peer (HLR), if the procedure succeeded at the SGSN's side. This patch adds the missing message and put the whole request handling of this procedure into a separate function. Ticket: OW#1338 Sponsored-by: On-Waves ehf