lynxis has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/44076?usp=email ) Change subject: tcap_as_loadshare: close the ASP connection when receiving an invalid message ...................................................................... tcap_as_loadshare: close the ASP connection when receiving an invalid message Related: SYS#8286 Change-Id: Iae3d2ebce2e984db497794297696af36ca7f010b --- M src/tcap_as_loadshare.c 1 file changed, 25 insertions(+), 13 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/76/44076/1 diff --git a/src/tcap_as_loadshare.c b/src/tcap_as_loadshare.c index 6a923e8..d490319 100644 --- a/src/tcap_as_loadshare.c +++ b/src/tcap_as_loadshare.c @@ -904,9 +904,9 @@ if (cs7_role != CS7_ROLE_SG) { LOGPASP(asp, DLTCAP, LOGL_ERROR, - "Rx unexpected OSMO IPA EXT TCAP ROUTING msg in role != CS7_ROLE_SG!\n"); + "Rx unexpected OSMO IPA EXT TCAP ROUTING msg in role != CS7_ROLE_SG! Closing connection.\n"); rc = -ENOENT; - goto out; + goto err_close; } /* in the IPA case, we assume there is a 1:1 mapping between the @@ -915,17 +915,17 @@ * know the identity of the peer */ as = ss7_asp_get_first_as(asp); if (!as) { - LOGPASP(asp, DLTCAP, LOGL_ERROR, "Rx message for IPA ASP without AS?!\n"); + LOGPASP(asp, DLTCAP, LOGL_ERROR, "Rx message for IPA ASP without AS?! Closing connection.\n"); rc = -ENOENT; - goto out; + goto err_close; } /* pull the IPA and OSMO_EXT header */ hdr = (struct ipa_tcap_routing_hdr *) msgb_data(msg); if (msgb_length(msg) < sizeof(struct ipa_tcap_routing_hdr)) { - LOGPASP(asp, DLTCAP, LOGL_ERROR, "TCAP routing message too short\n"); + LOGPASP(asp, DLTCAP, LOGL_ERROR, "TCAP routing message too short. Closing connection.\n"); rc = -EINVAL; - goto out; + goto err_close; } if (!as->cfg.loadshare.tcap.enabled || as->cfg.mode != OSMO_SS7_AS_TMOD_LOADSHARE) @@ -939,9 +939,9 @@ struct ipa_tcap_routing_add_range tcar = {}; if (msgb_length(msg) < sizeof(*hdr) + sizeof(struct ipa_tcap_routing_add_range)) { - LOGPASP(asp, DLTCAP, LOGL_ERROR, "TCAP routing message is too small\n"); + LOGPASP(asp, DLTCAP, LOGL_ERROR, "TCAP Add Range message is too small\n"); rc = -EINVAL; - goto out; + goto err_close; } msgb_pull(msg, sizeof(*hdr)); @@ -981,9 +981,9 @@ } case MT_TID_ACCEPT_NEW_TRANS: if (msgb_length(msg) < sizeof(*hdr) + sizeof(struct ipa_tcap_routing_accept_new_trans)) { - LOGPASP(asp, DLTCAP, LOGL_ERROR, "TCAP routing message is too small (accept new transactions)\n"); + LOGPASP(asp, DLTCAP, LOGL_ERROR, "TCAP New Transaction message is too small\n"); rc = -EINVAL; - goto out; + goto err_close; } msgb_pull(msg, sizeof(*hdr)); @@ -991,22 +991,34 @@ asp->tcap.accept_new_trans = msgb_pull_u8(msg) & 0x1; if (asp->tcap.accept_new_trans) LOGPASP(asp, DLTCAP, LOGL_INFO, - "TCAP New transaction command: ASP will receive new TCAP transactions\n"); + "TCAP New transaction message: ASP will receive new TCAP transactions\n"); else LOGPASP(asp, DLTCAP, LOGL_INFO, - "TCAP New transaction command: ASP won't receive new TCAP transactions\n"); + "TCAP New transaction message: ASP won't receive new TCAP transactions\n"); rc = ipa_tx_tcap_routing_ack(asp, osmo_ntohl(hdr->seq)); break; case MT_TID_ACK: /* shouldn't received from other end */ case MT_TID_NACK: /* shouldn't received from other end */ - default: + LOGPASP(asp, DLTCAP, LOGL_INFO, + "TCAP ACK / NACK message received, but not valid for this role. Closing connection.\n"); rc = -EINVAL; + goto err_close; + break; + default: + LOGPASP(asp, DLTCAP, LOGL_INFO, + "TCAP unknown routing message received. Closing connection.\n"); + rc = -EINVAL; + goto err_close; break; } out: return rc; + +err_close: + osmo_ss7_asp_disconnect(asp); + return rc; } /* update the short cuts contains_pc & contains_ssn */ -- To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/44076?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: libosmo-sigtran Gerrit-Branch: master Gerrit-Change-Id: Iae3d2ebce2e984db497794297696af36ca7f010b Gerrit-Change-Number: 44076 Gerrit-PatchSet: 1 Gerrit-Owner: lynxis <lynxis@fe80.eu>