Change in osmo-gbproxy[master]: gbproxy_peer: Free a cell as soon as no BSS BVC uses it

daniel gerrit-no-reply at lists.osmocom.org
Mon Jul 19 12:10:40 UTC 2021


daniel has submitted this change. ( https://gerrit.osmocom.org/c/osmo-gbproxy/+/24956 )

Change subject: gbproxy_peer: Free a cell as soon as no BSS BVC uses it
......................................................................

gbproxy_peer: Free a cell as soon as no BSS BVC uses it

This patch adds gbproxy_cell_cleanup_bvc() which removes the bvc pointer
to the cell. If the BSS BVC of this cell is removed it frees the whole
cell (removing all the SGSN BVC pointers to the cell). The SGSN-side
BVCs are blocked at this point and will only be reestablished if this
BVC is reset again from the BSS.

Before this patch cells were never freed and might accumulate over time.
They would only be reused if the bvci matched that of a previous cell.

Related: OS#4960
Change-Id: Ib874cbebcea58fa4bf15e1ff40fe11601573e531
---
M include/osmocom/gbproxy/gb_proxy.h
M src/gb_proxy_peer.c
2 files changed, 18 insertions(+), 15 deletions(-)

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



diff --git a/include/osmocom/gbproxy/gb_proxy.h b/include/osmocom/gbproxy/gb_proxy.h
index 76a7d31..1e73a1d 100644
--- a/include/osmocom/gbproxy/gb_proxy.h
+++ b/include/osmocom/gbproxy/gb_proxy.h
@@ -288,6 +288,7 @@
 struct gbproxy_cell *gbproxy_cell_by_cellid(struct gbproxy_config *cfg, const struct gprs_ra_id *raid, uint16_t cid);
 void gbproxy_cell_free(struct gbproxy_cell *cell);
 bool gbproxy_cell_add_sgsn_bvc(struct gbproxy_cell *cell, struct gbproxy_bvc *bvc);
+void gbproxy_cell_cleanup_bvc(struct gbproxy_cell *cell, struct gbproxy_bvc *bvc);
 
 /* NSE handling */
 struct gbproxy_nse *gbproxy_nse_alloc(struct gbproxy_config *cfg, uint16_t nsei, bool sgsn_facing);
diff --git a/src/gb_proxy_peer.c b/src/gb_proxy_peer.c
index 4eb427b..abbfa50 100644
--- a/src/gb_proxy_peer.c
+++ b/src/gb_proxy_peer.c
@@ -103,8 +103,6 @@
 
 void gbproxy_bvc_free(struct gbproxy_bvc *bvc)
 {
-	struct gbproxy_cell *cell;
-
 	if (!bvc)
 		return;
 
@@ -117,21 +115,10 @@
 
 	osmo_fsm_inst_free(bvc->fi);
 
-	cell = bvc->cell;
-	if (cell) {
-		int i;
-
-		if (cell->bss_bvc == bvc)
-			cell->bss_bvc = NULL;
-
-		/* we could also be a SGSN-side BVC */
-		for (i = 0; i < ARRAY_SIZE(cell->sgsn_bvc); i++) {
-			if (cell->sgsn_bvc[i] == bvc)
-				cell->sgsn_bvc[i] = NULL;
-		}
+	if (bvc->cell) {
+		gbproxy_cell_cleanup_bvc(bvc->cell, bvc);
 		bvc->cell = NULL;
 	}
-
 	talloc_free(bvc);
 }
 
@@ -214,6 +201,21 @@
 	return NULL;
 }
 
+void gbproxy_cell_cleanup_bvc(struct gbproxy_cell *cell, struct gbproxy_bvc *bvc)
+{
+	int i;
+
+	if (cell->bss_bvc == bvc)
+		return gbproxy_cell_free(cell);
+
+	/* we could also be a SGSN-side BVC */
+	for (i = 0; i < ARRAY_SIZE(cell->sgsn_bvc); i++) {
+		if (cell->sgsn_bvc[i] == bvc)
+			cell->sgsn_bvc[i] = NULL;
+	}
+
+}
+
 void gbproxy_cell_free(struct gbproxy_cell *cell)
 {
 	unsigned int i;

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

Gerrit-Project: osmo-gbproxy
Gerrit-Branch: master
Gerrit-Change-Id: Ib874cbebcea58fa4bf15e1ff40fe11601573e531
Gerrit-Change-Number: 24956
Gerrit-PatchSet: 1
Gerrit-Owner: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>
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/20210719/b3ac2d81/attachment.htm>


More information about the gerrit-log mailing list