summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-01-27 12:41:19 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-01-28 20:42:58 +0100
commite988ae471d8e699a4045d77048986570349203fa (patch)
tree7f3dba3295e0b7d2123ea315cb4b76cc3473df54
parente671d254cbc294f87620c2938eb6fa2883253fcb (diff)
gprs: Don't use subscr->keep_in_ram in normal operation
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
-rw-r--r--openbsc/src/gprs/gprs_subscriber.c2
-rw-r--r--openbsc/src/gprs/sgsn_vty.c27
-rw-r--r--openbsc/tests/vty_test_runner.py3
3 files changed, 30 insertions, 2 deletions
diff --git a/openbsc/src/gprs/gprs_subscriber.c b/openbsc/src/gprs/gprs_subscriber.c
index ea5d1d8..94db742 100644
--- a/openbsc/src/gprs/gprs_subscriber.c
+++ b/openbsc/src/gprs/gprs_subscriber.c
@@ -139,8 +139,6 @@ void gprs_subscr_cleanup(struct gsm_subscriber *subscr)
gprs_subscr_purge(subscr);
subscr->flags &= ~GPRS_SUBSCRIBER_ENABLE_PURGE;
}
-
- subscr->keep_in_ram = 0;
}
void gprs_subscr_cancel(struct gsm_subscriber *subscr)
diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c
index fb6cb78..1ecb2ea 100644
--- a/openbsc/src/gprs/sgsn_vty.c
+++ b/openbsc/src/gprs/sgsn_vty.c
@@ -589,6 +589,32 @@ DEFUN(update_subscr_create, update_subscr_create_cmd,
return CMD_SUCCESS;
}
+DEFUN(update_subscr_destroy, update_subscr_destroy_cmd,
+ UPDATE_SUBSCR_STR "destroy",
+ UPDATE_SUBSCR_HELP
+ "Destroy a subscriber entry\n")
+{
+ const char *imsi = argv[0];
+
+ struct gsm_subscriber *subscr;
+
+ subscr = gprs_subscr_get_by_imsi(imsi);
+ if (!subscr) {
+ vty_out(vty, "%% subscriber record does not exist for %s%s",
+ imsi, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ subscr->keep_in_ram = 0;
+ gprs_subscr_cancel(subscr);
+ if (subscr->use_count > 1)
+ vty_out(vty, "%% subscriber is still in use%s",
+ VTY_NEWLINE);
+ subscr_put(subscr);
+
+ return CMD_SUCCESS;
+}
+
#define UL_ERR_STR "system-failure|data-missing|unexpected-data-value|" \
"unknown-subscriber|roaming-not-allowed"
@@ -699,6 +725,7 @@ int sgsn_vty_init(void)
install_element(ENABLE_NODE, &update_subscr_insert_auth_triplet_cmd);
install_element(ENABLE_NODE, &update_subscr_create_cmd);
+ install_element(ENABLE_NODE, &update_subscr_destroy_cmd);
install_element(ENABLE_NODE, &update_subscr_cancel_cmd);
install_element(ENABLE_NODE, &update_subscr_update_location_result_cmd);
install_element(ENABLE_NODE, &update_subscr_update_auth_info_cmd);
diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py
index 31fadf1..de6a708 100644
--- a/openbsc/tests/vty_test_runner.py
+++ b/openbsc/tests/vty_test_runner.py
@@ -770,6 +770,9 @@ class TestVTYSGSN(TestVTYGenericBSC):
self.assert_(res.find('Authorized: 1') >= 0)
self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 cancel', ['']))
res = self.vty.command('show subscriber cache')
+ self.assert_(res.find('1234567890') >= 0)
+ self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 destroy', ['']))
+ res = self.vty.command('show subscriber cache')
self.assert_(res.find('1234567890') < 0)
def add_nat_test(suite, workdir):