Change in libosmocore[master]: gprs_ns2_sns: rework sns clean up

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
Fri Aug 6 20:18:43 UTC 2021


lynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/25145 )


Change subject: gprs_ns2_sns: rework sns clean up
......................................................................

gprs_ns2_sns: rework sns clean up

Move the cleanup into it's own state. Also changing the
SGSN unconfigured state which won't be triggered when a
SIZE is received.

Change-Id: I2639345fdf3cd300a934238d676c543065ceaa8b
---
M src/gb/gprs_ns2_sns.c
1 file changed, 33 insertions(+), 16 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/45/25145/1

diff --git a/src/gb/gprs_ns2_sns.c b/src/gb/gprs_ns2_sns.c
index b856eab..aee37fa 100644
--- a/src/gb/gprs_ns2_sns.c
+++ b/src/gb/gprs_ns2_sns.c
@@ -2059,6 +2059,29 @@
  * SGSN role
  ***********************************************************************/
 
+/* cleanup all state. If nsvc is given, don't remove this nsvc. (nsvc is given when a SIZE PDU received) */
+static void ns2_clear_sgsn(struct ns2_sns_state *gss, struct gprs_ns2_vc *size_nsvc)
+{
+	struct gprs_ns2_vc *nsvc, *nsvc2;
+
+	ns2_clear_elems(&gss->local);
+	ns2_clear_elems(&gss->remote);
+	llist_for_each_entry_safe(nsvc, nsvc2, &gss->nse->nsvc, list) {
+		/* Ignore the NSVC over which the SIZE PDU got received */
+		if (size_nsvc && size_nsvc == nsvc)
+			continue;
+
+		gprs_ns2_free_nsvc(nsvc);
+	}
+}
+
+static void ns2_sns_st_sgsn_unconfigured_onenter(struct osmo_fsm_inst *fi, uint32_t old_state)
+{
+	struct ns2_sns_state *gss = (struct ns2_sns_state *) fi->priv;
+
+	ns2_clear_sgsn(gss, NULL);
+}
+
 static void ns2_sns_st_sgsn_unconfigured(struct osmo_fsm_inst *fi, uint32_t event, void *data)
 {
 	struct ns2_sns_state *gss = (struct ns2_sns_state *) fi->priv;
@@ -2154,6 +2177,7 @@
 				  S(GPRS_SNS_ST_SGSN_WAIT_CONFIG),
 		.name = "UNCONFIGURED",
 		.action = ns2_sns_st_sgsn_unconfigured,
+		.onenter = ns2_sns_st_sgsn_unconfigured_onenter,
 	},
 	[GPRS_SNS_ST_SGSN_WAIT_CONFIG] = {
 		.in_event_mask = S(GPRS_SNS_EV_RX_CONFIG) |
@@ -2167,6 +2191,7 @@
 	[GPRS_SNS_ST_SGSN_WAIT_CONFIG_ACK] = {
 		.in_event_mask = S(GPRS_SNS_EV_RX_CONFIG_ACK),
 		.out_state_mask = S(GPRS_SNS_ST_UNCONFIGURED) |
+				  S(GPRS_SNS_ST_SGSN_WAIT_CONFIG) |
 				  S(GPRS_SNS_ST_SGSN_WAIT_CONFIG_ACK) |
 				  S(GPRS_SNS_ST_CONFIGURED),
 		.name = "SGSN_WAIT_CONFIG_ACK",
@@ -2178,7 +2203,8 @@
 				 S(GPRS_SNS_EV_RX_DELETE) |
 				 S(GPRS_SNS_EV_RX_CHANGE_WEIGHT) |
 				 S(GPRS_SNS_EV_REQ_NSVC_ALIVE),
-		.out_state_mask = S(GPRS_SNS_ST_UNCONFIGURED),
+		.out_state_mask = S(GPRS_SNS_ST_UNCONFIGURED) |
+				  S(GPRS_SNS_ST_SGSN_WAIT_CONFIG),
 		.name = "CONFIGURED",
 		/* shared with BSS side; once configured there's no difference */
 		.action = ns2_sns_st_configured,
@@ -2281,23 +2307,14 @@
 		/* perform state reset, if requested */
 		flag = *TLVP_VAL(tp, NS_IE_RESET_FLAG);
 		if (flag & 1) {
-			struct gprs_ns2_vc *nsvc, *nsvc2;
 			/* clear all state */
-			osmo_fsm_inst_state_chg(fi, GPRS_SNS_ST_UNCONFIGURED, 0, 0);
+			/* TODO: ensure gss->sns_nsvc is always the NSVC on which we received the SIZE PDU */
 			gss->N = 0;
-			ns2_clear_elems(&gss->local);
-			ns2_clear_elems(&gss->remote);
-			llist_for_each_entry_safe(nsvc, nsvc2, &gss->nse->nsvc, list) {
-				if (nsvc == gss->sns_nsvc) {
-					/* keep the NSVC we need for SNS, but unconfigure it */
-					nsvc->sig_weight = 0;
-					nsvc->data_weight = 0;
-					ns2_vc_force_unconfigured(nsvc);
-				} else {
-					/* free all other NS-VCs */
-					gprs_ns2_free_nsvc(nsvc);
-				}
-			}
+			ns2_clear_sgsn(gss, gss->sns_nsvc);
+			/* keep the NSVC we need for SNS, but unconfigure it */
+			gss->sns_nsvc->sig_weight = 0;
+			gss->sns_nsvc->data_weight = 0;
+			ns2_vc_force_unconfigured(gss->sns_nsvc);
 			ns2_sns_compute_local_ep_from_binds(fi);
 		}
 

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I2639345fdf3cd300a934238d676c543065ceaa8b
Gerrit-Change-Number: 25145
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210806/c91cbf7e/attachment.htm>


More information about the gerrit-log mailing list