<p>pespin <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/osmo-hnodeb/+/26348">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, but someone else must approve
  osmith: Looks good to me, but someone else must approve
  pespin: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Implement initial shutdown + reconnect FSM<br><br>The shutdown_fsm doesn't do much right now, but it's included there in<br>order to allow easy clean up of resources upon Iuh reconnect in the<br>future, as well as reset the lower layers.<br><br>Change-Id: Id35d692218af366843186b0966b62f65bb9eb620<br>---<br>M include/osmocom/hnodeb/Makefile.am<br>A include/osmocom/hnodeb/hnb_shutdown_fsm.h<br>M include/osmocom/hnodeb/hnodeb.h<br>M src/osmo-hnodeb/Makefile.am<br>M src/osmo-hnodeb/hnb.c<br>A src/osmo-hnodeb/hnb_shutdown_fsm.c<br>M src/osmo-hnodeb/iuh.c<br>7 files changed, 202 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmocom/hnodeb/Makefile.am b/include/osmocom/hnodeb/Makefile.am</span><br><span>index 23adb2a..b1acb7e 100644</span><br><span>--- a/include/osmocom/hnodeb/Makefile.am</span><br><span>+++ b/include/osmocom/hnodeb/Makefile.am</span><br><span>@@ -1,4 +1,5 @@</span><br><span> noinst_HEADERS = \</span><br><span style="color: hsl(120, 100%, 40%);">+      hnb_shutdown_fsm.h \</span><br><span>         hnbap.h \</span><br><span>    hnodeb.h \</span><br><span>   iuh.h \</span><br><span>diff --git a/include/osmocom/hnodeb/hnb_shutdown_fsm.h b/include/osmocom/hnodeb/hnb_shutdown_fsm.h</span><br><span>new file mode 100644</span><br><span>index 0000000..dc9b357</span><br><span>--- /dev/null</span><br><span>+++ b/include/osmocom/hnodeb/hnb_shutdown_fsm.h</span><br><span>@@ -0,0 +1,42 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/* hNodeB shutdown FSM */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* (C) 2021 by sysmocom - s.m.f.c. GmbH <info@sysmocom.de></span><br><span style="color: hsl(120, 100%, 40%);">+ * Author: Pau Espin Pedrol <pespin@sysmocom.de></span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * All Rights Reserved</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+ * it under the terms of the GNU Affero General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+ * the Free Software Foundation; either version 3 of the License, or</span><br><span style="color: hsl(120, 100%, 40%);">+ * (at your option) any later version.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * You should have received a copy of the GNU Affero General Public License</span><br><span style="color: hsl(120, 100%, 40%);">+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#pragma once</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdbool.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/core/fsm.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+enum hnb_shutdown_fsm_states {</span><br><span style="color: hsl(120, 100%, 40%);">+        HNB_SHUTDOWN_ST_NONE,</span><br><span style="color: hsl(120, 100%, 40%);">+ HNB_SHUTDOWN_ST_EXIT,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+enum hnb_shutdown_fsm_events {</span><br><span style="color: hsl(120, 100%, 40%);">+   HNB_SHUTDOWN_EV_START,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+extern struct osmo_fsm hnb_shutdown_fsm;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct hnb;</span><br><span style="color: hsl(120, 100%, 40%);">+void hnb_shutdown(struct hnb *hnb, const char *reason, bool exit_proc);</span><br><span style="color: hsl(120, 100%, 40%);">+bool hnb_shutdown_in_progress(const struct hnb *hnb);</span><br><span>diff --git a/include/osmocom/hnodeb/hnodeb.h b/include/osmocom/hnodeb/hnodeb.h</span><br><span>index deb683f..3bc2fb3 100644</span><br><span>--- a/include/osmocom/hnodeb/hnodeb.h</span><br><span>+++ b/include/osmocom/hnodeb/hnodeb.h</span><br><span>@@ -26,6 +26,7 @@</span><br><span> #include <osmocom/core/write_queue.h></span><br><span> #include <osmocom/core/logging.h></span><br><span> #include <osmocom/gsm/gsm23003.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/netif/stream.h></span><br><span> </span><br><span> enum {</span><br><span>       DMAIN,</span><br><span>@@ -62,6 +63,9 @@</span><br><span> </span><br><span>       uint32_t ctx_id;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+  struct osmo_fsm_inst *shutdown_fi; /* FSM instance to manage shutdown procedure during process exit */</span><br><span style="color: hsl(120, 100%, 40%);">+        bool shutdown_fi_exit_proc; /* exit process when shutdown_fsm is finished? */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>      struct {</span><br><span>             struct hnb_chan *chan;</span><br><span>       } cs;</span><br><span>diff --git a/src/osmo-hnodeb/Makefile.am b/src/osmo-hnodeb/Makefile.am</span><br><span>index 88f2571..7325728 100644</span><br><span>--- a/src/osmo-hnodeb/Makefile.am</span><br><span>+++ b/src/osmo-hnodeb/Makefile.am</span><br><span>@@ -33,6 +33,7 @@</span><br><span>   debug.c \</span><br><span>    hnbap.c \</span><br><span>    hnb.c \</span><br><span style="color: hsl(120, 100%, 40%);">+       hnb_shutdown_fsm.c \</span><br><span>         iuh.c \</span><br><span>      nas.c \</span><br><span>      ranap.c \</span><br><span>diff --git a/src/osmo-hnodeb/hnb.c b/src/osmo-hnodeb/hnb.c</span><br><span>index 3344cfb..b7be4ea 100644</span><br><span>--- a/src/osmo-hnodeb/hnb.c</span><br><span>+++ b/src/osmo-hnodeb/hnb.c</span><br><span>@@ -26,6 +26,7 @@</span><br><span> </span><br><span> #include <osmocom/hnodeb/hnodeb.h></span><br><span> #include <osmocom/hnodeb/iuh.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/hnodeb/hnb_shutdown_fsm.h></span><br><span> </span><br><span> </span><br><span> struct hnb *hnb_alloc(void *tall_ctx)</span><br><span>@@ -41,6 +42,10 @@</span><br><span>            .mcc = 1,</span><br><span>            .mnc = 1,</span><br><span>    };</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  hnb->shutdown_fi = osmo_fsm_inst_alloc(&hnb_shutdown_fsm, hnb, hnb,</span><br><span style="color: hsl(120, 100%, 40%);">+                                           LOGL_INFO, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>   hnb_iuh_alloc(hnb);</span><br><span> </span><br><span>      return hnb;</span><br><span>@@ -48,6 +53,10 @@</span><br><span> </span><br><span> void hnb_free(struct hnb *hnb)</span><br><span> {</span><br><span style="color: hsl(120, 100%, 40%);">+   if (hnb->shutdown_fi) {</span><br><span style="color: hsl(120, 100%, 40%);">+            osmo_fsm_inst_free(hnb->shutdown_fi);</span><br><span style="color: hsl(120, 100%, 40%);">+              hnb->shutdown_fi = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span>    hnb_iuh_free(hnb);</span><br><span>   talloc_free(hnb);</span><br><span> }</span><br><span>diff --git a/src/osmo-hnodeb/hnb_shutdown_fsm.c b/src/osmo-hnodeb/hnb_shutdown_fsm.c</span><br><span>new file mode 100644</span><br><span>index 0000000..55de64c</span><br><span>--- /dev/null</span><br><span>+++ b/src/osmo-hnodeb/hnb_shutdown_fsm.c</span><br><span>@@ -0,0 +1,134 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/* hNodeB shutdown FSM */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* (C) 2021 by sysmocom - s.m.f.c. GmbH <info@sysmocom.de></span><br><span style="color: hsl(120, 100%, 40%);">+ * Author: Pau Espin Pedrol <pespin@sysmocom.de></span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * All Rights Reserved</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+ * it under the terms of the GNU Affero General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+ * the Free Software Foundation; either version 3 of the License, or</span><br><span style="color: hsl(120, 100%, 40%);">+ * (at your option) any later version.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * You should have received a copy of the GNU Affero General Public License</span><br><span style="color: hsl(120, 100%, 40%);">+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/core/fsm.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/core/tdef.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/hnodeb/hnb_shutdown_fsm.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/hnodeb/hnodeb.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/hnodeb/iuh.h></span><br><span style="color: hsl(120, 100%, 40%);">+#define X(s) (1 << (s))</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define hnb_shutdown_fsm_state_chg(fi, NEXT_STATE) \</span><br><span style="color: hsl(120, 100%, 40%);">+ osmo_fsm_inst_state_chg(fi, NEXT_STATE, 0, 0)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static void st_none_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       struct hnb *hnb = (struct hnb *)fi->priv;</span><br><span style="color: hsl(120, 100%, 40%);">+  hnb_iuh_connect(hnb); /* Start reconnect once we are done with shutdown and we didn't exit process */</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static void st_none(struct osmo_fsm_inst *fi, uint32_t event, void *data)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  struct hnb *hnb = (struct hnb *)fi->priv;</span><br><span style="color: hsl(120, 100%, 40%);">+  switch (event) {</span><br><span style="color: hsl(120, 100%, 40%);">+      case HNB_SHUTDOWN_EV_START:</span><br><span style="color: hsl(120, 100%, 40%);">+           /* TODO: here we may want to communicate t lower layers over UDsocket that we are shutting down...</span><br><span style="color: hsl(120, 100%, 40%);">+             * TODO: Also, if Iuh link is still up, maybe send a Hnb deregister req towards HNBGW</span><br><span style="color: hsl(120, 100%, 40%);">+          * TODO: also signal the hnb object somehow that we are starting to shut down?</span><br><span style="color: hsl(120, 100%, 40%);">+                 */</span><br><span style="color: hsl(120, 100%, 40%);">+           if (osmo_stream_cli_is_connected(hnb->iuh.client))</span><br><span style="color: hsl(120, 100%, 40%);">+                 osmo_stream_cli_close(hnb->iuh.client);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+          hnb_shutdown_fsm_state_chg(fi, HNB_SHUTDOWN_ST_EXIT);</span><br><span style="color: hsl(120, 100%, 40%);">+         break;</span><br><span style="color: hsl(120, 100%, 40%);">+        }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static void st_exit_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+        struct hnb *hnb = (struct hnb *)fi->priv;</span><br><span style="color: hsl(120, 100%, 40%);">+  /* TODO: here we may want to signal the hnb object somehow that we have completed the shut down? */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (hnb->shutdown_fi_exit_proc) {</span><br><span style="color: hsl(120, 100%, 40%);">+          LOGPFSML(fi, LOGL_NOTICE, "Shutdown process completed successfully, exiting process\n");</span><br><span style="color: hsl(120, 100%, 40%);">+            exit(0);</span><br><span style="color: hsl(120, 100%, 40%);">+      }</span><br><span style="color: hsl(120, 100%, 40%);">+     hnb_shutdown_fsm_state_chg(fi, HNB_SHUTDOWN_ST_NONE);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static struct osmo_fsm_state hnb_shutdown_fsm_states[] = {</span><br><span style="color: hsl(120, 100%, 40%);">+        [HNB_SHUTDOWN_ST_NONE] = {</span><br><span style="color: hsl(120, 100%, 40%);">+            .in_event_mask =</span><br><span style="color: hsl(120, 100%, 40%);">+                      X(HNB_SHUTDOWN_EV_START),</span><br><span style="color: hsl(120, 100%, 40%);">+             .out_state_mask =</span><br><span style="color: hsl(120, 100%, 40%);">+                     X(HNB_SHUTDOWN_ST_EXIT),</span><br><span style="color: hsl(120, 100%, 40%);">+              .name = "NONE",</span><br><span style="color: hsl(120, 100%, 40%);">+             .onenter = st_none_on_enter,</span><br><span style="color: hsl(120, 100%, 40%);">+          .action = st_none,</span><br><span style="color: hsl(120, 100%, 40%);">+    },</span><br><span style="color: hsl(120, 100%, 40%);">+    [HNB_SHUTDOWN_ST_EXIT] = {</span><br><span style="color: hsl(120, 100%, 40%);">+            .name = "EXIT",</span><br><span style="color: hsl(120, 100%, 40%);">+             .out_state_mask =</span><br><span style="color: hsl(120, 100%, 40%);">+                     X(HNB_SHUTDOWN_ST_NONE),</span><br><span style="color: hsl(120, 100%, 40%);">+              .onenter = st_exit_on_enter,</span><br><span style="color: hsl(120, 100%, 40%);">+  }</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+const struct value_string hnb_shutdown_fsm_event_names[] = {</span><br><span style="color: hsl(120, 100%, 40%);">+ OSMO_VALUE_STRING(HNB_SHUTDOWN_EV_START),</span><br><span style="color: hsl(120, 100%, 40%);">+     { 0, NULL }</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int hnb_shutdown_fsm_timer_cb(struct osmo_fsm_inst *fi)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ switch (fi->state) {</span><br><span style="color: hsl(120, 100%, 40%);">+       default:</span><br><span style="color: hsl(120, 100%, 40%);">+              OSMO_ASSERT(false);</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span style="color: hsl(120, 100%, 40%);">+     return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct osmo_fsm hnb_shutdown_fsm = {</span><br><span style="color: hsl(120, 100%, 40%);">+  .name = "HNB_SHUTDOWN",</span><br><span style="color: hsl(120, 100%, 40%);">+     .states = hnb_shutdown_fsm_states,</span><br><span style="color: hsl(120, 100%, 40%);">+    .num_states = ARRAY_SIZE(hnb_shutdown_fsm_states),</span><br><span style="color: hsl(120, 100%, 40%);">+    .event_names = hnb_shutdown_fsm_event_names,</span><br><span style="color: hsl(120, 100%, 40%);">+  .log_subsys = DMAIN,</span><br><span style="color: hsl(120, 100%, 40%);">+  .timer_cb = hnb_shutdown_fsm_timer_cb,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static __attribute__((constructor)) void hnb_shutdown_fsm_init(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ OSMO_ASSERT(osmo_fsm_register(&hnb_shutdown_fsm) == 0);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+bool hnb_shutdown_in_progress(const struct hnb *hnb)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+     const struct osmo_fsm_inst *fi = hnb->shutdown_fi;</span><br><span style="color: hsl(120, 100%, 40%);">+ return fi->state != HNB_SHUTDOWN_ST_NONE;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void hnb_shutdown(struct hnb *hnb, const char *reason, bool exit_proc)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  struct osmo_fsm_inst *fi = hnb->shutdown_fi;</span><br><span style="color: hsl(120, 100%, 40%);">+       if (hnb_shutdown_in_progress(hnb)) {</span><br><span style="color: hsl(120, 100%, 40%);">+          LOGPFSML(fi, LOGL_NOTICE, "hNodeB is already being shutdown.\n");</span><br><span style="color: hsl(120, 100%, 40%);">+           if (exit_proc)</span><br><span style="color: hsl(120, 100%, 40%);">+                        hnb->shutdown_fi_exit_proc = true;</span><br><span style="color: hsl(120, 100%, 40%);">+         return;</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+     hnb->shutdown_fi_exit_proc = exit_proc;</span><br><span style="color: hsl(120, 100%, 40%);">+    LOGPFSML(fi, LOGL_NOTICE, "Shutting down hNodeB, exit %u, reason: %s\n",</span><br><span style="color: hsl(120, 100%, 40%);">+             exit_proc, reason);</span><br><span style="color: hsl(120, 100%, 40%);">+  osmo_fsm_inst_dispatch(fi, HNB_SHUTDOWN_EV_START, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span>diff --git a/src/osmo-hnodeb/iuh.c b/src/osmo-hnodeb/iuh.c</span><br><span>index 3153206..79df371 100644</span><br><span>--- a/src/osmo-hnodeb/iuh.c</span><br><span>+++ b/src/osmo-hnodeb/iuh.c</span><br><span>@@ -37,6 +37,7 @@</span><br><span> #include <osmocom/hnodeb/hnbap.h></span><br><span> #include <osmocom/hnodeb/rua.h></span><br><span> #include <osmocom/hnodeb/hnodeb.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/hnodeb/hnb_shutdown_fsm.h></span><br><span> </span><br><span> static int get_logevel_by_sn_type(int sn_type)</span><br><span> {</span><br><span>@@ -100,12 +101,13 @@</span><br><span>                        NULL, NULL, &sinfo, &flags);</span><br><span>       if (rc < 0) {</span><br><span>             LOGP(DSCTP, LOGL_ERROR, "Error during sctp_recvmsg()\n");</span><br><span style="color: hsl(0, 100%, 40%);">-             /* FIXME: clean up after disappeared HNB */</span><br><span>          osmo_stream_cli_close(conn);</span><br><span style="color: hsl(120, 100%, 40%);">+          hnb_shutdown(hnb, "sctp_recvmsg() error", false);</span><br><span>          goto free_ret;</span><br><span>       } else if (rc == 0) {</span><br><span>                LOGP(DSCTP, LOGL_INFO, "Connection to HNBGW closed\n");</span><br><span>            osmo_stream_cli_close(conn);</span><br><span style="color: hsl(120, 100%, 40%);">+          hnb_shutdown(hnb, "Iuh HNBGW conn closed", false);</span><br><span>                 rc = -1;</span><br><span>             goto free_ret;</span><br><span>       } else {</span><br><span>@@ -115,6 +117,14 @@</span><br><span>      if (flags & MSG_NOTIFICATION) {</span><br><span>          union sctp_notification *notif = (union sctp_notification *) msgb_data(msg);</span><br><span>                 log_sctp_notification(notif);</span><br><span style="color: hsl(120, 100%, 40%);">+         switch (notif->sn_header.sn_type) {</span><br><span style="color: hsl(120, 100%, 40%);">+                case SCTP_SHUTDOWN_EVENT:</span><br><span style="color: hsl(120, 100%, 40%);">+                     osmo_fsm_inst_dispatch(hnb->shutdown_fi, HNB_SHUTDOWN_EV_START, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+                     hnb_shutdown(hnb, "Iuh HNBGW conn notification (SCTP_SHUTDOWN_EVENT)", false);</span><br><span style="color: hsl(120, 100%, 40%);">+                      break;</span><br><span style="color: hsl(120, 100%, 40%);">+                default:</span><br><span style="color: hsl(120, 100%, 40%);">+                      break;</span><br><span style="color: hsl(120, 100%, 40%);">+                }</span><br><span>            rc = 0;</span><br><span>              goto free_ret;</span><br><span>       }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-hnodeb/+/26348">change 26348</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-hnodeb/+/26348"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-hnodeb </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Id35d692218af366843186b0966b62f65bb9eb620 </div>
<div style="display:none"> Gerrit-Change-Number: 26348 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: daniel <dwillmann@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: osmith <osmith@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>