Change in libosmocore[master]: ns2: correct parse a STATUS PDU which was received over a different NSVC

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

lynxis lazus gerrit-no-reply at lists.osmocom.org
Thu Sep 23 11:41:03 UTC 2021


lynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/25557 )


Change subject: ns2: correct parse a STATUS PDU which was received over a different NSVC
......................................................................

ns2: correct parse a STATUS PDU which was received over a different NSVC

STATUS PDU can be send over a different NSVC than the NSVC.
E.g. informing a NSVC got blocked in case of a lower-layer failure.

Change-Id: I5c9e9de10c669c1226da67bb9e2663c5cfe828a8
---
M src/gb/gprs_ns2_vc_fsm.c
1 file changed, 24 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/57/25557/1

diff --git a/src/gb/gprs_ns2_vc_fsm.c b/src/gb/gprs_ns2_vc_fsm.c
index d09c31a..3395254 100644
--- a/src/gb/gprs_ns2_vc_fsm.c
+++ b/src/gb/gprs_ns2_vc_fsm.c
@@ -851,6 +851,7 @@
 int ns2_vc_rx(struct gprs_ns2_vc *nsvc, struct msgb *msg, struct tlv_parsed *tp)
 {
 	struct gprs_ns_hdr *nsh = (struct gprs_ns_hdr *) msg->l2h;
+	struct gprs_ns2_vc *target_nsvc = NULL;
 	struct osmo_fsm_inst *fi = nsvc->fi;
 	int rc = 0;
 	uint8_t cause;
@@ -884,11 +885,27 @@
 		nsvci = tlvp_val16be(tp, NS_IE_VCI);
 		if (nsvci != nsvc->nsvci) {
 			/* 48.016 § 7.3.1 send RESET_ACK to wrong NSVCI + ignore */
-			if (nsh->pdu_type == NS_PDUT_RESET)
+			if (nsh->pdu_type == NS_PDUT_RESET) {
 				ns2_tx_reset_ack(nsvc);
+			} else if (nsh->pdu_type == NS_PDUT_STATUS) {
+				/* this is a PDU received over a NSVC and reports a status for another NSVC */
+				target_nsvc = gprs_ns2_nsvc_by_nsvci(nsvc->nse->nsi,  nsvci);
+				if (!target_nsvc) {
+					LOGPFSML(fi, LOGL_ERROR, "Received a STATUS PDU for unknown NSVC (NSVCI %d)\n", nsvci);
+					goto out;
+				}
 
-			LOG_NS_SIGNAL(nsvc, "Rx", nsh->pdu_type, LOGL_ERROR, " with wrong NSVCI=%05u. Ignoring PDU.\n", nsvci);
-			goto out;
+				if (target_nsvc->nse != nsvc->nse) {
+					LOGPFSML(fi, LOGL_ERROR, "Received a STATUS PDU for a NSVC (NSVCI %d) but it belongs to a different NSE!\n", nsvci);
+					/* send out status */
+					goto out;
+				}
+
+				/* the status will be passed to the nsvc/target nsvc in the switch */
+			} else {
+				LOG_NS_SIGNAL(nsvc, "Rx", nsh->pdu_type, LOGL_ERROR, " with wrong NSVCI=%05u. Ignoring PDU.\n", nsvci);
+				goto out;
+			}
 		}
 	}
 
@@ -922,7 +939,10 @@
 		osmo_fsm_inst_dispatch(fi, GPRS_NS2_EV_RX_UNITDATA, msg);
 		return 0;
 	case NS_PDUT_STATUS:
-		osmo_fsm_inst_dispatch(fi, GPRS_NS2_EV_RX_STATUS, tp);
+		if (target_nsvc)
+			osmo_fsm_inst_dispatch(target_nsvc->fi, GPRS_NS2_EV_RX_STATUS, tp);
+		else
+			osmo_fsm_inst_dispatch(fi, GPRS_NS2_EV_RX_STATUS, tp);
 		break;
 	default:
 		LOGPFSML(fi, LOGL_ERROR, "NSEI=%u Rx unknown NS PDU type %s\n", nsvc->nse->nsei,

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I5c9e9de10c669c1226da67bb9e2663c5cfe828a8
Gerrit-Change-Number: 25557
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210923/23ef0073/attachment.htm>


More information about the gerrit-log mailing list