fix segfault in case of kernel gtp-u

There's a problem during the initial start-up of osmo-ggsn in case
of kernel gtp-u: apn->ggsn->gsn is not yet set while parsing the
'apn' nodes from the config file.  This member is only set after
the last 'apn' node has been parsed at the end of the 'ggsn' node.

Closes: OS#3217
Change-Id: I022a5e5ebc1f155e8f94938856d310462f79bbe8
This commit is contained in:
Harald Welte 2018-02-14 01:04:04 +01:00
parent 042a445cf3
commit 0757504a86
1 changed files with 8 additions and 0 deletions

View File

@ -284,6 +284,14 @@ int apn_start(struct apn_ctx *apn)
apn_stop(apn, false);
return -1;
}
if (apn->ggsn->gsn == NULL) {
/* skip bringing up the APN now if the GSN is not initialized yet.
* This happens during initial load of the config file, as the
* "no shutdown" in the ggsn node only happens after the "apn" nodes
* are brought up */
LOGPAPN(LOGL_NOTICE, apn, "Skipping APN start\n");
return 0;
}
/* use GTP kernel module for data packet encapsulation */
if (gtp_kernel_init(apn->ggsn->gsn, apn->tun.cfg.dev_name,
&apn->v4.cfg.ifconfig_prefix, apn->tun.cfg.ipup_script) < 0) {