laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-netif/+/36244?usp=email )
Change subject: osmo_stream_cli_send(): Drop data if client is not connected [yet]
......................................................................
osmo_stream_cli_send(): Drop data if client is not connected [yet]
The behaviour is undefined on what should happen if a stream client user
is trying to write data before the client socket is connected. In
osmo_io mode we would actually crash due to a NULL-pointer dereference.
Let's discard any sent data in this situation and print a related error log message.
This problem actually shows up with osmo-bsc Change-Id
Icce412e6ee69366c7b131c9bc1d51e8d44204917 where we convert CBSP over to
osmo_io - here in situations where a CBSP client (using stream_cli) was
previously connected but has lost its connection.
Change-Id: I18d2e8e850c23a32f5983a715fa8a18747b296cd
---
M src/stream_cli.c
1 file changed, 28 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/44/36244/1
diff --git a/src/stream_cli.c b/src/stream_cli.c
index 8312faf..1a100ca 100644
--- a/src/stream_cli.c
+++ b/src/stream_cli.c
@@ -1003,12 +1003,20 @@
OSMO_ASSERT(cli);
OSMO_ASSERT(msg);
+ if (!osmo_stream_cli_is_connected(cli)) {
+ LOGSCLI(cli, LOGL_ERROR, "send: not connected, dropping data!\n");
+ msgb_free(msg);
+ return;
+ }
+
switch (cli->mode) {
case OSMO_STREAM_MODE_OSMO_FD:
msgb_enqueue(&cli->tx_queue, msg);
osmo_fd_write_enable(&cli->ofd);
break;
case OSMO_STREAM_MODE_OSMO_IO:
+ /* whenever osmo_stream_cli_is_connected() [see above check], we should have an iofd /*
+ OSMO_ASSERT(cli->iofd);
if (cli->proto == IPPROTO_SCTP)
rc = stream_iofd_sctp_send_msgb(cli->iofd, msg, MSG_NOSIGNAL);
else
--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/36244?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: I18d2e8e850c23a32f5983a715fa8a18747b296cd
Gerrit-Change-Number: 36244
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/36082?usp=email )
Change subject: New per-hnb rate_ctr and stat_item groups; track uptime
......................................................................
Patch Set 4:
(1 comment)
Patchset:
PS4:
> reported not working by user
specifically, _uptime_ not working.
--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/36082?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: I26d7c3657cdaf7c6ba5aa10a0677381ab099f8dd
Gerrit-Change-Number: 36082
Gerrit-PatchSet: 4
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Tue, 12 Mar 2024 08:19:20 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: comment
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/36204?usp=email )
Change subject: Introduce umts_cell_id_from_str() as inverse of umts_cell_id_name()
......................................................................
Introduce umts_cell_id_from_str() as inverse of umts_cell_id_name()
We are about to introduce the stringified UMTS cell identifier to the
VTY, and for that we need to not only print but also parse the related
string.
Related: SYS#6773
Change-Id: I6da947d1f2316241e44e53bb6aaec4221cfaa2c0
---
M include/osmocom/hnbgw/hnbgw.h
M src/osmo-hnbgw/hnbgw.c
2 files changed, 41 insertions(+), 0 deletions(-)
Approvals:
osmith: Looks good to me, but someone else must approve
pespin: Looks good to me, but someone else must approve
Jenkins Builder: Verified
laforge: Looks good to me, approved
diff --git a/include/osmocom/hnbgw/hnbgw.h b/include/osmocom/hnbgw/hnbgw.h
index f4f7dc1..62b548c 100644
--- a/include/osmocom/hnbgw/hnbgw.h
+++ b/include/osmocom/hnbgw/hnbgw.h
@@ -79,6 +79,7 @@
uint32_t cid; /*!< Cell ID */
};
const char *umts_cell_id_name(const struct umts_cell_id *ucid);
+int umts_cell_id_from_str(struct umts_cell_id *ucid, const char *instr);
struct hnbgw_context_map;
diff --git a/src/osmo-hnbgw/hnbgw.c b/src/osmo-hnbgw/hnbgw.c
index 82ae279..366568d 100644
--- a/src/osmo-hnbgw/hnbgw.c
+++ b/src/osmo-hnbgw/hnbgw.c
@@ -202,6 +202,32 @@
ucid->sac, ucid->cid);
}
+/* parse a string representation of an umts_cell_id into its decoded representation */
+int umts_cell_id_from_str(struct umts_cell_id *ucid, const char *instr)
+{
+ int rc = sscanf(instr, "%hu-%hu-L%hu-R%hu-S%hu-C%u", &ucid->mcc, &ucid->mnc, &ucid->lac, &ucid->rac, &ucid->sac, &ucid->cid);
+ if (rc < 0)
+ return -errno;
+
+ if (rc != 6)
+ return -EINVAL;
+
+ if (ucid->mcc > 999)
+ return -EINVAL;
+
+ if (ucid->mnc > 999)
+ return -EINVAL;
+
+ if (ucid->lac == 0 || ucid->lac == 0xffff)
+ return -EINVAL;
+
+ /* CellIdentity in the ASN.1 syntax is a bit-string of 28 bits length */
+ if (ucid->cid >= (1 << 28))
+ return -EINVAL;
+
+ return 0;
+}
+
const char *hnb_context_name(struct hnb_context *ctx)
{
char *result;
--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/36204?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: I6da947d1f2316241e44e53bb6aaec4221cfaa2c0
Gerrit-Change-Number: 36204
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged