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

laforge gerrit-no-reply at lists.osmocom.org
Fri Oct 8 05:43:57 UTC 2021


laforge has submitted this change. ( 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 which
generated the STATUS PDU. 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, 20 insertions(+), 4 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/src/gb/gprs_ns2_vc_fsm.c b/src/gb/gprs_ns2_vc_fsm.c
index 1a632b1..aa6613b 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 = nsvc;
 	struct osmo_fsm_inst *fi = nsvc->fi;
 	int rc = 0;
 	uint8_t cause;
@@ -884,11 +885,26 @@
 		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);
+					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 +938,7 @@
 		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);
+		osmo_fsm_inst_dispatch(target_nsvc->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: 4
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211008/20b9f72b/attachment.htm>


More information about the gerrit-log mailing list