Change in osmo-bts[master]: abis: Fix line leaked & recreated upon every reconnect

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

pespin gerrit-no-reply at lists.osmocom.org
Wed Sep 22 17:43:10 UTC 2021


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/25547 )


Change subject: abis: Fix line leaked & recreated upon every reconnect
......................................................................

abis: Fix line leaked & recreated upon every reconnect

Previous code creating a new line was really a workaroudn to have it
working while previous lines were being stacked internally inside
libosmo-abis.
Let's handle reference counts for the line properly and erase +
re-create it every time.
Recent patches to libosmo-abis fixed a crash happening when refcount
being 0 and destroying the object (object was not removed from a global
llist).

Depends: libosmo-abis Change-Id I1314d6b917ecb622994507475eb894e649a1a2ad
Change-Id: Ic37ae5bf657247e8cce99182c40d9adf890a5e41
---
M include/osmo-bts/abis.h
M src/common/abis.c
2 files changed, 12 insertions(+), 12 deletions(-)



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

diff --git a/include/osmo-bts/abis.h b/include/osmo-bts/abis.h
index 40707cd..d5cf634 100644
--- a/include/osmo-bts/abis.h
+++ b/include/osmo-bts/abis.h
@@ -8,7 +8,7 @@
 
 enum abis_link_fsm_event {
 	ABIS_LINK_EV_SIGN_LINK_OML_UP,
-	ABIS_LINK_EV_SIGN_LINK_DOWN,
+	ABIS_LINK_EV_SIGN_LINK_DOWN, /* data: struct e1inp_line* of link going down */
 	ABIS_LINK_EV_VTY_RM_ADDR, /* data: struct bsc_oml_host* being removed */
 };
 
diff --git a/src/common/abis.c b/src/common/abis.c
index 93635c2..b734576 100644
--- a/src/common/abis.c
+++ b/src/common/abis.c
@@ -81,7 +81,6 @@
 	struct bsc_oml_host *current_bsc;
 	struct gsm_bts *bts;
 	char *model_name;
-	int line_ctr;
 };
 
 static void reset_oml_link(struct gsm_bts *bts)
@@ -156,15 +155,7 @@
 		bts_dev_info.unit_name = bts->description;
 	bts_dev_info.location2 = priv->model_name;
 
-	line = e1inp_line_find(priv->line_ctr);
-	if (line) {
-		e1inp_line_get2(line, __FILE__);	/* We want a new reference for returned line */
-	} else
-		line = e1inp_line_create(priv->line_ctr, "ipa");	/* already comes with a reference */
-
-	/* The abis connection may fail and we may have to try again with a different BSC (if configured). The next
-	 * attempt must happen on a different line. */
-	priv->line_ctr++;
+	line = e1inp_line_create(0, "ipa");	/* already comes with a reference "ctor" */
 
 	if (!line) {
 		osmo_fsm_inst_state_chg(fi, ABIS_LINK_ST_FAILED, 0, 0);
@@ -186,13 +177,17 @@
 {
 	struct abis_link_fsm_priv *priv = fi->priv;
 	struct gsm_bts *bts = priv->bts;
+	struct e1inp_line *line;
 
 	switch (event) {
 	case ABIS_LINK_EV_SIGN_LINK_OML_UP:
 		osmo_fsm_inst_state_chg(fi, ABIS_LINK_ST_CONNECTED, 0, 0);
 		break;
 	case ABIS_LINK_EV_SIGN_LINK_DOWN:
+		line = (struct e1inp_line *)data;
 		reset_oml_link(bts);
+		/* Drop reference obtained through e1inp_line_create() to get rid of the line object: */
+		e1inp_line_put2(line, "ctor");
 		osmo_fsm_inst_state_chg(fi, ABIS_LINK_ST_WAIT_RECONNECT, OML_RETRY_TIMER, 0);
 		break;
 	default:
@@ -210,6 +205,7 @@
 	struct abis_link_fsm_priv *priv = fi->priv;
 	struct gsm_bts *bts = priv->bts;
 	struct gsm_bts_trx *trx;
+	struct e1inp_line *line = (struct e1inp_line *)data;
 	OSMO_ASSERT(event == ABIS_LINK_EV_SIGN_LINK_DOWN);
 
 	/* First remove the OML signalling link */
@@ -232,6 +228,10 @@
 		 * that TRX only. But libosmo-abis expects us to drop the entire
 		 * line when something goes wrong... */
 	}
+
+	/* Drop reference obtained through e1inp_line_create() to get rid of the line object: */
+	e1inp_line_put2(line, "ctor");
+
 	bts_model_abis_close(bts);
 	osmo_fsm_inst_state_chg(fi, ABIS_LINK_ST_WAIT_RECONNECT, OML_RETRY_TIMER, 0);
 }
@@ -395,7 +395,7 @@
 static void sign_link_down(struct e1inp_line *line)
 {
 	LOGPIL(line, DABIS, LOGL_ERROR, "Signalling link down\n");
-	osmo_fsm_inst_dispatch(g_bts->abis_link_fi, ABIS_LINK_EV_SIGN_LINK_DOWN, NULL);
+	osmo_fsm_inst_dispatch(g_bts->abis_link_fi, ABIS_LINK_EV_SIGN_LINK_DOWN, line);
 }
 
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/25547
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: Ic37ae5bf657247e8cce99182c40d9adf890a5e41
Gerrit-Change-Number: 25547
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210922/63f486ba/attachment.htm>


More information about the gerrit-log mailing list