bankd: createMapping should implicitly delete existing mappings

As explained in OS#4278, a remsim-bankd currently doesn't recover after
a remsim-server resetart, since old mappings remain in the bankd, and
the server has no chance of removing them.

To avoid this problem, a createMapping now always implicitly removes
any existing mapping that may exist for the given bankdSlot.

Change-Id: I83e319d22896b881c0d882542842f500075aa546
Closes: OS#4278
diff --git a/src/bankd/bankd_main.c b/src/bankd/bankd_main.c
index 7b50a73..03101fb 100644
--- a/src/bankd/bankd_main.c
+++ b/src/bankd/bankd_main.c
@@ -176,6 +176,18 @@
 		} else {
 			rspro2bank_slot(&bs, &creq->bank);
 			rspro2client_slot(&cs, &creq->client);
+			/* check if map exists */
+			map = slotmap_by_bank(g_bankd->slotmaps, &bs);
+			if (map) {
+				if (client_slot_equals(&map->client, &cs)) {
+					LOGPFSML(srvc->fi, LOGL_ERROR, "ignoring identical slotmap\n");
+					resp = rspro_gen_CreateMappingRes(ResultCode_ok);
+					goto send_resp;
+				} else {
+					LOGPFSM(srvc->fi, "implicitly removing slotmap\n");
+					bankd_srvc_remove_mapping(map);
+				}
+			}
 			/* Add a new mapping */
 			map = slotmap_add(g_bankd->slotmaps, &bs, &cs);
 			if (!map) {
@@ -184,6 +196,7 @@
 			} else
 				resp = rspro_gen_CreateMappingRes(ResultCode_ok);
 		}
+send_resp:
 		server_conn_send_rspro(srvc, resp);
 		break;
 	case RsproPDUchoice_PR_removeMappingReq: