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
This commit is contained in:
Vadim Yanitskiy 2021-02-06 16:02:12 +01:00 committed by laforge
parent b1485cd590
commit 522a33fe82
1 changed files with 13 additions and 13 deletions

View File

@ -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;