gbproxy: Reset IMSI acquisition within gbproxy_unregister_link_info

Currently then link_info is not cleaned up completely, when
gbproxy_unregister_link_info is called.

This patch adds a function gbproxy_reset_link that must be defined
externally. This is done in gb_proxy.c, where it resets the IMSI
acquisition.

Sponsored-by: On-Waves ehf
diff --git a/openbsc/include/openbsc/gb_proxy.h b/openbsc/include/openbsc/gb_proxy.h
index 1d1812f..c1882f3 100644
--- a/openbsc/include/openbsc/gb_proxy.h
+++ b/openbsc/include/openbsc/gb_proxy.h
@@ -224,6 +224,7 @@
 uint32_t gbproxy_make_sgsn_tlli(
 	struct gbproxy_peer *peer, struct gbproxy_link_info *link_info,
 	uint32_t bss_tlli);
+void gbproxy_reset_link(struct gbproxy_link_info *link_info);
 int gbproxy_check_imsi(
 	struct gbproxy_peer *peer, const uint8_t *imsi, size_t imsi_len);
 
diff --git a/openbsc/src/gprs/gb_proxy.c b/openbsc/src/gprs/gb_proxy.c
index 9aeb010..867364d 100644
--- a/openbsc/src/gprs/gb_proxy.c
+++ b/openbsc/src/gprs/gb_proxy.c
@@ -76,6 +76,7 @@
 			  uint16_t ns_bvci);
 static int gbprox_relay2sgsn(struct gbproxy_config *cfg, struct msgb *old_msg,
 			     uint16_t ns_bvci, uint16_t sgsn_nsei);
+static void gbproxy_reset_imsi_acquisition(struct gbproxy_link_info* link_info);
 
 static int check_peer_nsei(struct gbproxy_peer *peer, uint16_t nsei)
 {
@@ -273,6 +274,11 @@
 	return sgsn_tlli;
 }
 
+void gbproxy_reset_link(struct gbproxy_link_info *link_info)
+{
+	gbproxy_reset_imsi_acquisition(link_info);
+}
+
 /* Returns != 0 iff IMSI acquisition was in progress */
 static int gbproxy_restart_imsi_acquisition(struct gbproxy_link_info* link_info)
 {
diff --git a/openbsc/src/gprs/gb_proxy_tlli.c b/openbsc/src/gprs/gb_proxy_tlli.c
index fdb1509..fae05ed 100644
--- a/openbsc/src/gprs/gb_proxy_tlli.c
+++ b/openbsc/src/gprs/gb_proxy_tlli.c
@@ -367,6 +367,8 @@
 
 	link_info->is_deregistered = 1;
 
+	gbproxy_reset_link(link_info);
+
 	return;
 }
 
diff --git a/openbsc/tests/gbproxy/gbproxy_test.ok b/openbsc/tests/gbproxy/gbproxy_test.ok
index 16e9d48..d0c9d61 100644
--- a/openbsc/tests/gbproxy/gbproxy_test.ok
+++ b/openbsc/tests/gbproxy/gbproxy_test.ok
@@ -5580,7 +5580,7 @@
     Attach Reject count             : 1
     TLLI cache size                 : 1
     TLLI-Cache: 1
-      TLLI 00000000, IMSI 12131415161718, AGE 0, STORED 1, IMSI acquisition in progress, DE-REGISTERED
+      TLLI 00000000, IMSI 12131415161718, AGE 0, DE-REGISTERED
 Gbproxy global:
 Test TLLI info expiry