From 974cc7b32447a85d95e45f66e878234232bbe227 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Sat, 10 Oct 2020 06:00:05 +0700 Subject: [PATCH] gprs_bssgp_pcu: fix: do not crash on receipt of subsequent INFO.ind It's expected to receive subsequent INFO.ind messages at run-time, e.g. when a dynamic TCH/F_TCH/H_PDCH timeslot is switched from PDCH to TCH/F or TCH/H, osmo-bts would send us INFO.ind with the updated PDCH slot-mask indicating that this timeslot is disabled. In gprs_nsvc_create_and_connect(), do not bind() on the received NSVC address unconditionally - we may already be bound to it. Instead, return early and keep everything unchanged. I don't know how the PCU is supposed to handle NSVC address change, at least the new NS2 library does not handle this internally, nor it provides any API for that. Let's leave it for later. Change-Id: I159138e41e147cd30212da548b0ccd3f81d61b4e Related: I4c3bc883d795e5d1ee5ab175ac03684924692a7c Fixes: Ib389925cf5c9f18951af6242c31ea70476218e9a Related: SYS#5108 --- src/gprs_bssgp_pcu.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp index e0cfc378..adf5bf3c 100644 --- a/src/gprs_bssgp_pcu.cpp +++ b/src/gprs_bssgp_pcu.cpp @@ -930,6 +930,21 @@ int gprs_nsvc_create_and_connect(struct gprs_rlcmac_bts *bts, struct gprs_ns2_vc_bind *bind; int rc; + bts->nse = gprs_ns2_nse_by_nsei(bts->nsi, nsei); + if (bts->nse != NULL) { + /* FIXME: we end up here on receipt of subsequent INFO.ind. + * What are we supposed to do? Re-establish the connection? */ + LOGP(DBSSGP, LOGL_INFO, "NSE with NSEI %u is already configured, " + "keeping it unchanged\n", nsei); + return 0; + } + + bts->nse = gprs_ns2_create_nse(bts->nsi, nsei); + if (!bts->nse) { + LOGP(DBSSGP, LOGL_ERROR, "Failed to create NSE\n"); + return 1; + } + rc = gprs_ns2_ip_bind(bts->nsi, local, 0, &bind); if (rc < 0) { LOGP(DBSSGP, LOGL_ERROR, "Failed to create socket\n"); @@ -937,16 +952,6 @@ int gprs_nsvc_create_and_connect(struct gprs_rlcmac_bts *bts, return 1; } - bts->nse = gprs_ns2_nse_by_nsei(bts->nsi, nsei); - if (!bts->nse) - bts->nse = gprs_ns2_create_nse(bts->nsi, nsei); - - if (!bts->nse) { - LOGP(DBSSGP, LOGL_ERROR, "Failed to create NSE\n"); - gprs_ns2_free_bind(bind); - return 1; - } - if (bts->gb_dialect_sns) { rc = gprs_ns2_ip_connect_sns(bind, sgsn, nsei); } else {