Change in osmo-sgsn[master]: gb_proxy: tallocate memory for gbproxy cfg so it can be a talloc ctx

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

Harald Welte gerrit-no-reply at lists.osmocom.org
Fri Jun 1 10:02:50 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/9401 )

Change subject: gb_proxy: tallocate memory for gbproxy cfg so it can be a talloc ctx
......................................................................

gb_proxy: tallocate memory for gbproxy cfg so it can be a talloc ctx

Change-Id: Iad7cde5c08daacc3f5c4175d21d89fad25a5c3d7
---
M src/gprs/gb_proxy_main.c
1 file changed, 14 insertions(+), 8 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/src/gprs/gb_proxy_main.c b/src/gprs/gb_proxy_main.c
index 04143bb..474aa52 100644
--- a/src/gprs/gb_proxy_main.c
+++ b/src/gprs/gb_proxy_main.c
@@ -70,7 +70,7 @@
 #define CONFIG_FILE_LEGACY "osmo_gbproxy.cfg"
 
 static char *config_file = NULL;
-struct gbproxy_config gbcfg = {0};
+struct gbproxy_config *gbcfg;
 static int daemonize = 0;
 
 /* Pointer to the SGSN peer */
@@ -84,7 +84,7 @@
 
 	switch (event) {
 	case GPRS_NS_EVT_UNIT_DATA:
-		rc = gbprox_rcvmsg(&gbcfg, msg, nsvc->nsei, bvci, nsvc->nsvci);
+		rc = gbprox_rcvmsg(gbcfg, msg, nsvc->nsei, bvci, nsvc->nsvci);
 		break;
 	default:
 		LOGP(DGPRS, LOGL_ERROR, "SGSN: Unknown event %u from NS\n", event);
@@ -309,14 +309,20 @@
 		LOGP(DGPRS, LOGL_ERROR, "Unable to instantiate NS\n");
 		exit(1);
 	}
-	gbproxy_init_config(&gbcfg);
-	gbcfg.nsi = bssgp_nsi;
+
+	gbcfg = talloc_zero(tall_bsc_ctx, struct gbproxy_config);
+	if (!gbcfg) {
+		LOGP(DGPRS, LOGL_FATAL, "Unable to allocate config\n");
+		exit(1);
+	}
+	gbproxy_init_config(gbcfg);
+	gbcfg->nsi = bssgp_nsi;
 	gprs_ns_vty_init(bssgp_nsi);
 	gprs_ns_set_log_ss(DNS);
 	bssgp_set_log_ss(DBSSGP);
-	osmo_signal_register_handler(SS_L_NS, &gbprox_signal, &gbcfg);
+	osmo_signal_register_handler(SS_L_NS, &gbprox_signal, gbcfg);
 
-	rc = gbproxy_parse_config(config_file, &gbcfg);
+	rc = gbproxy_parse_config(config_file, gbcfg);
 	if (rc < 0) {
 		LOGP(DGPRS, LOGL_FATAL, "Cannot parse config file '%s'\n", config_file);
 		exit(2);
@@ -328,10 +334,10 @@
 	if (rc < 0)
 		exit(1);
 
-	if (!gprs_nsvc_by_nsei(gbcfg.nsi, gbcfg.nsip_sgsn_nsei)) {
+	if (!gprs_nsvc_by_nsei(gbcfg->nsi, gbcfg->nsip_sgsn_nsei)) {
 		LOGP(DGPRS, LOGL_FATAL, "You cannot proxy to NSEI %u "
 			"without creating that NSEI before\n",
-			gbcfg.nsip_sgsn_nsei);
+			gbcfg->nsip_sgsn_nsei);
 		exit(2);
 	}
 

-- 
To view, visit https://gerrit.osmocom.org/9401
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Iad7cde5c08daacc3f5c4175d21d89fad25a5c3d7
Gerrit-Change-Number: 9401
Gerrit-PatchSet: 1
Gerrit-Owner: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180601/d11c752d/attachment.htm>


More information about the gerrit-log mailing list