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
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 @@
 			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) {