msc: Add per subscriber keep_in_ram flag

Currently the keep_subscr flag in gsm_subscriber_group refers to a
whole group of subscribers which makes it difficult to really delete
single entries if the flag is set.

This patch adds a keep_in_ram field to gsm_subscriber which allows for
keeping subscriber objects in RAM while deleting others.

Note that really deleting an entry requires that both flags
(subscr_group->keep_subscr and subscr->keep_in_ram) are set to 0. So
only the latter should be used if a specification requires the
deletion of a subscriber entry.

Sponsored-by: On-Waves ehf
diff --git a/openbsc/tests/subscr/subscr_test.c b/openbsc/tests/subscr/subscr_test.c
index 277fc88..2a5d0e1 100644
--- a/openbsc/tests/subscr/subscr_test.c
+++ b/openbsc/tests/subscr/subscr_test.c
@@ -83,6 +83,22 @@
 	subscr_purge_inactive(&dummy_sgrp);
 
 	OSMO_ASSERT(llist_empty(&active_subscribers));
+
+	/* Test force_no_keep */
+
+	dummy_sgrp.keep_subscr = 0;
+
+	subscr = subscr_get_or_create(&dummy_sgrp, imsi);
+	OSMO_ASSERT(subscr);
+	subscr->keep_in_ram = 1;
+
+	OSMO_ASSERT(!llist_empty(&active_subscribers));
+	OSMO_ASSERT(subscr->use_count == 1);
+
+	subscr->keep_in_ram = 0;
+
+	subscr_put(subscr);
+	OSMO_ASSERT(llist_empty(&active_subscribers));
 }
 
 int main()