Commit dc11fc6806 for frr
commit dc11fc68064edf4fa5a2b6d3074eaa49ff9ebd01
Author: Lincoln Thurlow <lincoln@isi.edu>
Date: Tue Dec 1 11:00:45 2026 -0800
pathd: time out each PCEP session on its own
pathd cleans up after a PCE that goes down only when no other PCE is
connected, and then cleans up the segment lists of every PCE.
schedule_session_timeout() does not start the session timeout while
another PCE is connected, pcep_pcc_disable() cleans up right away
when the last PCE disconnects, and the cleanup is forced for every
originator.
This commit starts the session timeout of each PCE when its session
goes down, even when other PCEs are connected, and cleans up only when
it expires, and only the segment lists that PCE set.
Signed-off-by: Lincoln Thurlow <lincoln@isi.edu>
diff --git a/pathd/path_pcep.c b/pathd/path_pcep.c
index c0ae76498f..4567f67950 100644
--- a/pathd/path_pcep.c
+++ b/pathd/path_pcep.c
@@ -46,8 +46,7 @@ static int pcep_main_event_start_sync(int pcc_id);
static int pcep_main_event_start_sync_cb(struct path *path, void *arg);
static int pcep_main_event_initiate_candidate(struct path *path);
static int pcep_main_event_update_candidate(struct path *path);
-static int pcep_main_event_remove_candidate_segments(const char *originator,
- bool force);
+static int pcep_main_event_remove_candidate_segments(const char *originator);
/* Hook Handlers called from the Main Thread */
static int pathd_candidate_created_handler(struct srte_candidate *candidate);
@@ -199,8 +198,7 @@ int pcep_main_event_handler(enum pcep_main_event_type type, int pcc_id,
ret = pcep_main_event_update_candidate((struct path *)payload);
break;
case PCEP_MAIN_EVENT_REMOVE_CANDIDATE_LSP:
- ret = pcep_main_event_remove_candidate_segments(
- (const char *)payload, true);
+ ret = pcep_main_event_remove_candidate_segments((const char *)payload);
break;
case PCEP_MAIN_EVENT_UNDEFINED:
flog_warn(EC_PATH_PCEP_RECOVERABLE_INTERNAL_ERROR,
@@ -314,10 +312,9 @@ int pcep_main_event_update_candidate(struct path *path)
return ret;
}
-int pcep_main_event_remove_candidate_segments(const char *originator,
- bool force)
+int pcep_main_event_remove_candidate_segments(const char *originator)
{
- srte_candidate_unset_segment_list(originator, force);
+ srte_candidate_unset_segment_list(originator);
/* Avoid compiler warnings about const char* */
void *free_ptr = (void *)originator;
XFREE(MTYPE_PCEP, free_ptr);
diff --git a/pathd/path_pcep_pcc.c b/pathd/path_pcep_pcc.c
index 8615cffa85..d897ae59a5 100644
--- a/pathd/path_pcep_pcc.c
+++ b/pathd/path_pcep_pcc.c
@@ -103,7 +103,6 @@ static int compare_pcc_opts(struct pcc_opts *lhs, struct pcc_opts *rhs);
static int compare_pce_opts(struct pce_opts *lhs, struct pce_opts *rhs);
static int get_previous_best_pce(struct pcc_state **pcc);
static int get_best_pce(struct pcc_state **pcc);
-static int get_pce_count_connected(struct pcc_state **pcc);
static bool update_best_pce(struct pcc_state **pcc, int best);
/* Data Structure Helper Functions */
@@ -446,11 +445,6 @@ int pcep_pcc_disable(struct ctrl_state *ctrl_state, struct pcc_state *pcc_state)
PCEP_DEBUG("%s Disconnecting PCC...", pcc_state->tag);
cancel_comp_requests(ctrl_state, pcc_state);
pcep_lib_disconnect(pcc_state->sess);
- /* No need to remove if any PCEs is connected */
- if (get_pce_count_connected(ctrl_state->pcc) == 0) {
- pcep_thread_remove_candidate_path_segments(ctrl_state,
- pcc_state);
- }
pcc_state->sess = NULL;
pcc_state->status = PCEP_PCC_DISCONNECTED;
return 0;
@@ -814,18 +808,6 @@ int get_best_pce(struct pcc_state **pcc)
return 0;
}
-int get_pce_count_connected(struct pcc_state **pcc)
-{
- int count = 0;
- for (int i = 0; i < MAX_PCC; i++) {
- if (pcc[i] && pcc[i]->pce_opts
- && pcc[i]->status != PCEP_PCC_DISCONNECTED) {
- count++;
- }
- }
- return count;
-}
-
int get_previous_best_pce(struct pcc_state **pcc)
{
int previous_best_pce = -1;
@@ -1568,14 +1550,7 @@ void schedule_reconnect(struct ctrl_state *ctrl_state,
void schedule_session_timeout(struct ctrl_state *ctrl_state,
struct pcc_state *pcc_state)
{
- /* No need to schedule timeout if multiple PCEs are connected */
- if (get_pce_count_connected(ctrl_state->pcc)) {
- PCEP_DEBUG_PCEP(
- "schedule_session_timeout not setting timer for multi-pce mode");
-
- return;
- }
-
+ /* Each PCE has its own timeout, even when other PCEs are connected */
pcep_thread_schedule_session_timeout(
ctrl_state, pcep_pcc_get_pcc_id(pcc_state),
pcc_state->pce_opts->config_opts
@@ -1586,7 +1561,6 @@ void schedule_session_timeout(struct ctrl_state *ctrl_state,
void cancel_session_timeout(struct ctrl_state *ctrl_state,
struct pcc_state *pcc_state)
{
- /* No need to schedule timeout if multiple PCEs are connected */
if (!event_is_scheduled(pcc_state->t_session_timeout)) {
PCEP_DEBUG_PCEP("cancel_session_timeout timer thread NULL");
return;
diff --git a/pathd/pathd.c b/pathd/pathd.c
index 0266f5248e..5ea23bf730 100644
--- a/pathd/pathd.c
+++ b/pathd/pathd.c
@@ -1233,9 +1233,8 @@ void srte_candidate_status_update(struct srte_candidate *candidate, int status)
* the segment list to be removed.
*
* @param originator The originator tag of the segment list to be marked
- * @param force If the unset should be forced regardless of the originator
*/
-void srte_candidate_unset_segment_list(const char *originator, bool force)
+void srte_candidate_unset_segment_list(const char *originator)
{
if (originator == NULL) {
zlog_warn(
@@ -1279,13 +1278,8 @@ void srte_candidate_unset_segment_list(const char *originator, bool force)
continue;
}
- /* In the case of last pce,we force the unset
- * because we don't have pce by prefix (TODO) is all
- * 'global' */
if (strncmp(segment_list->originator, originator,
- sizeof(segment_list->originator))
- == 0
- || force) {
+ sizeof(segment_list->originator)) == 0) {
PATH_POLICY_DEBUG("Unset segment list %s",
segment_list->name);
SET_FLAG(segment_list->flags,
diff --git a/pathd/pathd.h b/pathd/pathd.h
index a70ec13de7..abe343097f 100644
--- a/pathd/pathd.h
+++ b/pathd/pathd.h
@@ -450,7 +450,7 @@ struct srte_candidate *srte_candidate_find(struct srte_policy *policy,
struct srte_segment_entry *
srte_segment_entry_find(struct srte_segment_list *segment_list, uint32_t index);
void srte_candidate_status_update(struct srte_candidate *candidate, int status);
-void srte_candidate_unset_segment_list(const char *originator, bool force);
+void srte_candidate_unset_segment_list(const char *originator);
const char *srte_origin2str(enum srte_protocol_origin origin);
void pathd_shutdown(void);