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

pathd: pcep module: prevent any possible disconnection race leading to NULL sessions #34

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pathd/path_pcep.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ int pcep_main_event_handler(enum pcep_main_event_type type, int pcc_id,
* will be comunicated through hook calls.
*/
enum pcep_lsp_operational_status real_status;
if(resp = path_nb_get_path(&path->nbkey)){
resp = path_nb_get_path(&path->nbkey);
if (!resp)
return ret;
resp->srp_id = path->srp_id;
real_status = resp->status;
resp->status = PCEP_LSP_OPERATIONAL_DOWN;
Expand All @@ -176,7 +178,6 @@ int pcep_main_event_handler(enum pcep_main_event_type type, int pcc_id,
pcep_ctrl_send_report(pcep_g->fpt, path->pcc_id, resp);
}
pcep_free_path(resp);
}
}
break;
default:
Expand Down
15 changes: 10 additions & 5 deletions pathd/path_pcep_pcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,10 @@ int pcep_pcc_disable(struct ctrl_state *ctrl_state, struct pcc_state *pcc_state)
void pcep_pcc_sync_path(struct ctrl_state *ctrl_state,
struct pcc_state *pcc_state, struct path *path)
{
if (pcc_state->status == PCEP_PCC_DISCONNECTED)
if (pcc_state->status != PCEP_PCC_SYNCHRONIZING)
return;

assert(pcc_state->status == PCEP_PCC_SYNCHRONIZING);
assert(path->is_synching);
path->is_synching = true;

if (pcc_state->caps.is_stateful) {
/* PCE supports LSP updates, just sync all the path with
Expand Down Expand Up @@ -353,7 +352,7 @@ void pcep_pcc_sync_path(struct ctrl_state *ctrl_state,
void pcep_pcc_sync_done(struct ctrl_state *ctrl_state,
struct pcc_state *pcc_state)
{
if (pcc_state->status == PCEP_PCC_DISCONNECTED)
if (pcc_state->status != PCEP_PCC_SYNCHRONIZING)
return;

if (pcc_state->caps.is_stateful) {
Expand Down Expand Up @@ -384,6 +383,9 @@ void pcep_pcc_send_report(struct ctrl_state *ctrl_state,
struct pcc_state *pcc_state,
struct path *path)
{
if (pcc_state->status != PCEP_PCC_OPERATING)
return;

if (pcc_state->caps.is_stateful) {
PCEP_DEBUG("%s Send report for candidate path %s",
pcc_state->tag, path->name);
Expand All @@ -398,7 +400,7 @@ void pcep_pcc_pathd_event_handler(struct ctrl_state *ctrl_state,
enum pcep_pathd_event_type type,
struct path *path)
{
if (!pcc_state->synchronized)
if (pcc_state->status != PCEP_PCC_OPERATING)
return;

/* Skipping candidate path with endpoint that do not match the
Expand Down Expand Up @@ -501,6 +503,9 @@ void handle_pcep_open(struct ctrl_state *ctrl_state,
void handle_pcep_message(struct ctrl_state *ctrl_state,
struct pcc_state *pcc_state, struct pcep_message *msg)
{
if (pcc_state->status != PCEP_PCC_OPERATING)
return;

switch (msg->msg_header->type) {
case PCEP_TYPE_INITIATE:
handle_pcep_lsp_initiate(ctrl_state, pcc_state, msg);
Expand Down