gtphub: check TEI presence in Create PDP Ctx Response

Sponsored-by: On-Waves ehi
diff --git a/openbsc/src/gprs/gtphub.c b/openbsc/src/gprs/gtphub.c
index 96068bf..cb42a12 100644
--- a/openbsc/src/gprs/gtphub.c
+++ b/openbsc/src/gprs/gtphub.c
@@ -1524,6 +1524,16 @@
 		gtphub_tunnel_endpoint_set_peer(&tun->endpoint[side_idx][plane_idx],
 						peer_from_ie);
 
+		if (!tei_from_ie &&
+		    !tun->endpoint[side_idx][plane_idx].tei_orig) {
+			LOG(LOGL_ERROR,
+			    "Create PDP Context message omits %s TEI, but the"
+			    " no TEI has been announced for this tunnel: %s",
+			    gtphub_plane_idx_names[plane_idx],
+			    gtphub_tunnel_str(tun));
+			return -1;
+		}
+
 		if (tei_from_ie) {
 			/* Create TEI mapping and replace in GTP packet IE */
 			uint32_t mapped_tei = nr_pool_next(&hub->tei_pool);