Change in osmo-sgsn[master]: vty: add cmd "reset sgsn state"

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

lynxis lazus gerrit-no-reply at lists.osmocom.org
Mon Aug 13 15:53:52 UTC 2018


lynxis lazus has submitted this change and it was merged. ( https://gerrit.osmocom.org/10370 )

Change subject: vty: add cmd "reset sgsn state"
......................................................................

vty: add cmd "reset sgsn state"

Reset the SGSN internal state. Useful when testing the SGSN via TTCN3.
Depends on the libosmocore commit:
I29b6ad6742ddf9b0b58b4af37d9a1cf18e019325

Change-Id: I92096f3f6ea49e75676e30e9921d00210bac5382
---
M src/gprs/sgsn_vty.c
1 file changed, 32 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/src/gprs/sgsn_vty.c b/src/gprs/sgsn_vty.c
index 8092158..057be9f 100644
--- a/src/gprs/sgsn_vty.c
+++ b/src/gprs/sgsn_vty.c
@@ -34,6 +34,7 @@
 #include <osmocom/sgsn/debug.h>
 #include <osmocom/sgsn/sgsn.h>
 #include <osmocom/gprs/gprs_ns.h>
+#include <osmocom/sgsn/gprs_gmm.h>
 #include <osmocom/sgsn/gprs_sgsn.h>
 #include <osmocom/sgsn/vty.h>
 #include <osmocom/sgsn/gsup_client.h>
@@ -44,6 +45,8 @@
 #include <osmocom/crypt/gprs_cipher.h>
 #include <osmocom/abis/ipa.h>
 
+#include <osmocom/gprs/gprs_bssgp.h>
+
 #include <pdp.h>
 #include <gtp.h>
 
@@ -796,6 +799,34 @@
 	vty_out(vty, "    Use count: %u%s", gsub->use_count, VTY_NEWLINE);
 }
 
+DEFUN_HIDDEN(reset_sgsn_state,
+      reset_sgsn_state_cmd,
+      "reset sgsn state",
+      "Remove all known subscriber, MM ctx and flush BSSGP queues Useful when running tests against the SGSN")
+{
+	struct gprs_subscr *subscr, *tmp_subscr;
+	struct sgsn_mm_ctx *mm, *tmp_mm;
+
+	llist_for_each_entry_safe(mm, tmp_mm, &sgsn_mm_ctxts, list)
+	{
+		gsm0408_gprs_access_cancelled(mm, SGSN_ERROR_CAUSE_NONE);
+	}
+	vty_out(vty, "Cancelled MM Ctx. %s", VTY_NEWLINE);
+
+	llist_for_each_entry_safe(subscr, tmp_subscr, gprs_subscribers, entry) {
+		gprs_subscr_get(subscr);
+		gprs_subscr_cancel(subscr);
+		gprs_subscr_put(subscr);
+	}
+	vty_out(vty, "Removed all gprs subscribers.%s", VTY_NEWLINE);
+
+	bssgp_flush_all_queues();
+	vty_out(vty, "Flushed all BSSGPs queues.%s", VTY_NEWLINE);
+
+	/* remove all queues to bssgp */
+	return CMD_SUCCESS;
+}
+
 DEFUN(show_subscr_cache,
       show_subscr_cache_cmd,
       "show subscriber cache",
@@ -1310,6 +1341,7 @@
 	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);
+	install_element(ENABLE_NODE, &reset_sgsn_state_cmd);
 
 	install_element(CONFIG_NODE, &cfg_sgsn_cmd);
 	install_node(&sgsn_node, config_write_sgsn);

-- 
To view, visit https://gerrit.osmocom.org/10370
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I92096f3f6ea49e75676e30e9921d00210bac5382
Gerrit-Change-Number: 10370
Gerrit-PatchSet: 4
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180813/345c7ff0/attachment.htm>


More information about the gerrit-log mailing list