dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bsc/+/38957?usp=email )
Change subject: pcu_sock: do not receive a TXT ind. with PCU_VERSION for a specific BTS
......................................................................
pcu_sock: do not receive a TXT ind. with PCU_VERSION for a specific BTS
We receive a TXT indication that contains the PCU_VERSION from the PCU when the
connection to the PCU is established. This message contains a BTS number, which
is always 0. This is a hard coded value that does not refer to a specific BTS
object. Also it is not logical to inform a specific BTS object about the PCU
version. This information should be directed to the connecting process as a
whole. However, we use this TXT indication to trigger certain initialization
processes on the BTS object we manage inside the BSC process. Unfortunately the
BSC is currently using the BTS Number in the TXT indication to resolve the BTS
object. This is not correct, instead the BSC should iterate of over all BTS
objects and trigger the initializations for each BTS object that has a BSC
co-located PCU.
This change does not have any dependencies, it just corrects the behavior of
the BSC on initialization.
Related: OS#6507
Change-Id: I3fbf5430db8b8ea29efb147bd162706990453fc5
---
M src/osmo-bsc/pcu_sock.c
1 file changed, 31 insertions(+), 10 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/57/38957/1
diff --git a/src/osmo-bsc/pcu_sock.c b/src/osmo-bsc/pcu_sock.c
index 02a3d84..23e4479 100644
--- a/src/osmo-bsc/pcu_sock.c
+++ b/src/osmo-bsc/pcu_sock.c
@@ -665,24 +665,33 @@
return 0;
}
-static int pcu_rx_txt_ind(struct gsm_bts *bts,
+static int pcu_rx_txt_ind(struct gsm_network *net, struct gsm_bts *bts,
const struct gsm_pcu_if_txt_ind *txt)
{
- int rc;
+ int rc = 0;
switch (txt->type) {
case PCU_VERSION:
- LOG_BTS(bts, DPCU, LOGL_INFO, "OsmoPCU version %s connected\n",
+ LOGP(DPCU, LOGL_INFO, "OsmoPCU version %s connected\n",
txt->text);
- rc = pcu_tx_si_all(bts);
+
+ /* we use the reception of the PCU_VERSION as a trigger to make the PCU available for
+ * all BTSs handled by this process (currently this is exactly one BTS, see FIXME notes) */
+ llist_for_each_entry(bts, &net->bts_list, list) {
+ if (bsc_co_located_pcu(bts)) {
+ if (pcu_tx_si_all(bts) < 0)
+ rc = -EINVAL;
+ }
+ }
if (rc < 0)
return -EINVAL;
break;
case PCU_OML_ALERT:
+ OSMO_ASSERT(bts);
LOG_BTS(bts, DPCU, LOGL_ERROR, "PCU external alarm: %s\n", txt->text);
break;
default:
- LOG_BTS(bts, DPCU, LOGL_ERROR, "Unknown TXT_IND type %u received\n",
+ LOGP(DPCU, LOGL_ERROR, "Unknown TXT_IND type %u received\n",
txt->type);
return -EINVAL;
}
@@ -699,25 +708,37 @@
return -EINVAL; \
} \
} while (0)
+
+#define ENSURE_BTS_OBJECT() \
+ if ((bts = gsm_bts_num(net, pcu_prim->bts_nr)) == NULL) { \
+ LOGP(DPCU, LOGL_ERROR, "Received PCU Prim for non-existent BTS %u\n", pcu_prim->bts_nr); \
+ return -EINVAL; \
+ }
+
static int pcu_rx(struct gsm_network *net, uint8_t msg_type,
struct gsm_pcu_if *pcu_prim, size_t prim_len)
{
int rc = 0;
struct gsm_bts *bts;
- bts = gsm_bts_num(net, pcu_prim->bts_nr);
- if (!bts)
- return -EINVAL;
-
switch (msg_type) {
case PCU_IF_MSG_DATA_REQ:
case PCU_IF_MSG_PAG_REQ:
+ ENSURE_BTS_OBJECT();
CHECK_IF_MSG_SIZE(prim_len, pcu_prim->u.data_req);
rc = pcu_rx_data_req(bts, msg_type, &pcu_prim->u.data_req);
break;
case PCU_IF_MSG_TXT_IND:
CHECK_IF_MSG_SIZE(prim_len, pcu_prim->u.txt_ind);
- rc = pcu_rx_txt_ind(bts, &pcu_prim->u.txt_ind);
+ if (pcu_prim->u.txt_ind.type == PCU_VERSION) {
+ /* A TXT indication that carries the PCU_VERSION is always addressed to the
+ * receiving process as a whole, which means we will not resolve a specific
+ * BTS object in this case. */
+ rc = pcu_rx_txt_ind(net, NULL, &pcu_prim->u.txt_ind);
+ } else {
+ ENSURE_BTS_OBJECT();
+ rc = pcu_rx_txt_ind(NULL, bts, &pcu_prim->u.txt_ind);
+ }
break;
default:
LOGP(DPCU, LOGL_ERROR, "Received unknown PCU msg type %d\n",
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/38957?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I3fbf5430db8b8ea29efb147bd162706990453fc5
Gerrit-Change-Number: 38957
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-netif/+/38955?usp=email )
Change subject: stream_cli: Add API osmo_stream_cli_set_tx_queue_max_length()
......................................................................
stream_cli: Add API osmo_stream_cli_set_tx_queue_max_length()
Change-Id: I3935fb933fe6136d68a9403eebbaf2616c2e5578
---
M TODO-RELEASE
M include/osmocom/netif/stream.h
M src/stream_cli.c
3 files changed, 37 insertions(+), 6 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/55/38955/1
diff --git a/TODO-RELEASE b/TODO-RELEASE
index 4f59788..74a0abb 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -8,3 +8,4 @@
# If any interfaces have been removed or changed since the last public release: c:r:0.
#library what description / commit summary line
libosmo-netif add API osmo_stream_cli_set_{ip_dscp,priority}(), osmo_stream_srv_link_set_{ip_dscp,priority}()
+libosmo-netif add API osmo-stream_cli_set_tx_queue_max_length()
diff --git a/include/osmocom/netif/stream.h b/include/osmocom/netif/stream.h
index 6edf915..3b3e04e 100644
--- a/include/osmocom/netif/stream.h
+++ b/include/osmocom/netif/stream.h
@@ -208,6 +208,7 @@
void osmo_stream_cli_set_data(struct osmo_stream_cli *cli, void *data);
void osmo_stream_cli_set_reconnect_timeout(struct osmo_stream_cli *cli, int timeout);
void *osmo_stream_cli_get_data(struct osmo_stream_cli *cli);
+int osmo_stream_cli_set_tx_queue_max_length(struct osmo_stream_cli *cli, unsigned int size);
char *osmo_stream_cli_get_sockname(const struct osmo_stream_cli *cli);
struct osmo_fd *osmo_stream_cli_get_ofd(struct osmo_stream_cli *cli);
int osmo_stream_cli_get_fd(const struct osmo_stream_cli *cli);
diff --git a/src/stream_cli.c b/src/stream_cli.c
index 88d5f9e..a00f32a 100644
--- a/src/stream_cli.c
+++ b/src/stream_cli.c
@@ -96,7 +96,9 @@
struct osmo_fd ofd;
struct osmo_io_fd *iofd;
};
- struct llist_head tx_queue;
+ struct llist_head tx_queue; /* osmo_ofd mode (only): Queue of msgbs */
+ unsigned int tx_queue_count; /* osmo_ofd mode (only): Current amount of msgbs queued */
+ unsigned int tx_queue_max_length; /* Max amount of msgbs which can be enqueued */
struct osmo_timer_list timer;
enum osmo_stream_cli_state state;
char *addr[OSMO_STREAM_MAX_ADDRS];
@@ -321,12 +323,11 @@
struct msgb *msg;
int ret;
- if (llist_empty(&cli->tx_queue)) {
+ msg = msgb_dequeue_count(&cli->tx_queue, &cli->tx_queue_count);
+ if (!msg) { /* done, tx_queue empty */
osmo_fd_write_disable(&cli->ofd);
return 0;
}
- msg = llist_first_entry(&cli->tx_queue, struct msgb, list);
- llist_del(&msg->list);
if (!osmo_stream_cli_is_connected(cli)) {
LOGSCLI(cli, LOGL_ERROR, "send: not connected, dropping data!\n");
@@ -367,6 +368,7 @@
/* Update msgb and re-add it at the start of the queue: */
msgb_pull(msg, ret);
llist_add(&msg->list, &cli->tx_queue);
+ cli->tx_queue_count++;
return 0;
}
@@ -376,6 +378,7 @@
if (err == EAGAIN) {
/* Re-add at the start of the queue to re-attempt: */
llist_add(&msg->list, &cli->tx_queue);
+ cli->tx_queue_count++;
return 0;
}
msgb_free(msg);
@@ -510,6 +513,7 @@
cli->reconnect_timeout = 5; /* default is 5 seconds. */
cli->segmentation_cb = NULL;
INIT_LLIST_HEAD(&cli->tx_queue);
+ cli->tx_queue_max_length = 1024; /* Default tx queue size, msgbs. */
cli->ma_pars.sctp.version = 0;
@@ -863,6 +867,24 @@
return cli->data;
}
+/*! Set the maximum length queue of the stream client.
+ * \param[in] cli Stream Client to modify
+ * \param[in] size maximum amount of msgbs which can be queued in the internal tx queue.
+ * \returns 0 on success, negative on error.
+ *
+ * The maximum length queue default value is 1024 msgbs. */
+int osmo_stream_cli_set_tx_queue_max_length(struct osmo_stream_cli *cli, unsigned int size)
+{
+ cli->tx_queue_max_length = size;
+
+ if (cli->iofd) /* Otherwise, this will be done in osmo_stream_cli_open() */
+ osmo_iofd_set_txqueue_max_length(cli->iofd, cli->tx_queue_max_length);
+
+ /* XXX: Here, in OSMO_STREAM_MODE_OSMO_FD mode we could check current
+ * size of cli->tx_queue and shrink it from the front or back... */
+ return 0;
+}
+
/*! Retrieve the stream client socket description.
* Calling this function will build a string that describes the socket in terms of its local/remote
* address/port. The returned name is stored in a static buffer; it is hence not re-entrant or thread-safe.
@@ -944,6 +966,7 @@
OSMO_ASSERT(!stream_cli_close(cli));
osmo_timer_del(&cli->timer);
msgb_queue_free(&cli->tx_queue);
+ cli->tx_queue_count = 0;
/* if we are in a user callback, delay freeing. */
if (cli->in_cb_mask != 0) {
LOGSCLI(cli, LOGL_DEBUG, "delay free() in_cb_mask=0x%02x\n", cli->in_cb_mask);
@@ -1204,8 +1227,8 @@
if (!cli->iofd)
goto error_close_socket;
+ osmo_iofd_set_txqueue_max_length(cli->iofd, cli->tx_queue_max_length);
osmo_iofd_notify_connected(cli->iofd);
-
configure_cli_segmentation_cb(cli, cli->segmentation_cb);
if (osmo_iofd_register(cli->iofd, fd) < 0)
@@ -1253,7 +1276,12 @@
switch (cli->mode) {
case OSMO_STREAM_MODE_OSMO_FD:
- msgb_enqueue(&cli->tx_queue, msg);
+ if (cli->tx_queue_count >= cli->tx_queue_max_length) {
+ LOGSCLI(cli, LOGL_ERROR, "send: tx queue full, dropping msg!\n");
+ msgb_free(msg);
+ return;
+ }
+ msgb_enqueue_count(&cli->tx_queue, msg, &cli->tx_queue_count);
osmo_fd_write_enable(&cli->ofd);
break;
case OSMO_STREAM_MODE_OSMO_IO:
@@ -1350,6 +1378,7 @@
switch (cli->mode) {
case OSMO_STREAM_MODE_OSMO_FD:
msgb_queue_free(&cli->tx_queue);
+ cli->tx_queue_count = 0;
/* If in state 'connecting', keep WRITE flag up to receive
* socket connection signal and then transition to STATE_CONNECTED: */
if (cli->state == STREAM_CLI_STATE_CONNECTED)
--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/38955?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: I3935fb933fe6136d68a9403eebbaf2616c2e5578
Gerrit-Change-Number: 38955
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcu/+/38954?usp=email )
Change subject: pcuif: add comment on TXT_IND/PCU_VERSION BTS initialization behavior
......................................................................
pcuif: add comment on TXT_IND/PCU_VERSION BTS initialization behavior
The PCU sends a TXT_IND with the PCU_VERSION as the first message
after the socket connection is established. The BTS/BSC uses those
messages to trigger some initialization (allocate BTS object inside
the PCU, send SI to the PCU).
Unfortunately the PCU will send the TXT_IND with the PCU_VERSION
always with to BTS 0. The 0 in this case is a hardcoded fake BTS
number (There is no BTS object allocated under this number in the
PCU at this point). However, the BTS/BSC will then do the
initialization process for BTS 0, which works by chance for the
BTS where the BTS number is always 0, in the case of the BSC there
may be multiple BTS configured, so there may be arbitrary BTS
numbers.
Let's fix this design error by agreeing that a TXT_IND that has the
type PCU_VERSION is always addressing the receiving process as a whole
and therefore the BTS number in the indication must be ignored.
Related: OS#6507
Change-Id: Ib3f340ae9450151549ce61d34b28253d499ae04a
---
M src/pcu_l1_if.cpp
1 file changed, 7 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/54/38954/1
diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index fb44bd8..630c244 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -124,6 +124,13 @@
struct gsm_pcu_if_txt_ind *txt;
va_list ap;
char *rep;
+
+ /* In case the caller sends a TXT indication of type PCU_VERSION, the bts_nr will always be 0. Also the receiver
+ * is expected to ignore the bts_nr when receiving a TXT indication of type PCU_VERSION. The rationale is that
+ * the information about the PCU version number is only useful to the receiving process as a whole (be it osmo-bsc
+ * or osmo-bts). */
+ /* TODO: add support for sending other TXT indication types than PCU_VERSION */
+ OSMO_ASSERT(t == PCU_VERSION);
struct msgb *msg = pcu_msgb_alloc(PCU_IF_MSG_TXT_IND, 0);
if (!msg)
return -ENOMEM;
--
To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/38954?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: Ib3f340ae9450151549ce61d34b28253d499ae04a
Gerrit-Change-Number: 38954
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Attention is currently required from: pespin.
fixeria has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/38953?usp=email )
Change subject: hnbgw: TC_rab_release: Fix race condition stats checked too early
......................................................................
Patch Set 1: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/38953?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Ica53d956ee8aed760854d3148af170144234e6b2
Gerrit-Change-Number: 38953
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Tue, 26 Nov 2024 15:45:12 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes