gprs: Fix bssgp_rcvmsg to handle signalling msgs with BVCI IE
diff mbox

Message ID
State Superseded
Headers show

Commit Message

Jacob Erlbeck Sept. 10, 2014, 9:41 a.m. UTC
Currently BSSGP messages with an NS BVCI of 0 (signalling) are
discarded if they aren't RESET messages. Thus valid signalling
messages (e.g. BLOCK) are not handled properly, because the BVCI IE
is ignored if it present. Instead a STATUS message referring to BVCI
0 (instead of the BVCI used in the BLOCK message) is returned.

This patch changes the implementation to use the BVCI contained in
the BVCI IE if that is present in a signalling message.

It fixes BSSGP BLOCK/UNBLOCK for the osmo-sgsn.

Note that signalling messages without an BVCI IE (e.g.
SUSPEND/RESUME) are still rejected.

Ticket: OW#1205
Sponsored-by: On-Waves ehf
 src/gb/gprs_bssgp.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff mbox

diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c
index b8c6c74..0e9fd38 100644
--- a/src/gb/gprs_bssgp.c
+++ b/src/gb/gprs_bssgp.c
@@ -976,6 +976,7 @@  int bssgp_rcvmsg(struct msgb *msg)
 	struct bssgp_bvc_ctx *bctx;
 	uint8_t pdu_type = bgph->pdu_type;
 	uint16_t ns_bvci = msgb_bvci(msg);
+	uint16_t bvci = ns_bvci;
 	int data_len;
 	int rc = 0;
@@ -991,14 +992,17 @@  int bssgp_rcvmsg(struct msgb *msg)
 		rc = bssgp_tlv_parse(&tp, budh->data, data_len);
+		bvci = ntohs(*(uint16_t *)TLVP_VAL(&tp, BSSGP_IE_BVCI));
 	/* look-up or create the BTS context for this BVC */
-	bctx = btsctx_by_bvci_nsei(ns_bvci, msgb_nsei(msg));
+	bctx = btsctx_by_bvci_nsei(bvci, msgb_nsei(msg));
 	/* Only a RESET PDU can create a new BVC context */
 	if (!bctx && pdu_type != BSSGP_PDUT_BVC_RESET) {
-			"type %u for unknown BVCI\n", msgb_nsei(msg), ns_bvci,
+			"type %u for unknown BVCI\n", msgb_nsei(msg), bvci,
-		return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI, &ns_bvci, msg);
+		return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI, &bvci, msg);
 	if (bctx) {