diff options
author | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2021-02-06 16:02:12 +0100 |
---|---|---|
committer | laforge <laforge@osmocom.org> | 2021-02-10 15:06:54 +0000 |
commit | 522a33fe82056a444678d19b0522f0e3fb602d14 (patch) | |
tree | 766509e1451226d6e069f79fac20aeb80207ca4a | |
parent | b1485cd590feaa738b791f7d6835873180d4db02 (diff) |
oml: reuse the given msgb in oml_fom_ack_nack()
This would allow to compose ACK/NACK messages with additional IEs
not present in the original message. Also, this change basically
eliminates unnecessary msgb_copy() / free().
Change-Id: I17f61636e9a144017e2c46b1540d152c21529391
Related: OS#3791
-rw-r--r-- | src/common/oml.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/common/oml.c b/src/common/oml.c index 9886fe44..d395d8f6 100644 --- a/src/common/oml.c +++ b/src/common/oml.c @@ -424,23 +424,15 @@ int oml_mo_opstart_nack(const struct gsm_abis_mo *mo, uint8_t nack_cause) return oml_mo_fom_ack_nack(mo, NM_MT_OPSTART, nack_cause); } -/* Send an ACK or NACK response for 'msg' to BSC, deriving message - * type, obj class, obj inst from 'msg' and copying all attributes - * contained in 'msg'. ACK is sent if cause == 0; NACK otherwise */ -int oml_fom_ack_nack(struct msgb *old_msg, uint8_t cause) +/* Send an ACK or NACK response to BSC for the given OML message, + * reusing it. ACK is sent if cause == 0; NACK otherwise. */ +int oml_fom_ack_nack(struct msgb *msg, uint8_t cause) { - struct msgb *msg; struct abis_om_fom_hdr *foh; - msg = msgb_copy(old_msg, "OML_fom_ack_nack"); - if (!msg) - return -ENOMEM; - - /* remove any l2/l1 that may be present in copy */ + /* remove any l2/l1 that may be already present */ msgb_pull_to_l2(msg); - msg->trx = old_msg->trx; - foh = (struct abis_om_fom_hdr *) msg->l3h; /* alter message type */ @@ -459,7 +451,11 @@ int oml_fom_ack_nack(struct msgb *old_msg, uint8_t cause) } /* we cannot use oml_send_msg() as we already have the OML header */ - return abis_oml_sendmsg(msg); + if (abis_oml_sendmsg(msg) != 0) + LOGPFOH(DOML, LOGL_ERROR, foh, "Failed to send ACK/NACK\n"); + + /* msgb was reused, do not free() */ + return 1; } /* @@ -1537,6 +1533,10 @@ int down_oml(struct gsm_bts *bts, struct msgb *msg) ret = -EINVAL; } + /* msgb was reused, do not free() */ + if (ret == 1) + return 0; + msgb_free(msg); return ret; |