pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-netif/+/39369?usp=email )
Change subject: stream: Add osmo_stream_srv_link_set_msgb_alloc_info()
......................................................................
stream: Add osmo_stream_srv_link_set_msgb_alloc_info()
This is needed so that user can set desired headroom+size info on
rx-allocated msgbs, so that osmo_stream_srv can inherit them upon
osmo_stream_srv_create2().
Manually obtaining the iofd through osmo_stream_srv_get_iofd() and
changing the params directly in the iofd produces undesired effects,
since the first msgbs are alredy allocated during
osmo_stream_srv_create2 (which calls osmo_iofd_register()) before the
object is available to the user.
As a result, first rx messages may come with unexpected size/headroom.
Ideally we'd had written the osmo_stream_srv APIs to have a 2 step
setup, eg _alloc() + _run()/_start(), but too late to do so now.
This approach is already follwed by existing
osmo_stream_srv_link_set_tx_queue_max_length() API.
Change-Id: I80a1c4b227629e3ca0c8c587a103db6057322cb4
---
M TODO-RELEASE
M include/osmocom/netif/stream.h
M src/stream_srv.c
3 files changed, 34 insertions(+), 0 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
pespin: Looks good to me, approved
osmith: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/TODO-RELEASE b/TODO-RELEASE
index e66b421..dfdbd89 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -11,3 +11,4 @@
libosmo-netif add API osmo-stream_cli_set_tx_queue_max_length(), osmo_stream_srv_link_set_tx_queue_max_length()
libosmo-netif add API struct osmo_ipa_ka_fsm_inst
libosmo-netif add API osmo_stream_{cli,srv}_set_segmentation_cb2()
+libosmo-netif add API osmo_stream_srv_link_set_msgb_alloc_info()
diff --git a/include/osmocom/netif/stream.h b/include/osmocom/netif/stream.h
index e793a26..83f17d7 100644
--- a/include/osmocom/netif/stream.h
+++ b/include/osmocom/netif/stream.h
@@ -88,6 +88,7 @@
char *osmo_stream_srv_link_get_sockname(const struct osmo_stream_srv_link *link);
struct osmo_fd *osmo_stream_srv_link_get_ofd(struct osmo_stream_srv_link *link);
int osmo_stream_srv_link_get_fd(const struct osmo_stream_srv_link *link);
+int osmo_stream_srv_link_set_msgb_alloc_info(struct osmo_stream_srv_link *link, unsigned int size, unsigned int headroom);
bool osmo_stream_srv_link_is_opened(const struct osmo_stream_srv_link *link);
int osmo_stream_srv_link_open(struct osmo_stream_srv_link *link);
void osmo_stream_srv_link_close(struct osmo_stream_srv_link *link);
diff --git a/src/stream_srv.c b/src/stream_srv.c
index c2b187a..261539b 100644
--- a/src/stream_srv.c
+++ b/src/stream_srv.c
@@ -69,6 +69,15 @@
* Server side.
*/
+struct msgb_alloc_info {
+ /*! Whether it was set by user or we use iofd defaults */
+ bool set_by_user;
+ /*! size of msgb to allocate (excluding headroom) */
+ unsigned int size;
+ /*! headroom to allocate when allocating msgb's */
+ unsigned int headroom;
+};
+
#define OSMO_STREAM_SRV_F_RECONF (1 << 0)
#define OSMO_STREAM_SRV_F_NODELAY (1 << 1)
@@ -88,6 +97,7 @@
void *data;
int flags;
unsigned int tx_queue_max_length; /* Max amount of msgbs which can be enqueued */
+ struct msgb_alloc_info msgb_alloc;
struct osmo_sock_init2_multiaddr_pars ma_pars;
};
@@ -506,6 +516,26 @@
link->accept_cb = accept_cb;
}
+/*! Set the msgb allocation parameters on child osmo_stream_srv objects
+ * \param[in] link Stream Server Link
+ * \param[in] size Size of msgb to allocate (excluding headroom)
+ * \param[in] headroom Headroom to allocate when allocating msgb's
+ *
+ * The parameters are applied to osmo_stream_srv objects upon creation.
+ * Setting both to 0 leaves it as implementation default.
+ **/
+int osmo_stream_srv_link_set_msgb_alloc_info(struct osmo_stream_srv_link *link, unsigned int size, unsigned int headroom)
+{
+ if (size == 0 && headroom == 0) {
+ link->msgb_alloc.set_by_user = false;
+ } else {
+ link->msgb_alloc.set_by_user = true;
+ link->msgb_alloc.headroom = headroom;
+ link->msgb_alloc.size = size;
+ }
+ return 0;
+}
+
/*! Destroy the stream server link. Closes + Releases Memory.
* \param[in] link Stream Server Link */
void osmo_stream_srv_link_destroy(struct osmo_stream_srv_link *link)
@@ -962,6 +992,8 @@
}
osmo_iofd_set_txqueue_max_length(conn->iofd, conn->srv->tx_queue_max_length);
+ if (conn->srv->msgb_alloc.set_by_user)
+ osmo_iofd_set_alloc_info(conn->iofd, conn->srv->msgb_alloc.size, conn->srv->msgb_alloc.headroom);
if (osmo_iofd_register(conn->iofd, fd) < 0) {
LOGSSRV(conn, LOGL_ERROR, "could not register FD %d\n", fd);
--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/39369?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: I80a1c4b227629e3ca0c8c587a103db6057322cb4
Gerrit-Change-Number: 39369
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Attention is currently required from: dexter.
fixeria has posted comments on this change by dexter. ( https://gerrit.osmocom.org/c/pysim/+/39225?usp=email )
Change subject: global_platform: fix usage of the Key Version Number (kvn)
......................................................................
Patch Set 5: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/39225?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I42be2438c7f199b238f2ec7a9434cec5393210a7
Gerrit-Change-Number: 39225
Gerrit-PatchSet: 5
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Mon, 20 Jan 2025 11:35:13 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Attention is currently required from: osmith, pespin.
Hello osmith,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/osmo-pcap/+/39367?usp=email
to look at the new patch set (#3).
The following approvals got outdated and were removed:
Code-Review+1 by osmith
Change subject: server: Implement non-blocking write to pcap file with osmo_io
......................................................................
server: Implement non-blocking write to pcap file with osmo_io
Actual zero-copy msgb passing from read tcp socket will be implemented
in follow-up patches.
Change-Id: I098a9455a2a4cc626444e6fc13aa88c4cc9694f0
Related: SYS#7080
---
M include/osmo-pcap/osmo_pcap_server.h
M src/osmo_pcap_wr_file.c
M src/osmo_server_core.c
3 files changed, 173 insertions(+), 39 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-pcap refs/changes/67/39367/3
--
To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39367?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: osmo-pcap
Gerrit-Branch: master
Gerrit-Change-Id: I098a9455a2a4cc626444e6fc13aa88c4cc9694f0
Gerrit-Change-Number: 39367
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Attention: osmith <osmith(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Attention is currently required from: daniel, laforge.
pespin has posted comments on this change by daniel. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/39372?usp=email )
Change subject: gbproxy: Don't log the payload size for every DL/UL-UNITDATA
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/39372?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: I862d67a48f1d694262cf39a1e939033bde0c6eab
Gerrit-Change-Number: 39372
Gerrit-PatchSet: 1
Gerrit-Owner: daniel <dwillmann(a)sysmocom.de>
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-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: daniel <dwillmann(a)sysmocom.de>
Gerrit-Comment-Date: Mon, 20 Jan 2025 10:52:58 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/39368?usp=email )
Change subject: msgb: msgb_copy_resize_c: Fix validation check to avoid memcpy buffer overflow
......................................................................
msgb: msgb_copy_resize_c: Fix validation check to avoid memcpy buffer overflow
If msg->data pointer is not allocated at the start of the msgb, (eg.
because it was pull()ed or had some headroom), the existing check
wouldn't catch it and memcpy() would write passed the allocated chunk
(msg->data - msg->_data) bytes.
Change-Id: If4c84162a4e5b44b82813fb58029fae04bd38230
---
M src/core/msgb.c
1 file changed, 3 insertions(+), 3 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
Jenkins Builder: Verified
pespin: Looks good to me, approved
osmith: Looks good to me, but someone else must approve
diff --git a/src/core/msgb.c b/src/core/msgb.c
index 713510c..6f081bb 100644
--- a/src/core/msgb.c
+++ b/src/core/msgb.c
@@ -327,10 +327,10 @@
{
struct msgb *new_msg;
- if (new_len < msgb_length(msg)) {
+ if (new_len < (msg->data - msg->_data) + msgb_length(msg)) {
LOGP(DLGLOBAL, LOGL_ERROR,
- "Data from old msgb (%u bytes) won't fit into new msgb (%u bytes) after reallocation\n",
- msgb_length(msg), new_len);
+ "Data from old msgb (%u bytes at offset %u) won't fit into new msgb (%u total bytes) after reallocation\n",
+ msgb_length(msg), (uint16_t)(msg->data - msg->_data), new_len);
return NULL;
}
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/39368?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: If4c84162a4e5b44b82813fb58029fae04bd38230
Gerrit-Change-Number: 39368
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>