From 0757504a865e67b7108440959ec59ce29805883d Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Wed, 14 Feb 2018 01:04:04 +0100 Subject: 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 --- ggsn/ggsn.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c index cb11c49..bbdb5c8 100644 --- a/ggsn/ggsn.c +++ b/ggsn/ggsn.c @@ -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) { -- cgit v1.2.3