Change in osmo-e1d[master]: make sure a given timeslot can only be opened once (by default)

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

laforge gerrit-no-reply at lists.osmocom.org
Tue Sep 22 19:31:35 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-e1d/+/20081 )

Change subject: make sure a given timeslot can only be opened once (by default)
......................................................................

make sure a given timeslot can only be opened once (by default)

Align the behavior of osmo-e1d with that of DAHDI:  If a timeslot is
opened once, it cannot be opened again by anyone until it is closed
by the current owner.  This way we'd have the same failure semantics
in DAHDI vs. osmo-e1d, which is very useful in case of misconfiguration
when osmo-bsc + osmo-mgw would "fight" over a timeslot.

Add a osmo_e1dp_client_ts_open_force() function that allows to override
and get back the original behavior.

Closes: OS#4654
Change-Id: Ib25adf827ec41e74de15e0e4fdcfc9bcc9a32e58
---
A TODO-RELEASE
M include/osmocom/e1d/proto.h
M include/osmocom/e1d/proto_clnt.h
M src/ctl.c
M src/proto_clnt.c
5 files changed, 37 insertions(+), 5 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/TODO-RELEASE b/TODO-RELEASE
new file mode 100644
index 0000000..27e2d93
--- /dev/null
+++ b/TODO-RELEASE
@@ -0,0 +1 @@
+* bump protocol version as 'flags' member was added to osmo_d1dp_ts_config
diff --git a/include/osmocom/e1d/proto.h b/include/osmocom/e1d/proto.h
index 5628e31..6457f14 100644
--- a/include/osmocom/e1d/proto.h
+++ b/include/osmocom/e1d/proto.h
@@ -81,6 +81,8 @@
 	E1DP_TSMODE_HDLCFCS	= 0x11,
 };
 
+/* osmo_e1dp_ts_config.flags */
+#define E1DP_TS_OPEN_F_FORCE	0x80
 
 /* the idea here is to use the first byte as a version number, to prevent incompatible
  * clients from connecting to e1d */
@@ -118,6 +120,7 @@
 
 struct osmo_e1dp_ts_config {
 	uint8_t mode;
+	uint8_t flags;
 	uint16_t read_bufsize;
 } __attribute__((packed));
 
diff --git a/include/osmocom/e1d/proto_clnt.h b/include/osmocom/e1d/proto_clnt.h
index 5a4f965..1473716 100644
--- a/include/osmocom/e1d/proto_clnt.h
+++ b/include/osmocom/e1d/proto_clnt.h
@@ -46,3 +46,6 @@
 int osmo_e1dp_client_ts_open(struct osmo_e1dp_client *clnt,
 	uint8_t intf, uint8_t line, uint8_t ts,
 	enum osmo_e1dp_ts_mode mode, uint16_t read_bufsize);
+int osmo_e1dp_client_ts_open_force(struct osmo_e1dp_client *clnt,
+	uint8_t intf, uint8_t line, uint8_t ts,
+	enum osmo_e1dp_ts_mode mode, uint16_t read_bufsize);
diff --git a/src/ctl.c b/src/ctl.c
index 8da21fd..8a0e339 100644
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -395,8 +395,16 @@
 		return 0;
 	}
 
-	/* If already open, close previous */
-	e1_ts_stop(ts);
+	if (ts->fd >= 0) {
+		/* we only force-reopen a busy timeslot if the flag is set */
+		if (cfg->flags & E1DP_TS_OPEN_F_FORCE) {
+			e1_ts_stop(ts);
+		} else {
+			LOGPTS(ts, DE1D, LOGL_ERROR,
+				"Timeslot already open, rejecting re-open without F_FORCE\n");
+			return 0;
+		}
+	}
 
 	/* Init */
 	ret = _e1d_ts_start(ts, mode, cfg->read_bufsize);
diff --git a/src/proto_clnt.c b/src/proto_clnt.c
index 69c7234..0f6e367 100644
--- a/src/proto_clnt.c
+++ b/src/proto_clnt.c
@@ -315,10 +315,10 @@
 	return 0;
 }
 
-int
-osmo_e1dp_client_ts_open(struct osmo_e1dp_client *clnt,
+static int
+_client_ts_open(struct osmo_e1dp_client *clnt,
 	uint8_t intf, uint8_t line, uint8_t ts,
-	enum osmo_e1dp_ts_mode mode, uint16_t read_bufsize)
+	enum osmo_e1dp_ts_mode mode, uint16_t read_bufsize, uint8_t flags)
 {
 	struct msgb *msgb;
 	struct osmo_e1dp_msg_hdr hdr;
@@ -333,6 +333,7 @@
 
 	memset(&cfg, 0x00, sizeof(struct osmo_e1dp_ts_config));
 	cfg.mode = mode;
+	cfg.flags = flags;
 	cfg.read_bufsize = read_bufsize;
 
 	tsfd = -1;
@@ -348,3 +349,19 @@
 
 	return tsfd;
 }
+
+int
+osmo_e1dp_client_ts_open(struct osmo_e1dp_client *clnt,
+	uint8_t intf, uint8_t line, uint8_t ts,
+	enum osmo_e1dp_ts_mode mode, uint16_t read_bufsize)
+{
+	return _client_ts_open(clnt, intf, line, ts, mode, read_bufsize, 0);
+}
+
+int
+osmo_e1dp_client_ts_open_force(struct osmo_e1dp_client *clnt,
+	uint8_t intf, uint8_t line, uint8_t ts,
+	enum osmo_e1dp_ts_mode mode, uint16_t read_bufsize)
+{
+	return _client_ts_open(clnt, intf, line, ts, mode, read_bufsize, E1DP_TS_OPEN_F_FORCE);
+}

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

Gerrit-Project: osmo-e1d
Gerrit-Branch: master
Gerrit-Change-Id: Ib25adf827ec41e74de15e0e4fdcfc9bcc9a32e58
Gerrit-Change-Number: 20081
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Assignee: tnt <tnt at 246tNt.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: tnt <tnt at 246tNt.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200922/ae41cbd9/attachment.htm>


More information about the gerrit-log mailing list