Change in osmo-sgsn[master]: GTP: refactor the echo timer

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
Tue Sep 18 18:09:16 UTC 2018


lynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/11023


Change subject: GTP: refactor the echo timer
......................................................................

GTP: refactor the echo timer

The gtp echo timer must be re-check everytime the
echo-timer has been modified or deactivated.

Fixes the TTCN3 SGSN_Tests.TC_attach_restart_ctr_echo

Change-Id: Ia33471a9a9cfc3887facb665c82094b99932052a
---
M include/osmocom/sgsn/gprs_sgsn.h
M src/gprs/gprs_sgsn.c
M src/gprs/sgsn_vty.c
3 files changed, 20 insertions(+), 6 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/23/11023/1

diff --git a/include/osmocom/sgsn/gprs_sgsn.h b/include/osmocom/sgsn/gprs_sgsn.h
index f745685..2658bd6 100644
--- a/include/osmocom/sgsn/gprs_sgsn.h
+++ b/include/osmocom/sgsn/gprs_sgsn.h
@@ -375,6 +375,7 @@
 int sgsn_ggsn_ctx_drop_all_pdp_except(struct sgsn_ggsn_ctx *ggsn, struct sgsn_pdp_ctx *except);
 void sgsn_ggsn_ctx_add_pdp(struct sgsn_ggsn_ctx *ggc, struct sgsn_pdp_ctx *pdp);
 void sgsn_ggsn_ctx_remove_pdp(struct sgsn_ggsn_ctx *ggc, struct sgsn_pdp_ctx *pdp);
+void sgsn_ggsn_ctx_check_echo_timer(struct sgsn_ggsn_ctx *ggc);
 
 struct apn_ctx {
 	struct llist_head list;
diff --git a/src/gprs/gprs_sgsn.c b/src/gprs/gprs_sgsn.c
index dc0e7c0..16ba979 100644
--- a/src/gprs/gprs_sgsn.c
+++ b/src/gprs/gprs_sgsn.c
@@ -489,12 +489,24 @@
 	talloc_free(pdp);
 }
 
+void sgsn_ggsn_ctx_check_echo_timer(struct sgsn_ggsn_ctx *ggc)
+{
+	if (llist_empty(&ggc->pdp_list) || ggc->echo_interval <= 0) {
+		/* stop timer */
+		if (osmo_timer_pending(&ggc->echo_timer))
+			osmo_timer_del(&ggc->echo_timer);
+	} else {
+		/* re-start timer */
+		sgsn_ggsn_echo_req(ggc);
+		osmo_timer_schedule(&ggc->echo_timer, ggc->echo_interval, 0);
+	}
+}
+
 /* GGSN contexts */
 static void echo_timer_cb(void *data)
 {
 	struct sgsn_ggsn_ctx *ggc = (struct sgsn_ggsn_ctx *) data;
-	sgsn_ggsn_echo_req(ggc);
-	osmo_timer_schedule(&ggc->echo_timer, ggc->echo_interval, 0);
+	sgsn_ggsn_ctx_check_echo_timer(ggc);
 }
 
 struct sgsn_ggsn_ctx *sgsn_ggsn_ctx_alloc(uint32_t id)
@@ -742,15 +754,14 @@
 
 void sgsn_ggsn_ctx_add_pdp(struct sgsn_ggsn_ctx *ggc, struct sgsn_pdp_ctx *pdp)
 {
-	if (llist_empty(&ggc->pdp_list) && ggc->echo_interval > 0)
-		osmo_timer_schedule(&ggc->echo_timer, ggc->echo_interval, 0);
+	sgsn_ggsn_ctx_check_echo_timer(ggc);
+
 	llist_add(&pdp->ggsn_list, &ggc->pdp_list);
 }
 void sgsn_ggsn_ctx_remove_pdp(struct sgsn_ggsn_ctx *ggc, struct sgsn_pdp_ctx *pdp)
 {
 	llist_del(&pdp->ggsn_list);
-	if (llist_empty(&ggc->pdp_list) && osmo_timer_pending(&ggc->echo_timer))
-		osmo_timer_del(&ggc->echo_timer);
+	sgsn_ggsn_ctx_check_echo_timer(ggc);
 	if (pdp->destroy_ggsn)
 		sgsn_ggsn_ctx_free(pdp->ggsn);
 	pdp->ggsn = NULL;
diff --git a/src/gprs/sgsn_vty.c b/src/gprs/sgsn_vty.c
index de193f0..63985bc 100644
--- a/src/gprs/sgsn_vty.c
+++ b/src/gprs/sgsn_vty.c
@@ -383,6 +383,7 @@
 			     "not be lower than 60 seconds, use this value for " \
 			     "testing purposes only!%s", VTY_NEWLINE);
 
+	sgsn_ggsn_ctx_check_echo_timer(ggc);
 	return CMD_SUCCESS;
 }
 
@@ -395,6 +396,7 @@
 	struct sgsn_ggsn_ctx *ggc = sgsn_ggsn_ctx_find_alloc(id);
 
 	ggc->echo_interval = -1;
+	sgsn_ggsn_ctx_check_echo_timer(ggc);
 
 	return CMD_SUCCESS;
 }

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

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia33471a9a9cfc3887facb665c82094b99932052a
Gerrit-Change-Number: 11023
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180918/cf0e25f0/attachment.htm>


More information about the gerrit-log mailing list