Change in osmo-bts[master]: oml: reuse the given msgb in oml_fom_ack_nack()

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

fixeria gerrit-no-reply at lists.osmocom.org
Sat Feb 6 16:07:23 UTC 2021


fixeria has uploaded this change for review. ( 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()

Change-Id: I17f61636e9a144017e2c46b1540d152c21529391
---
M src/common/oml.c
1 file changed, 13 insertions(+), 13 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/63/22763/1

diff --git a/src/common/oml.c b/src/common/oml.c
index b1ae7b4..12875f4 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: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210206/7e563ca8/attachment.htm>


More information about the gerrit-log mailing list