Open ryndia opened 9 months ago
Hello,
For TI-LFA, it is needed to compute the P and Q space to determine alternate route in case of link or node failure. For this purpose, the P and Q space need their own copy of the SPF, thus the vertex. Unfortunately, when OSPF shutdown, the vertex allocated for TI-LFA are not free. I'll have a look to the code to determine if this allocated vertex are free when TI-LFA is stopped and thus which piece of code should be added when OSPF is shutdown. If there is no such code in TI-LFA, I'll look how to create such function.
Regards
Olivier
If you look at the ospf_ti_lfa_compute()
function, there are 3 actions:
ospf_spf_copy()
function and allocate new memory for vertexospf_ti_lfa_free_p_spaces()
functionThus, there is a cleanup function for TI-LFA. This function seems to be call after all new vertex allocation. But, perhaps some vertex are not free correctly. I look to the cleanup function and it is calling ospf_spf_cleanup()
which call the list_delete()
function which is safe. In addition, ospf_spf_cleanup()
function is used by the standard routing algo to compute and setup route. Thus, this function has been checked, verified and tested since a while.
So, I don't know why there is remaining non free P & Q spaces vertex. Here, I think we should add some debugging message to trace these allocation, or perhaps, through gdb trace the call to the ospf_ti_lfa_free_p_spaces()
functions to determine why it is not called.
If you look at the
ospf_ti_lfa_compute()
function, there are 3 actions:
- Generate the P spaces which at the end call the
ospf_spf_copy()
function and allocate new memory for vertex- Install backup route from the previously computed P spaces
- Cleanup the P spaces and related Q spaces with call to
ospf_ti_lfa_free_p_spaces()
functionThus, there is a cleanup function for TI-LFA. This function seems to be call after all new vertex allocation. But, perhaps some vertex are not free correctly. I look to the cleanup function and it is calling
ospf_spf_cleanup()
which call thelist_delete()
function which is safe. In addition,ospf_spf_cleanup()
function is used by the standard routing algo to compute and setup route. Thus, this function has been checked, verified and tested since a while.So, I don't know why there is remaining non free P & Q spaces vertex. Here, I think we should add some debugging message to trace these allocation, or perhaps, through gdb trace the call to the
ospf_ti_lfa_free_p_spaces()
functions to determine why it is not called.
I notice that the p_space variable didn't set the free function for its vertex list. I set it in the function ospf_ti_lfa_generate_p_space
but the code crash due to the function ospf_spf_cleanup
in the function ospf_spf_calculate_area
. While using gdb I notice that the vertex_parent is used lastly in the function ospf_spf_remove_branch
and when the child vertex is being freed, I think the parent should have been freed here. I used some kind of trick to see if the vertex_parent get free in the ospf_spf_remove_branch
and it turn out it reach the free function, however the trick doesn't solve the problem. Do you think I am on the right way or am I wrong on this logic? Thank you for the help
If you look at the
ospf_ti_lfa_compute()
function, there are 3 actions:
- Generate the P spaces which at the end call the
ospf_spf_copy()
function and allocate new memory for vertex- Install backup route from the previously computed P spaces
- Cleanup the P spaces and related Q spaces with call to
ospf_ti_lfa_free_p_spaces()
functionThus, there is a cleanup function for TI-LFA. This function seems to be call after all new vertex allocation. But, perhaps some vertex are not free correctly. I look to the cleanup function and it is calling
ospf_spf_cleanup()
which call thelist_delete()
function which is safe. In addition,ospf_spf_cleanup()
function is used by the standard routing algo to compute and setup route. Thus, this function has been checked, verified and tested since a while. So, I don't know why there is remaining non free P & Q spaces vertex. Here, I think we should add some debugging message to trace these allocation, or perhaps, through gdb trace the call to theospf_ti_lfa_free_p_spaces()
functions to determine why it is not called.I notice that the p_space variable didn't set the free function for its vertex list. I set it in the function
ospf_ti_lfa_generate_p_space
but the code crash due to the functionospf_spf_cleanup
in the functionospf_spf_calculate_area
. While using gdb I notice that the vertex_parent is used lastly in the functionospf_spf_remove_branch
and when the child vertex is being freed, I think the parent should have been freed here. I used some kind of trick to see if the vertex_parent get free in theospf_spf_remove_branch
and it turn out it reach the free function, however the trick doesn't solve the problem. Do you think I am on the right way or am I wrong on this logic? Thank you for the help
This is what I notice for the ospfd: ospf_spf_vertex_parent_copy leak #14784
In fact, the p-space reuse the same vertex structure and thus the same function sets used by the standard SPF. So, the free function is already set in various functions (ospf_vertex_new, ospf_spf_vertex_copy and ospf_spf_init).
I'm pretty sure that all the SPF functions are correct. However, mem leaks will be raised. So, the problem comes from how TI-LFA is using these functions. Thus, I think you should investigate within the ospf_ti_lfa.c file, and in particular the ospf_ti_lfa_p_spaces()
function by adding some log to determine how many vertex are allocated for P & Q spaces, and check that there are all correctly free at the end of the function
In fact, the p-space reuse the same vertex structure and thus the same function sets used by the standard SPF. So, the free function is already set in various functions (ospf_vertex_new, ospf_spf_vertex_copy and ospf_spf_init).
I'm pretty sure that all the SPF functions are correct. However, mem leaks will be raised. So, the problem comes from how TI-LFA is using these functions. Thus, I think you should investigate within the ospf_ti_lfa.c file, and in particular the
ospf_ti_lfa_p_spaces()
function by adding some log to determine how many vertex are allocated for P & Q spaces, and check that there are all correctly free at the end of the function
Hello, i dont think the ospf_spf_copy
set the delete function for the p_space->vertex_list, that why I introduce a line to point the delete function for the vertex in the vertex_list in the p_space:
https://github.com/FRRouting/frr/blob/7f1e552a53afe085002e5caf3131294c5b8d1dc0/ospfd/ospf_ti_lfa.c#L789
I set the p_space->vertex_list->del = ospf_vertex_free;
. However as I say the the code crash on test when it hit this line:
https://github.com/FRRouting/frr/blob/7f1e552a53afe085002e5caf3131294c5b8d1dc0/ospfd/ospf_spf.c#L1814
This issue is stale because it has been open 180 days with no activity. Comment or remove the autoclose
label in order to avoid having this issue closed.
After addressing and debugging the code for leaks, three leaks persist, with one located below. Despite employing tools like GDB, my team is encountering challenges in resolving this specific leak. We would appreciate a review and any advice you can provide.