pespin has submitted this change. (
https://gerrit.osmocom.org/c/libosmo-sigtran/+/39398?usp=email )
(
11 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: ASP loadsharing: Pass xua_msg down to xua_as_transmit_msg
......................................................................
ASP loadsharing: Pass xua_msg down to xua_as_transmit_msg
This finally allows having access to msg values such as OPC and SLS at
the point in code where decision is taken to route the message to one
ASP inside the AS.
This will be needed to properly implemented ASP loadsharing within an
AS.
Related: SYS#7112
Change-Id: I70e5d33c7537dc0b72b5abced876e69018cc0829
---
M src/ipa.c
M src/m3ua.c
M src/sua.c
M src/xua_as_fsm.c
M src/xua_as_fsm.h
M src/xua_internal.h
M src/xua_msg.h
7 files changed, 60 insertions(+), 51 deletions(-)
Approvals:
Jenkins Builder: Verified
pespin: Looks good to me, approved
osmith: Looks good to me, but someone else must approve
laforge: Looks good to me, but someone else must approve
diff --git a/src/ipa.c b/src/ipa.c
index bbe94d1..c04b476 100644
--- a/src/ipa.c
+++ b/src/ipa.c
@@ -52,7 +52,7 @@
#include "ss7_internal.h"
#include "xua_asp_fsm.h"
-static struct msgb *ipa_to_msg(struct xua_msg *xua)
+struct msgb *ipa_to_msg(struct xua_msg *xua)
{
struct xua_msg_part *data_ie;
struct m3ua_data_hdr *data_hdr;
@@ -100,17 +100,9 @@
*/
int ipa_tx_xua_as(struct osmo_ss7_as *as, struct xua_msg *xua)
{
- struct msgb *msg;
OSMO_ASSERT(as->cfg.proto == OSMO_SS7_ASP_PROT_IPA);
- msg = ipa_to_msg(xua);
- xua_msg_free(xua);
- if (!msg) {
- LOGPAS(as, DLSS7, LOGL_ERROR, "Error encoding IPA Msg\n");
- return -1;
- }
-
- return xua_as_transmit_msg(as, msg);
+ return xua_as_transmit_msg(as, xua);
}
static int ipa_rx_msg_ccm(struct osmo_ss7_asp *asp, struct msgb *msg)
diff --git a/src/m3ua.c b/src/m3ua.c
index 8232d7b..39c799e 100644
--- a/src/m3ua.c
+++ b/src/m3ua.c
@@ -486,7 +486,7 @@
***********************************************************************/
/* Convert M3UA from xua_msg to msgb and set PPID/stream */
-static struct msgb *m3ua_to_msg(struct xua_msg *xua)
+struct msgb *m3ua_to_msg(struct xua_msg *xua)
{
struct msgb *msg = xua_to_msg(M3UA_VERSION, xua);
@@ -533,7 +533,6 @@
*/
int m3ua_tx_xua_as(struct osmo_ss7_as *as, struct xua_msg *xua)
{
- struct msgb *msg;
int rc;
OSMO_ASSERT(as->cfg.proto == OSMO_SS7_ASP_PROT_M3UA);
@@ -542,18 +541,11 @@
if (as->cfg.routing_key.context)
xua_msg_add_u32(xua, M3UA_IEI_ROUTE_CTX, as->cfg.routing_key.context);
- msg = m3ua_to_msg(xua);
- xua_msg_free(xua);
- if (!msg) {
- LOGPAS(as, DLM3UA, LOGL_ERROR, "Error encoding M3UA Msg\n");
- return -1;
- }
-
/* send the msg to the AS for transmission. The AS FSM might
* (depending on its state) enqueue it before transmission */
- rc = osmo_fsm_inst_dispatch(as->fi, XUA_AS_E_TRANSFER_REQ, msg);
+ rc = osmo_fsm_inst_dispatch(as->fi, XUA_AS_E_TRANSFER_REQ, xua);
if (rc < 0)
- msgb_free(msg);
+ xua_msg_free(xua);
return rc;
}
diff --git a/src/sua.c b/src/sua.c
index 4d90f9b..41bea1b 100644
--- a/src/sua.c
+++ b/src/sua.c
@@ -310,7 +310,6 @@
* \return 0 on success; negative on error */
int sua_tx_xua_as(struct osmo_ss7_as *as, struct xua_msg *xua)
{
- struct msgb *msg;
int rc;
OSMO_ASSERT(as->cfg.proto == OSMO_SS7_ASP_PROT_SUA);
@@ -319,18 +318,11 @@
if (as->cfg.routing_key.context)
xua_msg_add_u32(xua, SUA_IEI_ROUTE_CTX, as->cfg.routing_key.context);
- msg = sua_to_msg(xua);
- xua_msg_free(xua);
- if (!msg) {
- LOGPAS(as, DLSUA, LOGL_ERROR, "Error encoding SUA Msg\n");
- return -1;
- }
-
/* send the msg to the AS for transmission. The AS FSM might
* (depending on its state) enqueue it before transmission */
- rc = osmo_fsm_inst_dispatch(as->fi, XUA_AS_E_TRANSFER_REQ, msg);
+ rc = osmo_fsm_inst_dispatch(as->fi, XUA_AS_E_TRANSFER_REQ, xua);
if (rc < 0)
- msgb_free(msg);
+ xua_msg_free(xua);
return rc;
}
diff --git a/src/xua_as_fsm.c b/src/xua_as_fsm.c
index c4a167c..d0bc019 100644
--- a/src/xua_as_fsm.c
+++ b/src/xua_as_fsm.c
@@ -121,13 +121,29 @@
return -1;
}
-int xua_as_transmit_msg_broadcast(struct osmo_ss7_as *as, struct msgb *msg)
+static struct msgb *xua_as_encode_msg(const struct osmo_ss7_as *as, struct xua_msg *xua)
+{
+ switch (as->cfg.proto) {
+ case OSMO_SS7_ASP_PROT_M3UA:
+ return m3ua_to_msg(xua);
+ case OSMO_SS7_ASP_PROT_IPA:
+ return ipa_to_msg(xua);
+ default:
+ OSMO_ASSERT(0);
+ }
+}
+
+int xua_as_transmit_msg_broadcast(struct osmo_ss7_as *as, struct xua_msg *xua)
{
struct osmo_ss7_asp *asp;
unsigned int i;
+ struct msgb *msg;
struct msgb *msg_cpy;
bool sent = false;
+ msg = xua_as_encode_msg(as, xua);
+ OSMO_ASSERT(msg);
+
for (i = 0; i < ARRAY_SIZE(as->cfg.asps); i++) {
asp = as->cfg.asps[i];
if (!asp || !osmo_ss7_asp_active(asp))
@@ -138,35 +154,41 @@
}
msgb_free(msg);
+ xua_msg_free(xua);
return sent ? 0 : -1;
}
/* actually transmit a message through this AS */
-int xua_as_transmit_msg(struct osmo_ss7_as *as, struct msgb *msg)
+int xua_as_transmit_msg(struct osmo_ss7_as *as, struct xua_msg *xua)
{
struct osmo_ss7_asp *asp = NULL;
+ struct msgb *msg;
switch (as->cfg.mode) {
case OSMO_SS7_AS_TMOD_OVERRIDE:
case OSMO_SS7_AS_TMOD_LOADSHARE:
/* TODO: OSMO_SS7_AS_TMOD_LOADSHARE: actually use the SLS value
- * to ensure same SLS goes through same ASP. Not strictly
- * required by M3UA RFC, but would fit the overall principle. */
+ * in xua->mtp.sls to ensure same SLS goes through same ASP. Not
+ * strictly required by M3UA RFC, but would fit the overall
+ * principle. */
case OSMO_SS7_AS_TMOD_ROUNDROBIN:
asp = osmo_ss7_as_select_asp(as);
break;
case OSMO_SS7_AS_TMOD_BCAST:
- return xua_as_transmit_msg_broadcast(as, msg);
+ return xua_as_transmit_msg_broadcast(as, xua);
case _NUM_OSMO_SS7_ASP_TMOD:
OSMO_ASSERT(false);
}
if (!asp) {
LOGPFSM(as->fi, "No ASP in AS, dropping message\n");
- msgb_free(msg);
+ xua_msg_free(xua);
return -1;
}
+ msg = xua_as_encode_msg(as, xua);
+ OSMO_ASSERT(msg);
+ xua_msg_free(xua);
return osmo_ss7_asp_send(asp, msg);
}
@@ -192,7 +214,7 @@
struct osmo_ss7_as *as;
struct {
struct osmo_timer_list t_r;
- struct llist_head queued_msgs;
+ struct llist_head queued_xua_msgs;
} recovery;
bool ipa_route_created;
};
@@ -481,7 +503,7 @@
struct xua_as_fsm_priv *xafp = (struct xua_as_fsm_priv *) fi->priv;
struct osmo_ss7_asp *asp;
struct xua_as_event_asp_inactive_ind_pars *inact_ind_pars;
- struct msgb *msg;
+ struct xua_msg *xua;
struct osmo_xlm_prim_notify npar;
switch (event) {
@@ -510,8 +532,8 @@
break;
case XUA_AS_E_TRANSFER_REQ:
/* message for transmission */
- msg = data;
- xua_as_transmit_msg(xafp->as, msg);
+ xua = data;
+ xua_as_transmit_msg(xafp->as, xua);
break;
}
}
@@ -520,7 +542,7 @@
{
struct xua_as_fsm_priv *xafp = (struct xua_as_fsm_priv *) fi->priv;
struct xua_as_event_asp_inactive_ind_pars *inact_ind_pars;
- struct msgb *msg;
+ struct xua_msg *xua;
struct osmo_xlm_prim_notify npar;
switch (event) {
@@ -529,8 +551,12 @@
osmo_timer_del(&xafp->recovery.t_r);
osmo_fsm_inst_state_chg(fi, XUA_AS_S_ACTIVE, 0, 0);
/* push out any pending queued messages */
- while ((msg = msgb_dequeue(&xafp->recovery.queued_msgs)))
- xua_as_transmit_msg(xafp->as, msg);
+ while (!llist_empty(&xafp->recovery.queued_xua_msgs)) {
+ struct xua_msg *xua;
+ xua = llist_first_entry(&xafp->recovery.queued_xua_msgs, struct xua_msg,
entry);
+ llist_del(&xua->entry);
+ xua_as_transmit_msg(xafp->as, xua);
+ }
break;
case XUA_ASPAS_ASP_INACTIVE_IND:
inact_ind_pars = data;
@@ -544,8 +570,12 @@
break;
case XUA_AS_E_RECOVERY_EXPD:
LOGPFSM(fi, "T(r) expired; dropping queued messages\n");
- while ((msg = msgb_dequeue(&xafp->recovery.queued_msgs)))
- talloc_free(msg);
+ while (!llist_empty(&xafp->recovery.queued_xua_msgs)) {
+ struct xua_msg *xua;
+ xua = llist_first_entry(&xafp->recovery.queued_xua_msgs, struct xua_msg,
entry);
+ llist_del(&xua->entry);
+ xua_msg_free(xua);
+ }
if (check_any_other_asp_not_down(xafp->as, NULL))
osmo_fsm_inst_state_chg(fi, XUA_AS_S_INACTIVE, 0, 0);
else
@@ -553,8 +583,8 @@
break;
case XUA_AS_E_TRANSFER_REQ:
/* enqueue the to-be-transferred message */
- msg = data;
- msgb_enqueue(&xafp->recovery.queued_msgs, msg);
+ xua = data;
+ llist_add_tail(&xua->entry, &xafp->recovery.queued_xua_msgs);
break;
}
}
@@ -642,7 +672,7 @@
xafp->as = as;
xafp->recovery.t_r.cb = t_r_callback;
xafp->recovery.t_r.data = fi;
- INIT_LLIST_HEAD(&xafp->recovery.queued_msgs);
+ INIT_LLIST_HEAD(&xafp->recovery.queued_xua_msgs);
fi->priv = xafp;
diff --git a/src/xua_as_fsm.h b/src/xua_as_fsm.h
index cf897e2..08f626b 100644
--- a/src/xua_as_fsm.h
+++ b/src/xua_as_fsm.h
@@ -24,7 +24,7 @@
XUA_ASPAS_ASP_DOWN_IND,
XUA_ASPAS_ASP_ACTIVE_IND,
XUA_AS_E_RECOVERY_EXPD,
- XUA_AS_E_TRANSFER_REQ,
+ XUA_AS_E_TRANSFER_REQ, /* param: struct xua_msg*, ownership transferred. */
};
extern struct osmo_fsm xua_as_fsm;
diff --git a/src/xua_internal.h b/src/xua_internal.h
index 3e9c15b..4d99231 100644
--- a/src/xua_internal.h
+++ b/src/xua_internal.h
@@ -33,6 +33,7 @@
struct osmo_mtp_prim *m3ua_to_xfer_ind(struct xua_msg *xua);
int m3ua_hmdc_rx_from_l2(struct osmo_ss7_instance *inst, struct xua_msg *xua);
+struct msgb *m3ua_to_msg(struct xua_msg *xua);
int m3ua_tx_xua_as(struct osmo_ss7_as *as, struct xua_msg *xua);
void m3ua_tx_snm_available(struct osmo_ss7_asp *asp, const uint32_t *rctx, unsigned int
num_rctx,
const uint32_t *aff_pc, unsigned int num_aff_pc,
@@ -114,11 +115,12 @@
#define PC_STR "Point Code\n"
#define INST_STR "An instance of the SS7 stack\n"
-int xua_as_transmit_msg(struct osmo_ss7_as *as, struct msgb *msg);
+int xua_as_transmit_msg(struct osmo_ss7_as *as, struct xua_msg *xua);
int xua_find_as_for_asp(struct osmo_ss7_as **as, const struct osmo_ss7_asp *asp,
const struct xua_msg_part *rctx_ie);
+struct msgb *ipa_to_msg(struct xua_msg *xua);
int ipa_tx_xua_as(struct osmo_ss7_as *as, struct xua_msg *xua);
int ipa_rx_msg(struct osmo_ss7_asp *asp, struct msgb *msg, uint8_t sls);
struct osmo_ss7_as *ipa_find_as_for_asp(struct osmo_ss7_asp *asp);
diff --git a/src/xua_msg.h b/src/xua_msg.h
index 5f877ed..79af86f 100644
--- a/src/xua_msg.h
+++ b/src/xua_msg.h
@@ -29,6 +29,7 @@
struct osmo_sccp_gt;
struct xua_msg {
+ struct llist_head entry; /* Allows queueing a xua_msg into a llist */
struct xua_common_hdr hdr;
struct osmo_mtp_transfer_param mtp;
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-sigtran/+/39398?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: I70e5d33c7537dc0b72b5abced876e69018cc0829
Gerrit-Change-Number: 39398
Gerrit-PatchSet: 12
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>