gbproxy_peer: Free all related BVCs if the cell is freed

Previously the SGSN BVCs would still be present after the related Cell
was freed. This caused some inconsistencies if a BVC with the same BVCI
was established again. The symptoms of this were cells that were attached
to no SGSN or the same one multiple times and crashes.

This patch ensures that the SGSN-side BVCs are also freed when the cell
is freed and that this fact is reflected when handling reset
notifications.

Change-Id: Iedeede8917e2870e0b62a2050ccb331109167017
This commit is contained in:
Daniel Willmann 2021-12-06 16:47:22 +01:00
parent e705b3fb3f
commit 28ec0e33fc
2 changed files with 12 additions and 2 deletions

View File

@ -682,8 +682,10 @@ static void bss_ptp_bvc_reset_notif(uint16_t nsei, uint16_t bvci, const struct g
LOGPBVC(bvc->cell->bss_bvc, LOGL_NOTICE, "Destroying due to conflicting "
"BVCI configuration (new NSEI=%05u)!\n", bvc->nse->nsei);
gbproxy_bvc_free(bvc->cell->bss_bvc);
bvc->cell = NULL;
} else {
LOGPBVC(bvc, LOGL_ERROR, "Found cell without BSS BVC, this should not happen!");
}
bvc->cell->bss_bvc = bvc;
}
}

View File

@ -217,8 +217,16 @@ void gbproxy_cell_cleanup_bvc(struct gbproxy_cell *cell, struct gbproxy_bvc *bvc
{
int i;
if (cell->bss_bvc == bvc)
if (cell->bss_bvc == bvc) {
/* Remove the whole cell including all BVCs */
for (i = 0; i < ARRAY_SIZE(cell->sgsn_bvc); i++) {
if (cell->sgsn_bvc[i]) {
gbproxy_bvc_free(cell->sgsn_bvc[i]);
cell->sgsn_bvc[i] = NULL;
}
}
return gbproxy_cell_free(cell);
}
/* we could also be a SGSN-side BVC */
for (i = 0; i < ARRAY_SIZE(cell->sgsn_bvc); i++) {