From 4d2668823916e2998016f72f06452fcd51068c71 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Sat, 29 Aug 2020 23:29:11 +0000 Subject: handover: fix detection for ambiguous HO neighbor ident Adding rate counter checks to TC_ho_neighbor_config_1 (1.c) uncovers that the test passes for the wrong reason. The ambiguous cell identification should be the cause for the handover error, but the log shows that instead a handover is attempted to BTS 3 which is not connected. find_handover_target_cell() first tries to find a precise match of values, and in a second pass applies wildcards like BSIC_ANY and NEIGHBOR_IDENT_KEY_ANY_BTS. That second pass lacks detection of ambiguous matches. Use the same code for both passes, by encapsulating in a loop of two, which first runs with exact_match == true and then false. Proper detection of the ambiguous target cell identification in TC_ho_neighbor_config_1() is shown by the resulting 'handover:error' count, see I10bc0b67ca8dcf41dbb02332ed18017e819c2b32 (osmo-ttcn3-hacks). Related: OS#4736 Related: I10bc0b67ca8dcf41dbb02332ed18017e819c2b32 (osmo-ttcn3-hacks) Change-Id: Ib0087b6566ae4d82f8c3ef272c1256bcd1d08bf1 --- src/osmo-bsc/handover_logic.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/osmo-bsc/handover_logic.c b/src/osmo-bsc/handover_logic.c index 071228e88..ade330d46 100644 --- a/src/osmo-bsc/handover_logic.c +++ b/src/osmo-bsc/handover_logic.c @@ -183,32 +183,34 @@ int find_handover_target_cell(struct gsm_bts **local_target_cell_p, /* No explicit neighbor entries exist for this BTS. Hence apply the legacy default behavior that all * local cells are neighbors. */ struct gsm_bts *bts; - struct gsm_bts *wildcard_match = NULL; + int i; LOG_HO(conn, LOGL_DEBUG, "No explicit neighbors, regarding all local cells as neighbors\n"); - llist_for_each_entry(bts, &net->bts_list, list) { - struct neighbor_ident_key bts_key = *bts_ident_key(bts); - if (neighbor_ident_key_match(&bts_key, search_for, true)) { - if (local_target_cell) { - if (log_errors) - LOG_HO(conn, LOGL_ERROR, - "NEIGHBOR CONFIGURATION ERROR: Multiple local cells match %s" - " (BTS %d and BTS %d)." - " Aborting Handover because of ambiguous network topology.\n", - neighbor_ident_key_name(search_for), - local_target_cell->nr, bts->nr); - return -EINVAL; + /* For i == 0, look for an exact 1:1 match of all ident_key fields. + * For i == 1, interpret wildcard values, when no exact match exists. */ + for (i = 0; i < 2; i++) { + bool exact_match = !i; + llist_for_each_entry(bts, &net->bts_list, list) { + struct neighbor_ident_key bts_key = *bts_ident_key(bts); + if (neighbor_ident_key_match(&bts_key, search_for, exact_match)) { + if (local_target_cell) { + if (log_errors) + LOG_HO(conn, LOGL_ERROR, + "NEIGHBOR CONFIGURATION ERROR: Multiple local cells match %s" + " (BTS %d and BTS %d)." + " Aborting Handover because of ambiguous network topology.\n", + neighbor_ident_key_name(search_for), + local_target_cell->nr, bts->nr); + return -EINVAL; + } + local_target_cell = bts; } - local_target_cell = bts; } - if (neighbor_ident_key_match(&bts_key, search_for, false)) - wildcard_match = bts; + if (local_target_cell) + break; } - if (!local_target_cell) - local_target_cell = wildcard_match; - if (!local_target_cell) { if (log_errors) LOG_HO(conn, LOGL_ERROR, "Cannot Handover, no cell matches %s\n", -- cgit v1.2.3