neels has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/36894?usp=email )
Change subject: hnb_persistent: introduce disconnected timeout ...................................................................... hnb_persistent: introduce disconnected timeout Add timer hnbgw X35: Clean up all hNodeB persistent state after this time of the hNodeB being disconnected. Set to zero to never clear hNodeB persistent state. (default is 60*60*24*27 = a week). The idea is to bound memory usage at sites where hNodeB do not stay on one fixed cell id, but use a different cell id after each Iuh reconnection. Related: SYS#6773 Related: osmo-ttcn3-hacks Ibec009203d38f65714561b7c28edbdbd8b34e704 Change-Id: Ic819d7cbc03fb39e98c204b70d016c5170dc6307 --- M include/osmocom/hnbgw/hnbgw.h M src/osmo-hnbgw/hnbgw.c M src/osmo-hnbgw/tdefs.c 3 files changed, 58 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved osmith: Looks good to me, but someone else must approve diff --git a/include/osmocom/hnbgw/hnbgw.h b/include/osmocom/hnbgw/hnbgw.h index c28f8bc..36358b1 100644 --- a/include/osmocom/hnbgw/hnbgw.h +++ b/include/osmocom/hnbgw/hnbgw.h @@ -412,6 +412,8 @@ struct nft_kpi_val v; } dl; } nft_kpi; + + struct osmo_timer_list disconnected_timeout; }; struct ue_context { diff --git a/src/osmo-hnbgw/hnbgw.c b/src/osmo-hnbgw/hnbgw.c index 20d6aa6..6f74d04 100644 --- a/src/osmo-hnbgw/hnbgw.c +++ b/src/osmo-hnbgw/hnbgw.c @@ -44,6 +44,7 @@ #include <osmocom/hnbgw/hnbgw_cn.h> #include <osmocom/hnbgw/context_map.h> #include <osmocom/hnbgw/mgw_fsm.h> +#include <osmocom/hnbgw/tdefs.h> struct hnbgw *g_hnbgw = NULL; @@ -560,6 +561,24 @@ .item_desc = hnb_stat_desc, }; +static void hnb_persistent_disconnected_timeout_cb(void *data) +{ + hnb_persistent_free(data); +} + +static void hnb_persistent_disconnected_timeout_schedule(struct hnb_persistent *hnbp) +{ + unsigned long period_s = osmo_tdef_get(hnbgw_T_defs, -35, OSMO_TDEF_S, 60*60*24*7); + if (period_s < 1) { + LOG_HNBP(hnbp, LOGL_INFO, + "timer X35 is zero, not setting a disconnected timeout for this hnb-persistent instance.\n"); + return; + } + /* It is fine if the timer is already active, osmo_timer_del() is done implicitly by the osmo_timer API. */ + osmo_timer_setup(&hnbp->disconnected_timeout, hnb_persistent_disconnected_timeout_cb, hnbp); + osmo_timer_schedule(&hnbp->disconnected_timeout, period_s, 0); +} + struct hnb_persistent *hnb_persistent_alloc(const struct umts_cell_id *id) { struct hnb_persistent *hnbp = talloc_zero(g_hnbgw, struct hnb_persistent); @@ -583,6 +602,11 @@ if (g_hnbgw->nft_kpi.active) nft_kpi_hnb_persistent_add(hnbp); + /* Normally the disconnected timer runs only when the hNodeB is not currently connected on Iuh. This here is paranoia: + * In case we have to HNBAP HNB Register Reject, the disconnected timer should be active on this unused hnbp. + * On success, hnb_persistent_registered() will stop the disconnected timer directly after this. */ + hnb_persistent_disconnected_timeout_schedule(hnbp); + return hnbp; out_free_ctrs: @@ -645,6 +669,9 @@ return; } + /* The hNodeB is now connected, i.e. not disconnected. */ + osmo_timer_del(&hnbp->disconnected_timeout); + /* start counting traffic */ if (g_hnbgw->nft_kpi.active) hnb_persistent_update_remote_addr(hnbp); @@ -664,11 +691,15 @@ /* stop counting traffic */ nft_kpi_hnb_stop(hnbp); + + /* The hNodeB is now disconnected. Clear out hnb_persistent when the disconnected timeout has passed. */ + hnb_persistent_disconnected_timeout_schedule(hnbp); } void hnb_persistent_free(struct hnb_persistent *hnbp) { /* FIXME: check if in use? */ + osmo_timer_del(&hnbp->disconnected_timeout); nft_kpi_hnb_stop(hnbp); nft_kpi_hnb_persistent_remove(hnbp); osmo_stat_item_group_free(hnbp->statg); diff --git a/src/osmo-hnbgw/tdefs.c b/src/osmo-hnbgw/tdefs.c index cfcd4c2..5092922 100644 --- a/src/osmo-hnbgw/tdefs.c +++ b/src/osmo-hnbgw/tdefs.c @@ -36,6 +36,12 @@ {.T = 4, .default_val = 5, .desc = "Timeout to receive RANAP RESET ACKNOWLEDGE from an MSC/SGSN" }, {.T = -31, .default_val = 15, .desc = "Timeout for establishing and releasing context maps (RUA <-> SCCP)" }, {.T = -34, .default_val = 1000, .unit = OSMO_TDEF_MS, .desc = "Period to query network traffic stats from netfilter" }, + { + .T = -35, + .default_val = 60*60*24*7, + .desc = "Clean up all hNodeB persistent state after this time of the hNodeB being disconnected." + " Set to zero to never clear hNodeB persistent state. (default is 60*60*24*27 = a week)", + }, {.T = -1002, .default_val = 10, .desc = "Timeout for the HNB to respond to PS RAB Assignment Request" }, { } }; -- To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/36894?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hnbgw Gerrit-Branch: master Gerrit-Change-Id: Ic819d7cbc03fb39e98c204b70d016c5170dc6307 Gerrit-Change-Number: 36894 Gerrit-PatchSet: 3 Gerrit-Owner: neels <nhofm...@sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <lafo...@osmocom.org> Gerrit-Reviewer: neels <nhofm...@sysmocom.de> Gerrit-Reviewer: osmith <osm...@sysmocom.de> Gerrit-MessageType: merged