Change in osmo-gbproxy[master]: gbproxy: Route BSSGP STATUS with PDU_IN_ERROR containing a TLLI

daniel gerrit-no-reply at lists.osmocom.org
Wed Jul 28 11:04:49 UTC 2021


daniel has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-gbproxy/+/25077 )


Change subject: gbproxy: Route BSSGP STATUS with PDU_IN_ERROR containing a TLLI
......................................................................

gbproxy: Route BSSGP STATUS with PDU_IN_ERROR containing a TLLI

Fixes TC_status_sig_ul_tlli

Related: OS#4892
Change-Id: I9d2ec73520ee46ceedda3f7e63035e6a51a65ac2
---
M src/gb_proxy.c
1 file changed, 49 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-gbproxy refs/changes/77/25077/1

diff --git a/src/gb_proxy.c b/src/gb_proxy.c
index 94ac4a3..f473c39 100644
--- a/src/gb_proxy.c
+++ b/src/gb_proxy.c
@@ -988,6 +988,28 @@
 	return gbprox_relay2nse(msg, sgsn->nse, 0);
 }
 
+static int gbproxy_tlli_from_status_pdu(struct msgb *msg, struct tlv_parsed *tp, uint32_t *tlli)
+{
+	int rc;
+	int pdu_len = TLVP_LEN(tp, BSSGP_IE_PDU_IN_ERROR);
+	const uint8_t *pdu_data = TLVP_VAL(tp, BSSGP_IE_PDU_IN_ERROR);
+	struct bssgp_normal_hdr *bgph = (struct bssgp_normal_hdr *)pdu_data;
+	struct tlv_parsed tp_inner[2];
+
+	rc = osmo_tlv_prot_parse(&osmo_pdef_bssgp, tp, ARRAY_SIZE(tp_inner), bgph->pdu_type, bgph->data, pdu_len - sizeof(*bgph), 0, 0, DGPRS, "FOO");
+
+	if (rc < 0)
+		return rc;
+
+	if (TLVP_PRESENT(tp, BSSGP_IE_TLLI)) {
+		*tlli = osmo_load32be(TLVP_VAL(tp, BSSGP_IE_TLLI));
+	} else {
+		return -ENOENT;
+	}
+
+	return 0;
+}
+
 /* Receive an incoming signalling message from a BSS-side NS-VC */
 static int gbprox_rx_sig_from_bss(struct gbproxy_nse *nse, struct msgb *msg, uint16_t ns_bvci)
 {
@@ -1078,9 +1100,36 @@
 		break;
 	}
 	case BSSGP_PDUT_STATUS:
+	{
+		/* Check if the status needs to be terminated locally */
+		uint8_t cause = *TLVP_VAL(&tp[0], BSSGP_IE_CAUSE);
+		if (cause == BSSGP_CAUSE_UNKNOWN_BVCI || cause == BSSGP_CAUSE_BVCI_BLOCKED) {
+			/* Log and handle locally */
+			ptp_bvci = ntohs(tlvp_val16_unal(&tp[0], BSSGP_IE_BVCI));
+			LOGP(DGPRS, LOGL_ERROR, "%s Rx STATUS with cause %s for PtP-BVC %05u\n", log_pfx,
+				bssgp_cause_str (cause), ptp_bvci);
+			/* FIXME: Remove/block our BVC if present? */
+			break;
+		}
+
+		LOGP(DGPRS, LOGL_INFO, "Forwarding STATUS with cause %s\n", bssgp_cause_str(cause));
+		struct gbproxy_sgsn *sgsn;
+		if (gbproxy_tlli_from_status_pdu(msg, tp, &tlli) == 0) {
+			sgsn = gbproxy_select_sgsn(nse->cfg, &tlli);
+		} else {
+			sgsn = gbproxy_select_sgsn(nse->cfg, NULL);
+		}
+		if (!sgsn) {
+
+			rc = -EINVAL;
+			break;
+		}
+
+		rc = gbprox_relay2nse(msg, sgsn->nse, 0);
 		/* FIXME: inspect the erroneous PDU IE (if any) and check
 		 * if we can extract a TLLI/RNI to route it to the correct SGSN */
 		break;
+	}
 	case BSSGP_PDUT_RAN_INFO:
 	case BSSGP_PDUT_RAN_INFO_REQ:
 	case BSSGP_PDUT_RAN_INFO_ACK:

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

Gerrit-Project: osmo-gbproxy
Gerrit-Branch: master
Gerrit-Change-Id: I9d2ec73520ee46ceedda3f7e63035e6a51a65ac2
Gerrit-Change-Number: 25077
Gerrit-PatchSet: 1
Gerrit-Owner: daniel <dwillmann at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210728/d95531ee/attachment.htm>


More information about the gerrit-log mailing list