laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-bts/+/22763 )

Change subject: oml: reuse the given msgb in oml_fom_ack_nack()
......................................................................

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
---
M src/common/oml.c
1 file changed, 13 insertions(+), 13 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/common/oml.c b/src/common/oml.c
index 9886fe4..d395d8f 100644
--- a/src/common/oml.c
+++ b/src/common/oml.c
@@ -424,23 +424,15 @@
        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 @@
        }

        /* 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 @@
                ret = -EINVAL;
        }

+       /* msgb was reused, do not free() */
+       if (ret == 1)
+               return 0;
+
        msgb_free(msg);
 
        return ret;

--
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/22763
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I17f61636e9a144017e2c46b1540d152c21529391
Gerrit-Change-Number: 22763
Gerrit-PatchSet: 3
Gerrit-Owner: fixeria <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-MessageType: merged

Reply via email to