diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2019-05-27 18:04:02 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2019-05-29 08:45:43 +0000 |
commit | 1825ab5bae0b044bb6497200b5039284162d402e (patch) | |
tree | a70a9aae4b7dd5a5d5d266692fe2d962fd43ff87 | |
parent | 20795e3fda107f4b292497337fd1a35d74482342 (diff) |
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
-rw-r--r-- | src/gprs/gprs_sgsn.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/gprs/gprs_sgsn.c b/src/gprs/gprs_sgsn.c index 01f039a66..f725811d0 100644 --- a/src/gprs/gprs_sgsn.c +++ b/src/gprs/gprs_sgsn.c @@ -492,12 +492,15 @@ void sgsn_pdp_ctx_free(struct sgsn_pdp_ctx *pdp) 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 @@ int sgsn_ggsn_ctx_drop_all_pdp_except(struct sgsn_ggsn_ctx *ggsn, struct sgsn_pd 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) { |