gprs: Fix TLLI cache size computation

Currently the enabled_tllis_count field isn't always decremented when
an element is removed from the TLLI cache list.

This patch adds the missing update and also adjusts the counter
accordingly.

Sponsored-by: On-Waves ehf
This commit is contained in:
Jacob Erlbeck 2014-06-27 12:20:44 +02:00 committed by Holger Hans Peter Freyther
parent aa3e334608
commit 040b4012a7
2 changed files with 10 additions and 9 deletions

View File

@ -464,6 +464,7 @@ static void gbprox_delete_tllis(struct gbprox_peer *peer)
llist_del(&tlli_info->list);
talloc_free(tlli_info);
}
state->enabled_tllis_count = 0;
OSMO_ASSERT(llist_empty(&state->enabled_tllis));
}
@ -646,7 +647,6 @@ static void gbprox_register_tlli(struct gbprox_peer *peer, uint32_t tlli,
memcpy(tlli_info->mi_data, imsi, imsi_len);
}
/* TODO: Hack??? */
peer->ctrg->ctr[GBPROX_PEER_CTR_TLLI_CACHE_SIZE].current =
state->enabled_tllis_count;
}
@ -654,6 +654,7 @@ static void gbprox_register_tlli(struct gbprox_peer *peer, uint32_t tlli,
static void gbprox_unregister_tlli(struct gbprox_peer *peer, uint32_t tlli)
{
struct gbprox_tlli_info *tlli_info;
struct gbprox_patch_state *state = &peer->patch_state;
tlli_info = gbprox_find_tlli(peer, tlli);
if (tlli_info) {
@ -662,7 +663,11 @@ static void gbprox_unregister_tlli(struct gbprox_peer *peer, uint32_t tlli)
tlli);
llist_del(&tlli_info->list);
talloc_free(tlli_info);
state->enabled_tllis_count -= 1;
}
peer->ctrg->ctr[GBPROX_PEER_CTR_TLLI_CACHE_SIZE].current =
state->enabled_tllis_count;
}
static int gbprox_check_tlli(struct gbprox_peer *peer, uint32_t tlli)

View File

@ -1737,8 +1737,7 @@ Peers:
RAID patched (SGSN): 2
APN patched : 2
Attach Request count : 1
TLLI cache size : 2
TLLI-Cache: 2
TLLI-Cache: 0
--- RA update ---
PROCESSING RA UPD REQ from 0x01020304:1111
@ -1783,8 +1782,7 @@ Peers:
RAID patched (SGSN): 3
APN patched : 2
Attach Request count : 1
TLLI cache size : 2
TLLI-Cache: 2
TLLI-Cache: 0
PROCESSING DETACH REQ from 0x01020304:1111
00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 75 30 00 80 0e 00 15 01 c0 19 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 7e e1 41
@ -1816,8 +1814,7 @@ Peers:
RAID patched (SGSN): 3
APN patched : 2
Attach Request count : 1
TLLI cache size : 3
TLLI-Cache: 3
TLLI-Cache: 0
--- Bad cases ---
TLLI is already detached, shouldn't patch
@ -1855,7 +1852,6 @@ Peers:
RAID patched (SGSN): 3
APN patched : 2
Attach Request count : 1
TLLI cache size : 3
TLLI-Cache: 3
TLLI-Cache: 0
===== GbProxy test END