Change in libosmocore[master]: gsm0808: make msgb size and headroom configurable

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

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Fri Feb 22 04:00:44 UTC 2019


Neels Hofmeyr has uploaded this change for review. ( https://gerrit.osmocom.org/13004


Change subject: gsm0808: make msgb size and headroom configurable
......................................................................

gsm0808: make msgb size and headroom configurable

Allow for manual configuration of buffer size and headroom by exposing
osmo_gsm0808_msg_size and osmo_gsm0808_msg_headroom; if unset (remaining 0),
the current defaults remain in effect.

In osmo-msc, I would like to prepend an osmo_prim to the msgb created by
gsm0808 API, but turns out the headroom is too small:

    msgb(0x61700001b660): Not enough headroom msgb_push (126 < 264)

Instead of always copying a msgb that has just that instant been created, it
makes more sense to allocate sufficient headroom in the first place. The
gsm0808 API allocates msgb implicitly, this is the least impact fix.

Compat: the BSSMAP_MSG_SIZE and BSSMAP_HEADROOM_SIZE can no longer be used as
constants, e.g. to initialize the size of static things. They should only ever
be used with msgb_alloc_headroom(), so I assert that this is fine.
I am not sure why these #defines are in the public header in the first place,
but since they are, keep them there and make them reflect the actually used
sizes.

Change-Id: I95729991eb49555f8bba60c5dc916131b03b6cf2
---
M TODO-RELEASE
M include/osmocom/gsm/gsm0808.h
M src/gsm/gsm0808.c
M src/gsm/libosmogsm.map
4 files changed, 12 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/04/13004/1

diff --git a/TODO-RELEASE b/TODO-RELEASE
index 8ccfa49..9bf5b03 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -7,3 +7,4 @@
 # If any interfaces have been added since the last public release: c:r:a + 1.
 # If any interfaces have been removed or changed since the last public release: c:r:0.
 #library	what			description / commit summary line
+gsm		gsm0808.h		GSM0808_MSG_SIZE and GSM0808_MSG_HEADROOM are no longer compile-time constant numbers
diff --git a/include/osmocom/gsm/gsm0808.h b/include/osmocom/gsm/gsm0808.h
index 35e7a8e..dfab29a 100644
--- a/include/osmocom/gsm/gsm0808.h
+++ b/include/osmocom/gsm/gsm0808.h
@@ -29,8 +29,12 @@
 #include <osmocom/gsm/gsm23003.h>
 #include <osmocom/core/utils.h>
 
-#define BSSMAP_MSG_SIZE 512
-#define BSSMAP_MSG_HEADROOM 128
+#define BSSMAP_MSG_DEFAULT_SIZE 512
+#define BSSMAP_MSG_DEFAULT_HEADROOM 128
+extern size_t osmo_gsm0808_msg_size;
+extern size_t osmo_gsm0808_msg_headroom;
+#define BSSMAP_MSG_HEADROOM (osmo_gsm0808_msg_headroom ? : BSSMAP_MSG_DEFAULT_HEADROOM)
+#define BSSMAP_MSG_SIZE (osmo_gsm0808_msg_size ? : BSSMAP_MSG_DEFAULT_SIZE - BSSMAP_MSG_DEFAULT_HEADROOM + BSSMAP_MSG_HEADROOM)
 
 struct sockaddr_storage;
 
diff --git a/src/gsm/gsm0808.c b/src/gsm/gsm0808.c
index 4873076..ff17bd2 100644
--- a/src/gsm/gsm0808.c
+++ b/src/gsm/gsm0808.c
@@ -27,6 +27,9 @@
 #include <osmocom/gsm/protocol/gsm_08_08.h>
 #include <osmocom/gsm/gsm48.h>
 
+size_t osmo_gsm0808_msg_size = 0;
+size_t osmo_gsm0808_msg_headroom = 0;
+
 /*! \addtogroup gsm0808
  *  @{
  *  \file gsm0808.c
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index 48757a7..525fa0d 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -228,6 +228,8 @@
 gsm0808_lcls_status_names;
 gsm0808_enc_lcls;
 gsm0808_dec_lcls;
+osmo_gsm0808_msg_size;
+osmo_gsm0808_msg_headroom;
 
 gsm29118_msgb_alloc;
 gsm29118_create_alert_req;

-- 
To view, visit https://gerrit.osmocom.org/13004
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I95729991eb49555f8bba60c5dc916131b03b6cf2
Gerrit-Change-Number: 13004
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190222/05b34761/attachment.htm>


More information about the gerrit-log mailing list