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): Modifed code to port hash list of ue contexts to protobuf map #13895

Closed
wants to merge 18 commits into from

Conversation

rsarwad
Copy link
Contributor

@rsarwad rsarwad commented Sep 12, 2022

Summary

fix(agw): Modifed code to port hash list of ue contexts to protobuf map

Test Plan

Executed s1ap sanity test suite and unit test cases.
Because of DCO check failure, the changes have been duplicated PR, #14342

Signed-off-by: Rashmi <rashmi.sarwad@radisys.com>
Signed-off-by: Rashmi <rashmi.sarwad@radisys.com>
Signed-off-by: Rashmi <rashmi.sarwad@radisys.com>
Signed-off-by: Rashmi <rashmi.sarwad@radisys.com>
Signed-off-by: Rashmi <rashmi.sarwad@radisys.com>
Signed-off-by: Rashmi <rashmi.sarwad@radisys.com>
Signed-off-by: Rashmi <rashmi.sarwad@radisys.com>
@rsarwad rsarwad requested review from a team and panyogesh September 12, 2022 14:33
@pull-request-size pull-request-size bot added the size/XL Denotes a Pull Request that changes 500-999 lines. label Sep 12, 2022
@github-actions github-actions bot added the component: agw Access gateway-related issue label Sep 12, 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

@@ -54,7 +48,7 @@ void delete_pending_procedures(
base_proc1 = base_proc2;
}
LIST_INIT(ctx_p->pending_procedures);
free_wrapper((void**)&ctx_p->pending_procedures);
free_cpp_wrapper((void**)&ctx_p->pending_procedures);
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]

if (ue_context_p) {
sgw_s11_teid_t* p1 = LIST_FIRST(&(ue_context_p->sgw_s11_teid_list));
while (p1) {
if (p1->sgw_s11_teid == teid) {
LIST_REMOVE(p1, entries);
free_wrapper((void**)&p1);
free_cpp_wrapper((void**)&p1);
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]

delete_pending_procedures(
&(context_p->sgw_eps_bearer_context_information));

free_cpp_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]

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please fix lint warnings

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

sgw_s11_teid_t* p2 = nullptr;
while (p1) {
p2 = LIST_NEXT(p1, entries);
LIST_REMOVE(p1, entries);
free_wrapper((void**)&p1);
free_cpp_wrapper((void**)&p1);
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

@@ -97,7 +97,7 @@ void sgw_remove_sgw_bearer_context_information(sgw_state_t* sgw_state,
while (p1) {
if (p1->sgw_s11_teid == teid) {
LIST_REMOVE(p1, entries);
free_wrapper((void**)&p1);
free_cpp_wrapper((void**)&p1);
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
Collaborator

Choose a reason for hiding this comment

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

Please fix lint warning

Copy link
Contributor

Choose a reason for hiding this comment

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

Fix cpplint warning

@@ -1475,7 +1474,7 @@
if (pgw_ni_cbr_proc && (LIST_EMPTY(pgw_ni_cbr_proc->pending_eps_bearers))) {
pgw_base_proc_t* base_proc1 = LIST_FIRST(sgw_context_p->pending_procedures);
LIST_REMOVE(base_proc1, entries);
free_wrapper((void**)&sgw_context_p->pending_procedures);
free_cpp_wrapper((void**)&sgw_context_p->pending_procedures);
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

@@ -119,6 +118,7 @@ TEST(SPGWStateConverterTest, TestUEContextConversion) {
EXPECT_TRUE(!memcmp(&want_sgw.last_known_cell_Id,
&got_sgw.last_known_cell_Id,
sizeof(want_sgw.last_known_cell_Id)));
sgw_free_ue_context((void**)&final_ctx);
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
Collaborator

Choose a reason for hiding this comment

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

Please fix lint warning

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 12, 2022

feg-workflow

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

Results for commit 0f7be0e.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 12, 2022

agw-workflow

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

Results for commit 0f7be0e.

♻️ This comment has been updated with latest results.

…text_ht

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

github-actions bot commented Sep 13, 2022

Oops! Looks like you failed the DCO check. Be sure to sign all your commits.

Howto

♻️ Updated: ❌ The check is still failing the DCO check after the last commit.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 13, 2022

dp-workflow

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

Results for commit 0f7be0e.

♻️ This comment has been updated with latest results.

@ajahl
Copy link
Contributor

ajahl commented Sep 26, 2022

@rsarwad Can you fix the conflicts and the linter warnings?

spgw_free_s11_bearer_context_information(&new_bearer_context_information);
return NULL;
}

/*
* Trying to insert the new tunnel into the tree.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please update the comment

Suggested change
* Trying to insert the new tunnel into the tree.
* Trying to insert the new tunnel into the map.

"Failed to free teid from state_teid_ht \n");
return temp;
"Failed to free teid from state_teid_map \n");
return magma::PROTO_MAP_KEY_ALREADY_EXISTS;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be an explicit error, not that key already exists. Can we add an error code for PROTO_MAP_REMOVE_KEY_FAILED

Copy link
Contributor Author

Choose a reason for hiding this comment

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

state_teid_map_t* state_teid_map = get_spgw_teid_state();
if (!state_teid_map) {
OAILOG_ERROR(LOG_SPGW_APP, "Failed to get state_teid_map");
return spgw_bearer_context_info;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Better to just return a nullptr (which is the value of spgw_bearer_context_info at this point) since this is an error scenario.

Suggested change
return spgw_bearer_context_info;
return nullptr;

map_uint64_spgw_ue_context_t* state_ue_map = get_spgw_ue_state();
if (!state_ue_map) {
OAILOG_ERROR(LOG_SPGW_APP, "Failed to find spgw_ue_state");
OAILOG_FUNC_RETURN(LOG_SPGW_APP, ue_context_p);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment as above

Suggested change
OAILOG_FUNC_RETURN(LOG_SPGW_APP, ue_context_p);
OAILOG_FUNC_RETURN(LOG_SPGW_APP, nullptr);

OAILOG_ERROR(LOG_SPGW_APP, "Failed to find spgw_ue_state");
OAILOG_FUNC_RETURN(LOG_SPGW_APP, ue_context_p);
}
state_ue_map->get(imsi64, &ue_context_p);
OAILOG_FUNC_RETURN(LOG_SPGW_APP, ue_context_p);
}

spgw_ue_context_t* spgw_create_or_get_ue_context(imsi64_t imsi64) {
OAILOG_FUNC_IN(LOG_SPGW_APP);
spgw_ue_context_t* ue_context_p = NULL;
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
spgw_ue_context_t* ue_context_p = NULL;
spgw_ue_context_t* ue_context_p = nullptr;

map_uint64_spgw_ue_context_t* state_ue_map = get_spgw_ue_state();
if (!state_ue_map) {
OAILOG_ERROR(LOG_SPGW_APP, "Failed to find spgw_ue_state");
OAILOG_FUNC_RETURN(LOG_SPGW_APP, ue_context_p);
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
OAILOG_FUNC_RETURN(LOG_SPGW_APP, ue_context_p);
OAILOG_FUNC_RETURN(LOG_SPGW_APP, nullptr);

@@ -1984,7 +1989,8 @@ void handle_failed_create_bearer_response(
pgw_base_proc_t* base_proc1 =
LIST_FIRST(sgw_context_p->pending_procedures);
LIST_REMOVE(base_proc1, entries);
free_wrapper((void**)&sgw_context_p->pending_procedures);
delete sgw_context_p->pending_procedures;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use free_cpp_wrapper

delete_pending_procedures(
&(context_p->sgw_eps_bearer_context_information));

free_cpp_wrapper((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.

Please fix lint warnings

@@ -215,8 +215,10 @@ void SpgwStateConverter::sgw_pdn_connection_to_proto(

void SpgwStateConverter::proto_to_sgw_pdn_connection(
const oai::SgwPdnConnection& proto, sgw_pdn_connection_t* state_pdn) {
state_pdn->apn_in_use =
strndup(proto.apn_in_use().c_str(), proto.apn_in_use().length());
if ((proto.apn_in_use().length())) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use proto.has_apn_in_use() here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

apn_in_use is of string type. For string data type, protobuf doesn't generate api, has_<field_name>;
It's in https://developers.google.com/protocol-buffers/docs/reference/cpp-generated#proto3_string
If field is not set then it returns empty string, but again in code we need to check empty string using memcmp; So I thought to use length of string.

@@ -97,7 +97,7 @@ void sgw_remove_sgw_bearer_context_information(sgw_state_t* sgw_state,
while (p1) {
if (p1->sgw_s11_teid == teid) {
LIST_REMOVE(p1, entries);
free_wrapper((void**)&p1);
free_cpp_wrapper((void**)&p1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please fix lint warning

@@ -119,6 +118,7 @@ TEST(SPGWStateConverterTest, TestUEContextConversion) {
EXPECT_TRUE(!memcmp(&want_sgw.last_known_cell_Id,
&got_sgw.last_known_cell_Id,
sizeof(want_sgw.last_known_cell_Id)));
sgw_free_ue_context((void**)&final_ctx);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please fix lint warning

@@ -44,9 +44,9 @@ void put_spgw_state(void);
* Returns pointer to SPGW UE state
* @return hashtable_ts_t struct with SPGW UE context structs as data
Copy link
Contributor

Choose a reason for hiding this comment

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

Update the return type in comment

@@ -1,70 +0,0 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this not used anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sgw.hpp is nowhere used

"An error occurred while destroying SGW s11_bearer_context_information "
"hashtable");
if (state_ue_map.map && state_ue_map.destroy_map() != PROTO_MAP_OK) {
OAI_FPRINTF_ERR("An error occurred while destroying SPGW's state ue map ");
Copy link
Contributor

Choose a reason for hiding this comment

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

What doe FPRINTF do? Can we replace this with OAILOG_ERROR

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 think we need to keep "OAI_FPRINTF_ERR" because free_state() would be called when tasks exits. So can't rely on logging task as it might have already exited.
Let me change at other places in this function.

@@ -97,7 +97,7 @@ void sgw_remove_sgw_bearer_context_information(sgw_state_t* sgw_state,
while (p1) {
if (p1->sgw_s11_teid == teid) {
LIST_REMOVE(p1, entries);
free_wrapper((void**)&p1);
free_cpp_wrapper((void**)&p1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix cpplint warning

@@ -1475,7 +1474,7 @@
if (pgw_ni_cbr_proc && (LIST_EMPTY(pgw_ni_cbr_proc->pending_eps_bearers))) {
pgw_base_proc_t* base_proc1 = LIST_FIRST(sgw_context_p->pending_procedures);
LIST_REMOVE(base_proc1, entries);
free_wrapper((void**)&sgw_context_p->pending_procedures);
free_cpp_wrapper((void**)&sgw_context_p->pending_procedures);
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

@@ -119,6 +118,7 @@ TEST(SPGWStateConverterTest, TestUEContextConversion) {
EXPECT_TRUE(!memcmp(&want_sgw.last_known_cell_Id,
&got_sgw.last_known_cell_Id,
sizeof(want_sgw.last_known_cell_Id)));
sgw_free_ue_context((void**)&final_ctx);
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

sgw_s11_teid_t* p2 = nullptr;
while (p1) {
p2 = LIST_NEXT(p1, entries);
LIST_REMOVE(p1, entries);
free_wrapper((void**)&p1);
free_cpp_wrapper((void**)&p1);
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

delete_pending_procedures(
&(context_p->sgw_eps_bearer_context_information));

free_cpp_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.

Fix the warning

Signed-off-by: Rashmi <rashmi.sarwad@radisys.com>
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/XL Denotes a Pull Request that changes 500-999 lines. labels Oct 12, 2022
@rsarwad rsarwad requested review from a team and mpfirrmann October 13, 2022 04:59
magma#14139)

otherwise hanging containers take up to 20s to restart and tests run
into timeouts.

Signed-off-by: Marco Pfirrmann <marco.pfirrmann@tngtech.com>
Co-authored-by: Marco Pfirrmann <christian.kraemer@tngtech.com>

Addressed review comment

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

feat(agw): time before killing containers during restart is reduced as (magma#14139)

otherwise hanging containers take up to 20s to restart and tests run
into timeouts.

Signed-off-by: Marco Pfirrmann <marco.pfirrmann@tngtech.com>
Co-authored-by: Marco Pfirrmann <christian.kraemer@tngtech.com>

Addressed review comment

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

feat(agw): time before killing containers during restart is reduced as (magma#14139)

otherwise hanging containers take up to 20s to restart and tests run
into timeouts.

Signed-off-by: Marco Pfirrmann <marco.pfirrmann@tngtech.com>
Co-authored-by: Marco Pfirrmann <christian.kraemer@tngtech.com>

fix(ci): there was a bit too much deleted in magma#14050 (magma#14143)

Signed-off-by: Fritz Lehnert <13189449+Neudrino@users.noreply.github.com>
@rsarwad rsarwad requested a review from a team as a code owner October 13, 2022 05:12
@rsarwad rsarwad requested a review from koolzz October 13, 2022 05:12
…text_ht

Signed-off-by: Rashmi <rashmi.sarwad@radisys.com>
@@ -112,8 +114,7 @@ status_code_e SpgwStateManager::read_ue_state_from_db() {
return RETURNerror;
}
OAILOG_DEBUG(log_task, "Reading UE state from db for key %s", key.c_str());
spgw_ue_context_t* ue_context_p =
(spgw_ue_context_t*)calloc(1, sizeof(spgw_ue_context_t));
spgw_ue_context_t* ue_context_p = new spgw_ue_context_t();
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 ue_context_p

Copy link
Contributor

@ajahl ajahl Oct 14, 2022

Choose a reason for hiding this comment

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

In C++ the new operator already throws an exception (bad_alloc) if it is not able to allocate memory I guess. Why we should need the Null check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ajahl should we catch the exception?

Copy link
Contributor

@ajahl ajahl Oct 24, 2022

Choose a reason for hiding this comment

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

Only if we can handle the error, maybe to log the error. However, the application should be stopped.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then it's good to catch the exception to understand where the application is going wrong. @ssanadhya May I know your thoughts on this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@rsarwad , since this would be a system error, it is best to let the process terminate as a result of bad_alloc exception. No need to catch that exception.

@@ -55,8 +55,7 @@ status_code_e mock_read_spgw_ue_state_db(
return RETURNerror;
}

spgw_ue_context_t* ue_context_p =
(spgw_ue_context_t*)calloc(1, sizeof(spgw_ue_context_t));
spgw_ue_context_t* ue_context_p = new spgw_ue_context_t();
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 missing

@@ -76,8 +76,7 @@ TEST(SPGWStateConverterTest, TestUEContextConversion) {
auto want_teid = LIST_FIRST(&initial_ctx->sgw_s11_teid_list)->sgw_s11_teid;

oai::SpgwUeContext proto_ctx;
spgw_ue_context_t* final_ctx =
(spgw_ue_context_t*)calloc(1, sizeof(spgw_ue_context_t));
spgw_ue_context_t* final_ctx = new spgw_ue_context_t();
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 missing

LIST_INIT(s11_proc_create_bearer->pending_eps_bearers);
for (auto& eps_bearer_proto : proto.pending_eps_bearers()) {
sgw_eps_bearer_ctxt_t* eps_bearer =
(sgw_eps_bearer_ctxt_t*)calloc(1, sizeof(sgw_eps_bearer_ctxt_t));
sgw_eps_bearer_ctxt_t* eps_bearer = new sgw_eps_bearer_ctxt_t();
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 missing

@@ -937,26 +936,23 @@ void SpgwStateConverter::insert_proc_into_sgw_pending_procedures(
const oai::PgwCbrProcedure& proto,
sgw_eps_bearer_context_information_t::pending_procedures_s*
pending_procedures) {
pgw_ni_cbr_proc_t* s11_proc_create_bearer =
(pgw_ni_cbr_proc_t*)calloc(1, sizeof(pgw_ni_cbr_proc_t));
pgw_ni_cbr_proc_t* s11_proc_create_bearer = new pgw_ni_cbr_proc_t();
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 missing

@@ -233,8 +233,7 @@ void SpgwStateConverter::proto_to_sgw_pdn_connection(

for (int i = 0; i < BEARERS_PER_UE; i++) {
if (proto.eps_bearer_list(i).eps_bearer_id()) {
auto* eps_bearer_entry =
(sgw_eps_bearer_ctxt_t*)calloc(1, sizeof(sgw_eps_bearer_ctxt_t));
auto* eps_bearer_entry = new sgw_eps_bearer_ctxt_t();
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 missing

@@ -72,8 +70,7 @@ pgw_ni_cbr_proc_t* pgw_create_procedure_create_bearer(
LIST_INSERT_HEAD((ctx_p->pending_procedures), base_proc, entries);

s11_proc_create_bearer->pending_eps_bearers =
(pgw_ni_cbr_proc_s::pending_eps_bearers_s*)calloc(
1, sizeof(s11_proc_create_bearer->pending_eps_bearers));
new pgw_ni_cbr_proc_s::pending_eps_bearers_s();
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 missing

pgw_ni_cbr_proc_t* s11_proc_create_bearer =
reinterpret_cast<pgw_ni_cbr_proc_t*>(
calloc(1, sizeof(pgw_ni_cbr_proc_t)));
pgw_ni_cbr_proc_t* s11_proc_create_bearer = new pgw_ni_cbr_proc_t();
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 missing

Signed-off-by: Rashmi <rashmi.sarwad@radisys.com>
sgw_eps_bearer_entry_wrapper->sgw_eps_bearer_entry = eps_bearer;
LIST_INSERT_HEAD((s11_proc_create_bearer->pending_eps_bearers),
sgw_eps_bearer_entry_wrapper, entries);
}
if (failed_to_allocate) {
pgw_free_procedure_create_bearer(
(pgw_ni_cbr_proc_t**)&s11_proc_create_bearer);
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<pgw_ni_cbr_proc_t**>(...) instead [readability/casting] [4]

hashtable_ts_create(SGW_STATE_CONTEXT_HT_MAX_SIZE, nullptr,
(void (*)(void**))sgw_free_ue_context, nullptr);
state_ue_map.map = new google::protobuf::Map<uint64_t, spgw_ue_context_s*>();
if (!(state_ue_map.map)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If you use new to instantiate an object in C++ the Null check is always needless because of the bad_alloc exception.

sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p =
reinterpret_cast<sgw_eps_bearer_ctxt_t*>(
calloc(1, sizeof(sgw_eps_bearer_ctxt_t)));
sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p = new sgw_eps_bearer_ctxt_t();

if (!eps_bearer_ctxt_p) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The Null check is always needless because of C++ throws a bad_alloc exception.

@@ -660,8 +657,7 @@ status_code_e create_temporary_dedicated_bearer_context(
}
}
struct sgw_eps_bearer_entry_wrapper_s* sgw_eps_bearer_entry_p =
reinterpret_cast<sgw_eps_bearer_entry_wrapper_s*>(
calloc(1, sizeof(*sgw_eps_bearer_entry_p)));
new sgw_eps_bearer_entry_wrapper_s();
if (!sgw_eps_bearer_entry_p) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The Null check is always needless because of C++ throws a bad_alloc exception.

reinterpret_cast<pgw_ni_cbr_proc_t*>(
calloc(1, sizeof(pgw_ni_cbr_proc_t)));
pgw_ni_cbr_proc_t* s11_proc_create_bearer = new pgw_ni_cbr_proc_t();
if (!s11_proc_create_bearer) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The Null check is always needless because of C++ throws a bad_alloc exception.

s11_proc_create_bearer->proc.type =
PGW_BASE_PROC_TYPE_NETWORK_INITATED_CREATE_BEARER_REQUEST;
pgw_base_proc_t* base_proc = (pgw_base_proc_t*)s11_proc_create_bearer;

if (!ctx_p->pending_procedures) {
ctx_p->pending_procedures =
new sgw_eps_bearer_context_information_s::pending_procedures_s();
if (!ctx_p->pending_procedures) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The Null check is always needless because of C++ throws a bad_alloc exception.

* Malloc failed, may be ENOMEM error
*/
new_tunnel = new mme_sgw_tunnel_t();
if (new_tunnel == nullptr) {
Copy link
Contributor

@ajahl ajahl Oct 24, 2022

Choose a reason for hiding this comment

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

The Null check after call the new operator is always needless because of C++ throws a bad_alloc exception.

…text_ht

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

github-actions bot commented Oct 28, 2022

Oops! Looks like you failed the PR Check DCO. Be sure to sign all your commits.

Howto

♻️ Updated: ❌ The check is still failing the PR Check DCO after the last commit.

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

…text_ht

Signed-off-by: Rashmi <rashmi.sarwad@radisys.com>
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