Review at  https://gerrit.osmocom.org/8056

let osmo-bts log a special notice if OML connection is closed early

A frequent configuration file error is that the unit_id settings of
osmo-bts and osmo-bsc don't match. The BSC already prints an error
in this case. Let the BTS print an error as well.

We use a heuristic for this purpose: If the OML link is dropped within
10 seconds after being established, log a special warning which alerts
the user and recommend a manual configuration file check.

Change-Id: I476ac797458b5a46edea3ae9cfbd491fd7f77f47
Related: OS#3143
---
M include/osmo-bts/gsm_data_shared.h
M src/common/abis.c
2 files changed, 23 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/56/8056/1

diff --git a/include/osmo-bts/gsm_data_shared.h 
b/include/osmo-bts/gsm_data_shared.h
index 812d086..6a1613b 100644
--- a/include/osmo-bts/gsm_data_shared.h
+++ b/include/osmo-bts/gsm_data_shared.h
@@ -514,6 +514,10 @@
        uint8_t initial_mcs;
 };
 
+/* The amount of time within which a sudden disconnect of a newly established
+ * OML connection will cause a special warning to be logged. */
+#define OSMO_BTS_OML_CONN_EARLY_DISCONNECT 10   /* in seconds */
+
 /* One BTS */
 struct gsm_bts {
        /* list header in net->bts_list */
@@ -552,6 +556,7 @@
        /* how do we talk OML with this TRX? */
        uint8_t oml_tei;
        struct e1inp_sign_link *oml_link;
+       struct timeval oml_conn_established_timestamp;
 
        /* Abis network management O&M handle */
        struct abis_nm_h *nmh;
diff --git a/src/common/abis.c b/src/common/abis.c
index 6aa2f1d..6c303b9 100644
--- a/src/common/abis.c
+++ b/src/common/abis.c
@@ -31,6 +31,7 @@
 #include <errno.h>
 #include <string.h>
 #include <stdlib.h>
+#include <inttypes.h>
 
 #include <osmocom/core/select.h>
 #include <osmocom/core/timer.h>
@@ -108,6 +109,9 @@
                sign_link = g_bts->oml_link =
                        e1inp_sign_link_create(&line->ts[E1INP_SIGN_OML-1],
                                                E1INP_SIGN_OML, NULL, 255, 0);
+               if (osmo_gettimeofday(&g_bts->oml_conn_established_timestamp, 
NULL) != 0)
+                       memset(&g_bts->oml_conn_established_timestamp, 0,
+                              sizeof(g_bts->oml_conn_established_timestamp));
                drain_oml_queue(g_bts);
                sign_link->trx = g_bts->c0;
                bts_link_estab(g_bts);
@@ -140,9 +144,22 @@
        LOGP(DABIS, LOGL_ERROR, "Signalling link down\n");
 
        /* First remove the OML signalling link */
-       if (g_bts->oml_link)
+       if (g_bts->oml_link) {
+               struct timeval now;
+
                e1inp_sign_link_destroy(g_bts->oml_link);
+
+               /* Log a special notice if the OML connection was dropped 
relatively quickly. */
+               if (g_bts->oml_conn_established_timestamp.tv_sec != 0 && 
osmo_gettimeofday(&now, NULL) == 0 &&
+                   g_bts->oml_conn_established_timestamp.tv_sec + 
OSMO_BTS_OML_CONN_EARLY_DISCONNECT >= now.tv_sec) {
+                       LOGP(DABIS, LOGL_NOTICE, "OML link was closed early 
within %" PRIu64 " seconds. "
+                       "If this situation persists, please check your BTS and 
BSC configuration files for errors. "
+                       "A common error is a mismatch between unit_id 
configuration parameters of BTS and BSC.\n",
+                       (uint64_t)(now.tv_sec - 
g_bts->oml_conn_established_timestamp.tv_sec));
+               }
+       }
        g_bts->oml_link = NULL;
+       memset(&g_bts->oml_conn_established_timestamp, 0, 
sizeof(g_bts->oml_conn_established_timestamp));
 
        /* Then iterate over the RSL signalling links */
        llist_for_each_entry(trx, &g_bts->trx_list, list) {

-- 
To view, visit https://gerrit.osmocom.org/8056
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I476ac797458b5a46edea3ae9cfbd491fd7f77f47
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling <ssperl...@sysmocom.de>

Reply via email to