Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(agw): Modified code to port teid has list to protobuf in sgw_s8 task #14006

Merged
merged 10 commits into from
Nov 17, 2022

Conversation

rsarwad
Copy link
Contributor

@rsarwad rsarwad commented Sep 23, 2022

Summary

fix(agw): Modified code to port teid has list to protobuf in sgw_s8 task

Test Plan

Executed only unit test suite. For in-bound roaming, End2End scenarios used to be tested in Tera VM setup. Since we are not using the Tera VM setup. We couldn't validate End2End scenario.

Additional Information

Once federated integ_test supports mocked external PGW, we can validate the End2End scenarios for inbound roaming UE

…edure_id to protobuf map

Signed-off-by: Rashmi <rashmi.sarwad@radisys.com>
Signed-off-by: Rashmi <rashmi.sarwad@radisys.com>
@rsarwad rsarwad requested review from a team and ajahl September 23, 2022 13:55
@pull-request-size pull-request-size bot added the size/L Denotes a Pull Request that changes 100-499 lines. label Sep 23, 2022
@github-actions
Copy link
Contributor

Thanks for opening a PR! 💯

A couple initial guidelines

Howto

  • Reviews. The "Reviewers" listed for this PR are the Magma maintainers who will shepherd it.
  • Checks. All required CI checks must pass before merge.
  • Merge. Once approved and passing CI checks, use the ready2merge label to indicate the maintainers can merge your PR.

More info

Please take a moment to read through the Magma project's

If this is your first Magma PR, also consider reading

@github-actions github-actions bot added the component: agw Access gateway-related issue label Sep 23, 2022
}
free_wrapper((void**)sgw_eps_context);
free_wrapper((void**)ptr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Using C-style cast. Use reinterpret_cast<void**>(...) instead [readability/casting] [4]

}
}
state_cache_p->temporary_create_session_procedure_id_map.map = nullptr;
free_cpp_wrapper((void**)&state_cache_p);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Using C-style cast. Use reinterpret_cast<void**>(...) instead [readability/casting] [4]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the warning

@github-actions
Copy link
Contributor

github-actions bot commented Sep 23, 2022

feg-workflow

    2 files  203 suites   39s ⏱️
374 tests 374 ✔️ 0 💤 0
388 runs  388 ✔️ 0 💤 0

Results for commit 5215f3e.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 23, 2022

dp-workflow

14 tests   14 ✔️  2m 12s ⏱️
  1 suites    0 💤
  1 files      0

Results for commit 5215f3e.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 23, 2022

agw-workflow

615 tests   611 ✔️  4m 31s ⏱️
    2 suites      4 💤
    2 files        0

Results for commit 5215f3e.

♻️ This comment has been updated with latest results.

@ajahl
Copy link
Contributor

ajahl commented Sep 26, 2022

@rsarwad Can you fix the linter warnings and rebase your PR?

@@ -170,15 +170,15 @@ struct proto_map_s {
** the map. If key does not exists returns error **
** **
***************************************************************************/
proto_map_rc_t remove(const keyT key) {
proto_map_rc_t remove(const keyT key, bool free_an_entry = true) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the need of this flag? Shouldn`t the entry be freed always?

Copy link
Contributor Author

@rsarwad rsarwad Oct 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If flag is set, an entry for corresponding key would be removed and also contents are freed.
But in this PR, sgw_context would be initially in map, temporary_create_session_procedure_id_map. On reception of create session response, sgw_context would be removed from temporary_create_session_procedure_id_map and inserted into state_tied_map

sgw_eps_bearer_context_information_t* sgw_bearer_context_info = NULL;
hash_table_ts_t* state_imsi_ht = get_sgw_ue_state();
sgw_eps_bearer_context_information_t* sgw_bearer_context_info = nullptr;
map_uint32_sgw_eps_bearer_context_t* state_teid_ht = get_s8_state_teid_map();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NULL check for state_teid_ht

}
}
state_cache_p->temporary_create_session_procedure_id_map.map = nullptr;
free_cpp_wrapper((void**)&state_cache_p);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the warning

@@ -130,5 +148,14 @@ status_code_e SgwStateManager::read_ue_state_from_db() {
sgw_state_t* SgwStateManager::get_state(bool read_from_db) {
return state_cache_p;
}

map_uint32_sgw_eps_bearer_context_t* SgwStateManager::get_s8_state_teid_map() {
AssertFatal(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Error log instead of assertFatal

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's mandatory to have this flag, is_initialized to be initialized. So I think assertFatal should be fine

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, if the state is not cleanly initialized from Redis, the service should fail to start up.

Signed-off-by: Rashmi <rashmi.sarwad@radisys.com>
…d_hl

Signed-off-by: Rashmi <rashmi.sarwad@radisys.com>
"s11_bearer_context_information_htbl";
constexpr char SGW_STATE_TABLE_NAME[] = "sgw_state";
constexpr char SGW_TASK_NAME[] = "SGW";
constexpr char SGW_S8_CSR_PROC_ID_MAP[] = "sgw_s8_csr_proc_id_map";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
constexpr char SGW_S8_CSR_PROC_ID_MAP[] = "sgw_s8_csr_proc_id_map";
constexpr char SGW_S8_CSR_PROC_ID_MAP_NAME[] = "sgw_s8_csr_proc_id_map";

@@ -130,5 +148,14 @@ status_code_e SgwStateManager::read_ue_state_from_db() {
sgw_state_t* SgwStateManager::get_state(bool read_from_db) {
return state_cache_p;
}

map_uint32_sgw_eps_bearer_context_t* SgwStateManager::get_s8_state_teid_map() {
AssertFatal(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, if the state is not cleanly initialized from Redis, the service should fail to start up.

(const hash_key_t)session_rsp_p->temporary_create_session_procedure_id,
(void**)&sgw_context_p);
sgw_eps_bearer_context_information_t* sgw_context_p = nullptr;
sgw_state->temporary_create_session_procedure_id_map.get(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of getting this entry before removing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While handling create session request, sgw_context is created and inserted into map, temporary_create_session_procedure_id_map. Because for roaming users, sgw_s11_teid would be allocated by external PGW, shall be received in create session response message. So on reception of create session response, sgw_context is removed from map, but not freed.
So first we get the sgw_context, remove from map, temporary_create_session_procedure_id_map and insert into state_teid_map

@@ -1846,17 +1850,30 @@ sgw_eps_bearer_context_information_t* update_sgw_context_to_s11_teid_map(
OAILOG_FUNC_RETURN(LOG_SGW_S8, sgw_context_p);
}

if (sgw_state->temporary_create_session_procedure_id_map.remove(
session_rsp_p->temporary_create_session_procedure_id, false) !=
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the remove with false flag here? In the original logic the entry is being removed and freed from the hash table.

Copy link
Contributor Author

@rsarwad rsarwad Oct 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the original code, only entry is removed but not freed from hash table. This is taken care by API, hashtable_ts_remove() which only removes an entry from hash table but doesn't free. For API, hashtable_ts_free() free_wrapper is called as here https://github.com/magma/magma/blob/master/lte/gateway/c/core/oai/lib/hashtable/hashtable.c#L664
But same is not true for hashtable_ts_remove(), https://github.com/magma/magma/blob/master/lte/gateway/c/core/oai/lib/hashtable/hashtable.c#L691
The original code is here, https://github.com/magma/magma/pull/14006/files#diff-89dd268674e287dc1dc45f2515f69e41f864be6074f3e03529324cb1eeecb374L1837

To implement same behavior, I added new flag.

}
free_wrapper((void**)sgw_eps_context);
free_wrapper(reinterpret_cast<void**>(ptr));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
free_wrapper(reinterpret_cast<void**>(ptr));
free_cpp_wrapper(reinterpret_cast<void**>(ptr));

Copy link
Contributor Author

@rsarwad rsarwad Oct 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this PR, memory for sgw_eps_bearer_context_information_t is allocated with calloc. But in other PR, memory is allocated with new(). It's here, https://github.com/magma/magma/pull/13895/files#diff-89dd268674e287dc1dc45f2515f69e41f864be6074f3e03529324cb1eeecb374R189
It's shall be taken care while rebasing.

}
s8_state_teid_map.map = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason that you can not set map to nullptr in function destroy_map()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had missed it. Thanks for bringing into notice

"temporary_create_session_procedure_id_map ");
}
}
state_cache_p->temporary_create_session_procedure_id_map.map = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

Signed-off-by: Rashmi <rashmi.sarwad@radisys.com>
…d_hl

Signed-off-by: Rashmi <rashmi.sarwad@radisys.com>
Copy link
Contributor

@pruthvihebbani pruthvihebbani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pruthvihebbani
Copy link
Contributor

@rsarwad Please rebase the PR

…d_hl

Signed-off-by: Rashmi <rashmi.sarwad@radisys.com>
Signed-off-by: Rashmi <rashmi.sarwad@radisys.com>
@@ -124,7 +124,6 @@ void SgwStateManager::free_state() {
"temporary_create_session_procedure_id_map ");
}
}
s8_state_teid_map.map = nullptr;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is removed because map is set to nullptr within destroy_map() itself. This change is done while addressing the comment, #14006 (comment)

@@ -136,7 +135,6 @@ void SgwStateManager::free_state() {
"temporary_create_session_procedure_id_map ");
}
}
state_cache_p->temporary_create_session_procedure_id_map.map = nullptr;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is removed because map is set to nullptr within destroy_map() itself. This change is done while addressing the comment, #14006 (comment)

@pull-request-size pull-request-size bot added size/M Denotes a PR that changes 30-99 lines. and removed size/L Denotes a Pull Request that changes 100-499 lines. labels Nov 10, 2022
Signed-off-by: Rashmi <rashmi.sarwad@radisys.com>
Copy link
Collaborator

@ssanadhya ssanadhya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@ssanadhya
Copy link
Collaborator

@rsarwad , please rebase to retrigger CI.

…d_hl

Signed-off-by: Rashmi <rashmi.sarwad@radisys.com>
@pull-request-size pull-request-size bot added size/L Denotes a Pull Request that changes 100-499 lines. and removed size/M Denotes a PR that changes 30-99 lines. labels Nov 17, 2022
@github-actions
Copy link
Contributor

FeG Lint & Test

    2 files  203 suites   40s ⏱️
374 tests 374 ✔️ 0 💤 0
388 runs  388 ✔️ 0 💤 0

Results for commit 64f82c3.

@github-actions
Copy link
Contributor

DP Lint & Test

14 tests   14 ✔️  2m 14s ⏱️
  1 suites    0 💤
  1 files      0

Results for commit 64f82c3.

@rsarwad rsarwad merged commit 2674612 into magma:master Nov 17, 2022
lucasgonze pushed a commit to lucasgonze/magma that referenced this pull request Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: agw Access gateway-related issue size/L Denotes a Pull Request that changes 100-499 lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants