Commit 7a4a547e53 for frr
commit 7a4a547e53c6caa955077c75aefe678c13993c48
Author: Lincoln Thurlow <lincoln@isi.edu>
Date: Mon Nov 30 09:32:36 2026 -0800
pathd: refuse PCUpd for an unknown PLSP-ID
pathd crashes when a PCE sends a PCUpd for a PLSP-ID that no path
on the router has.
The PCUpd handler looks the PLSP-ID up with assertions that it is
nonzero and known, so a PCE that sends a wrong PLSP-ID aborts the
daemon.
This commit addresses the TODO request for implementation and
responds with PCUpd with PCErr 19/3 (Attempted LSP Update Request
for an LSP identified by an unknown PLSP-ID), as RFC 8231 5.8.3
specifies.
Signed-off-by: Lincoln Thurlow <lincoln@isi.edu>
diff --git a/pathd/path_pcep_pcc.c b/pathd/path_pcep_pcc.c
index 7703b171ab..eb052141a3 100644
--- a/pathd/path_pcep_pcc.c
+++ b/pathd/path_pcep_pcc.c
@@ -108,7 +108,7 @@ static bool update_best_pce(struct pcc_state **pcc, int best);
/* Data Structure Helper Functions */
static void lookup_plspid(struct pcc_state *pcc_state, struct path *path);
-static void lookup_nbkey(struct pcc_state *pcc_state, struct path *path);
+static bool lookup_nbkey(struct pcc_state *pcc_state, struct path *path);
static void free_req_entry(struct req_entry *req);
static struct req_entry *push_new_req(struct pcc_state *pcc_state,
struct path *path);
@@ -1213,7 +1213,17 @@ void handle_pcep_lsp_update(struct ctrl_state *ctrl_state,
{
struct path *path;
path = pcep_lib_parse_path(msg);
- lookup_nbkey(pcc_state, path);
+
+ /* An unknown PLSP-ID gets PCErr 19/3 (RFC 8231 section 5.8.3) */
+ if (!lookup_nbkey(pcc_state, path)) {
+ flog_warn(EC_PATH_PCEP_PROTOCOL_ERROR, "%s PCE sent a PCUpd for unknown PLSP-ID %u",
+ pcc_state->tag, path->plsp_id);
+ send_pcep_error(pcc_state, PCEP_ERRT_INVALID_OPERATION,
+ PCEP_ERRV_LSP_UPDATE_UNKNOWN_PLSP_ID, path);
+ pcep_free_path(path);
+ return;
+ }
+
pcep_thread_refine_path(ctrl_state, pcc_state->id,
&continue_pcep_lsp_update, path, NULL);
}
@@ -1823,15 +1833,17 @@ void lookup_plspid(struct pcc_state *pcc_state, struct path *path)
}
}
-void lookup_nbkey(struct pcc_state *pcc_state, struct path *path)
+/* Returns false if no path has the PLSP-ID; PLSP-ID 0 is never assigned */
+bool lookup_nbkey(struct pcc_state *pcc_state, struct path *path)
{
struct nbkey_map_data key, *mapping;
- // TODO: Should give an error to the PCE instead of crashing
- assert(path->plsp_id != 0);
+
key.plspid = path->plsp_id;
mapping = nbkey_map_find(&pcc_state->nbkey_map, &key);
- assert(mapping != NULL);
+ if (mapping == NULL)
+ return false;
path->nbkey = mapping->nbkey;
+ return true;
}
void free_req_entry(struct req_entry *req)