From 9af7028ebe72bb5bf47713f11b4e111ed83c0693 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 10 Dec 2017 14:13:33 +0100 Subject: sccp_helpers: don't return msgb with l2h set It's a bad idea to use sccp_msgb_alloc() for SCCP User Primitive msgbs. The rationale is quite simple: The SCU msgb's are used for wrapping osmo_prim. The user payload data (e.g. BSSAP) in such primitives is found at msgb->l2h. However, user payload data is optional. So in a SCU primitive without user data, we must have msgb->l2h == NULL. The old behavior resulted in bogus data (actually the sccp_user_prim) to be contained in the DATA section of SCCP messages such as RLSD/RLC. Also, the old implementation of scu_msgb_alloc() discarded the 'name' argument and replaced it with a static "SCU" which was of course another bug. Change-Id: I19cb83302aaa404ab1a2d92e6f2aec43d0380426 Related: OS#2732 --- src/sccp_helpers.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sccp_helpers.c b/src/sccp_helpers.c index 078ca2b..1a67488 100644 --- a/src/sccp_helpers.c +++ b/src/sccp_helpers.c @@ -33,9 +33,12 @@ #include "sccp_internal.h" +#define SCU_MSG_SIZE 2048 +#define SCU_MSG_HEADROOM 0 + static struct msgb *scu_msgb_alloc(const char *name) { - return sccp_msgb_alloc("SCU"); + return msgb_alloc_headroom(SCU_MSG_SIZE+SCU_MSG_HEADROOM, SCU_MSG_HEADROOM, name); } void osmo_sccp_make_addr_pc_ssn(struct osmo_sccp_addr *addr, uint32_t pc, uint32_t ssn) -- cgit v1.2.3