From 20d5851ecbdec18426e8b0aa588c6adbe5bb156b Mon Sep 17 00:00:00 2001 From: Sebastien Merle Date: Thu, 2 Jul 2020 12:30:44 +0200 Subject: [PATCH] pathd: pcep module: prevent any possible disconnection race leading to NULL sessions --- pathd/path_pcep_pcc.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pathd/path_pcep_pcc.c b/pathd/path_pcep_pcc.c index 47cc1b4c7b3f..400c0abda501 100644 --- a/pathd/path_pcep_pcc.c +++ b/pathd/path_pcep_pcc.c @@ -387,11 +387,9 @@ 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); - path->is_synching = true; path->go_active = true; @@ -428,7 +426,7 @@ void pcep_pcc_sync_done(struct ctrl_state *ctrl_state, { struct req_entry *req; - if (pcc_state->status == PCEP_PCC_DISCONNECTED) + if (pcc_state->status != PCEP_PCC_SYNCHRONIZING) return; if (pcc_state->caps.is_stateful) { @@ -464,6 +462,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); @@ -480,7 +481,7 @@ void pcep_pcc_pathd_event_handler(struct ctrl_state *ctrl_state, { struct req_entry* req; - if (!pcc_state->synchronized) + if (pcc_state->status != PCEP_PCC_OPERATING) return; /* Skipping candidate path with endpoint that do not match the @@ -586,6 +587,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);