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

[agw][mme] Replace ctime_r with strftime #4240

Merged
merged 2 commits into from Jan 5, 2021

Conversation

ssanadhya
Copy link
Collaborator

@ssanadhya ssanadhya commented Jan 4, 2021

Signed-off-by: Shruti Sanadhya ssanadhya@fb.com

Summary

Replace ctime_r with recommended strftime

Test Plan

make integ_test for functional testing

tail /var/log/mme.log to make sure the time is printed correctly

vagrant@magma-dev:~/magma/lte/gateway$ tail /var/log/mme.log
000275 Mon Jan 04 23:37:17 2021 7FBF36BEDC80 INFO  SPGW-A tasks/sgw/pgw_config.c          :0588        SGi MTU (read)........: 1500
000276 Mon Jan 04 23:37:17 2021 7FBF36BEDC80 INFO  SPGW-A tasks/sgw/pgw_config.c          :0591        NAT ..................: true
000277 Mon Jan 04 23:37:17 2021 7FBF36BEDC80 INFO  SPGW-A tasks/sgw/pgw_config.c          :0594        User TCP MSS clamping : true
000278 Mon Jan 04 23:37:17 2021 7FBF36BEDC80 INFO  SPGW-A tasks/sgw/pgw_config.c          :0597        User IP masquerading  : false
000279 Mon Jan 04 23:37:17 2021 7FBF36BEDC80 INFO  SPGW-A tasks/sgw/pgw_config.c          :0600    - PCEF support ...........: false (in development)
000280 Mon Jan 04 23:37:17 2021 7FBF36BEDC80 INFO  SPGW-A tasks/sgw/pgw_config.c          :0646    - DNS Configuration:
000281 Mon Jan 04 23:37:17 2021 7FBF36BEDC80 INFO  SPGW-A tasks/sgw/pgw_config.c          :0649        IPv4 Primary Address ..........: 8.8.8.8
000282 Mon Jan 04 23:37:17 2021 7FBF36BEDC80 INFO  SPGW-A tasks/sgw/pgw_config.c          :0652        IPv4 Secondary Address ..........: 8.8.4.4
000283 Mon Jan 04 23:37:17 2021 7FBF36BEDC80 INFO  SPGW-A tasks/sgw/pgw_config.c          :0653    - Helpers:
000284 Mon Jan 04 23:37:17 2021 7FBF36BEDC80 INFO  SPGW-A tasks/sgw/pgw_config.c          :0656        Push PCO (DNS+MTU) ........: false

Signed-off-by: Shruti Sanadhya <ssanadhya@fb.com>
@ssanadhya ssanadhya added component: agw Access gateway-related issue apply-v1.3 Needs to be applied to v1.3 release branch as well labels Jan 4, 2021
@magmabot magmabot added the component: cwag CWAG related issues label Jan 4, 2021
Copy link
Contributor

@ulaskozat ulaskozat left a comment

Choose a reason for hiding this comment

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

LGTM

time(cur_time);
struct tm* cur_local_time;
cur_local_time = localtime(cur_time);
char* time_str = calloc(32, sizeof(char));
Copy link
Contributor

Choose a reason for hiding this comment

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

This array can be allocated on stack of caller to avoid dynamic memory allocation. Caller can pass explicit array pointer. is there any downside of this ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes @pshelar, that is also a feasible approach. We will have to pass the array pointer as well as the array length to the function, increasing the number of arguments to the function. Alternatively, we can fix the size of the time_str using a macro and just use that everywhere. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Modified in 744d161

Signed-off-by: Shruti Sanadhya <ssanadhya@fb.com>
@ssanadhya ssanadhya merged commit 5d03e26 into magma:master Jan 5, 2021
@ssanadhya ssanadhya deleted the log_time_fix branch January 5, 2021 06:25
@ssanadhya ssanadhya added the backported-v1.3 Has been backported to v1.3 release branch label Jan 5, 2021
ssanadhya added a commit that referenced this pull request Jan 5, 2021
* Replace ctime_r with strftime

Signed-off-by: Shruti Sanadhya <ssanadhya@fb.com>
tmdzk pushed a commit that referenced this pull request Jan 5, 2021
* Replace ctime_r with strftime

Signed-off-by: Shruti Sanadhya <ssanadhya@fb.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apply-v1.3 Needs to be applied to v1.3 release branch as well backported-v1.3 Has been backported to v1.3 release branch component: agw Access gateway-related issue component: cwag CWAG related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants