[AMF/MME] Fixed M-TMSI pool release (#2307)

M-TMSI pool release was incorrectly modified and has now been corrected.
This commit is contained in:
Sukchan Lee 2024-01-21 11:55:46 +09:00
parent d7b896affb
commit b94173ab41
3 changed files with 18 additions and 2 deletions

View File

@ -157,6 +157,12 @@ typedef uint32_t ogs_pool_id_t;
(pool)->array[j] = temp; \
} \
} while (0)
#define ogs_pool_assert_if_has_duplicate(pool) do { \
int i, j; \
for (i = 0; i < (pool)->size; i++) \
for (j = i+1; j < (pool)->size; j++) \
ogs_assert(((pool)->array[i]) != ((pool)->array[j])); \
} while (0)
#ifdef __cplusplus
}

View File

@ -62,8 +62,12 @@ void amf_context_init(void)
ogs_pool_init(&amf_ue_pool, ogs_global_conf()->max.ue);
ogs_pool_init(&ran_ue_pool, ogs_global_conf()->max.ue);
ogs_pool_init(&amf_sess_pool, ogs_app()->pool.sess);
/* Increase size of TMSI pool (#1827) */
ogs_pool_init(&m_tmsi_pool, ogs_global_conf()->max.ue*2);
ogs_pool_random_id_generate(&m_tmsi_pool);
#if 0 /* For debugging : Verify whether there are duplicates of M_TMSI. */
ogs_pool_assert_if_has_duplicate(&m_tmsi_pool);
#endif
ogs_list_init(&self.gnb_list);
ogs_list_init(&self.amf_ue_list);
@ -2487,7 +2491,8 @@ int amf_m_tmsi_free(amf_m_tmsi_t *m_tmsi)
ogs_assert(m_tmsi);
/* Restore M-TMSI by Issue #2307 */
*m_tmsi &= 0x003fffff;
*m_tmsi &= 0x3fffffff;
*m_tmsi = ((*m_tmsi & 0xffff) | ((*m_tmsi & 0x3f000000) >> 8));
ogs_pool_free(&m_tmsi_pool, m_tmsi);
return OGS_OK;

View File

@ -118,8 +118,12 @@ void mme_context_init(void)
ogs_pool_init(&sgw_ue_pool, ogs_global_conf()->max.ue);
ogs_pool_init(&mme_sess_pool, ogs_app()->pool.sess);
ogs_pool_init(&mme_bearer_pool, ogs_app()->pool.bearer);
/* Increase size of TMSI pool (#1827) */
ogs_pool_init(&m_tmsi_pool, ogs_global_conf()->max.ue*2);
ogs_pool_random_id_generate(&m_tmsi_pool);
#if 0 /* For debugging : Verify whether there are duplicates of M_TMSI. */
ogs_pool_assert_if_has_duplicate(&m_tmsi_pool);
#endif
self.enb_addr_hash = ogs_hash_make();
ogs_assert(self.enb_addr_hash);
@ -4652,7 +4656,8 @@ int mme_m_tmsi_free(mme_m_tmsi_t *m_tmsi)
ogs_assert(m_tmsi);
/* Restore M-TMSI by Issue #2307 */
*m_tmsi &= 0x003fffff;
*m_tmsi &= 0x3fffffff;
*m_tmsi = ((*m_tmsi & 0xffff) | ((*m_tmsi & 0x3f000000) >> 8));
ogs_pool_free(&m_tmsi_pool, m_tmsi);
return OGS_OK;