Change in osmo-sgsn[master]: sgsn: Fix echo timer not started upon first pdp ctx created

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/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Mon May 27 17:10:26 UTC 2019


Pau Espin Pedrol has uploaded this change for review. ( https://gerrit.osmocom.org/14210


Change subject: sgsn: Fix echo timer not started upon first pdp ctx created
......................................................................

sgsn: Fix echo timer not started upon first pdp ctx created

Commit 176a4d2f33865a5c0433f8679f5e68f209d7b874 moved echo timer related
code to its own function but did some mistakes when moving the logic
from several places into its own function. As a result, echo timer was
only enabled after the 2nd pdp ctx was created, instead of the expected
1st.
First, let's be consistent and always call the function *after* changing
state, since that's what the function expects. This fixes the issue.

Finally make the logic in the function more intuitive by checking in the
if clause the only case where actually the echo timer should be enabled:
Only if policy specifies so and we have at least 1 pdp ctx against that ggsn.

Fixes: 176a4d2f33865a5c0433f8679f5e68f209d7b874
Change-Id: I826030978edb61ea5a172c2b72f63758206a6246
---
M src/gprs/gprs_sgsn.c
1 file changed, 9 insertions(+), 7 deletions(-)



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

diff --git a/src/gprs/gprs_sgsn.c b/src/gprs/gprs_sgsn.c
index 01f039a..f725811 100644
--- a/src/gprs/gprs_sgsn.c
+++ b/src/gprs/gprs_sgsn.c
@@ -492,12 +492,15 @@
 
 void sgsn_ggsn_ctx_check_echo_timer(struct sgsn_ggsn_ctx *ggc)
 {
-	if (llist_empty(&ggc->pdp_list) || ggc->echo_interval <= 0) {
-		if (osmo_timer_pending(&ggc->echo_timer))
-			osmo_timer_del(&ggc->echo_timer);
-	} else {
-		if (!osmo_timer_pending(&ggc->echo_timer))
+	bool pending = osmo_timer_pending(&ggc->echo_timer);
+
+	/* Only enable if allowed by policy and at least 1 pdp ctx exists against ggsn */
+	if (!llist_empty(&ggc->pdp_list) && ggc->echo_interval > 0) {
+		if (!pending)
 			osmo_timer_schedule(&ggc->echo_timer, ggc->echo_interval, 0);
+	} else {
+		if (pending)
+			osmo_timer_del(&ggc->echo_timer);
 	}
 }
 
@@ -754,9 +757,8 @@
 
 void sgsn_ggsn_ctx_add_pdp(struct sgsn_ggsn_ctx *ggc, struct sgsn_pdp_ctx *pdp)
 {
-	sgsn_ggsn_ctx_check_echo_timer(ggc);
-
 	llist_add(&pdp->ggsn_list, &ggc->pdp_list);
+	sgsn_ggsn_ctx_check_echo_timer(ggc);
 }
 void sgsn_ggsn_ctx_remove_pdp(struct sgsn_ggsn_ctx *ggc, struct sgsn_pdp_ctx *pdp)
 {

-- 
To view, visit https://gerrit.osmocom.org/14210
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: I826030978edb61ea5a172c2b72f63758206a6246
Gerrit-Change-Number: 14210
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190527/d269a204/attachment.htm>


More information about the gerrit-log mailing list