Commit 085fb91db2 for frr

commit 085fb91db225945edfb269ceccd4b7e00d1f55fa
Author: Lincoln Thurlow <lincoln@isi.edu>
Date:   Tue Dec 1 11:00:45 2026 -0800

    pathd: report a refused PCUpd in a PCRpt

    A PCUpd whose segment list name is already in use leaves the path
    without a segment list, and the PCE is not told.
    path_pcep_config_update_path() deletes the current segment list before
    it adds the new one, and nothing reports the failure.

    This commit checks the name before changing anything, and reports the
    refused PCUpd in a PCRpt carrying its SRP-ID and an LSP-ERROR-CODE TLV
    "Unacceptable parameters" (4), (RFC 8231 5.8.3). A PCUpd is not an
    instantiation, so PCErr 24 does not apply. A PCUpd without a symbolic
    path name takes the name of the candidate path it updates.

    Signed-off-by: Lincoln Thurlow <lincoln@isi.edu>

diff --git a/pathd/path_pcep.c b/pathd/path_pcep.c
index 15d4553384..c0ae76498f 100644
--- a/pathd/path_pcep.c
+++ b/pathd/path_pcep.c
@@ -296,6 +296,17 @@ int pcep_main_event_update_candidate(struct path *path)
 	int ret = 0;

 	ret = path_pcep_config_update_path(path);
+	if (ret == ERROR_24_1) {
+		struct path *resp = path_pcep_config_get_path(&path->nbkey);
+
+		if (resp) {
+			resp->srp_id = path->srp_id;
+			resp->lsp_error_code = PCEP_TLV_LSP_ERROR_CODE_UNACCEPTABLE_PARAMS;
+			pcep_ctrl_send_report(pcep_g->fpt, path->pcc_id, resp, true);
+		}
+		pcep_free_path(path);
+		return ret;
+	}
 	if (ret != PATH_NB_ERR && path->srp_id != 0)
 		notify_status(path, ret == PATH_NB_NO_CHANGE);
 	/* Same ownership as the initiate case: the parsed path is ours. */
diff --git a/pathd/path_pcep.h b/pathd/path_pcep.h
index 5536a9385a..4d90a5a7cb 100644
--- a/pathd/path_pcep.h
+++ b/pathd/path_pcep.h
@@ -222,6 +222,8 @@ struct path {
 	uint32_t req_id;
 	/* The operational status of the path */
 	enum pcep_lsp_operational_status status;
+	/* LSP-ERROR-CODE TLV value, 0 for none */
+	enum pcep_tlv_lsp_error_codes lsp_error_code;
 	/* If true, the receiver (PCC) must remove the path.
 	   See draft-ietf-pce-pce-initiated-lsp */
 	bool do_remove;
diff --git a/pathd/path_pcep_config.c b/pathd/path_pcep_config.c
index aa460d00a7..4b5ce1d28b 100644
--- a/pathd/path_pcep_config.c
+++ b/pathd/path_pcep_config.c
@@ -404,6 +404,17 @@ int path_pcep_config_update_path(struct path *path)
 	if (!candidate)
 		return 0;

+	/* A PCUpd may leave out the symbolic path name */
+	if (path->name == NULL)
+		path->name = candidate_name(candidate);
+
+	/* Refuse before the current segment list is deleted */
+	if (segment_list_name_taken(path, candidate)) {
+		zlog_warn("segment list name %s-%u of path %s is already in use, rejecting the path",
+			  path->name, path->plsp_id, path->name);
+		return ERROR_24_1;
+	}
+
 	candidate->policy->srp_id = path->srp_id;
 	// first clean up old segment list if present
 	if (candidate->lsp->segment_list) {
@@ -420,11 +431,8 @@ int path_pcep_config_update_path(struct path *path)
 	segment_list_name = segment_list_name_buff;

 	segment_list = srte_segment_list_add(segment_list_name);
-	if (segment_list == NULL) {
-		zlog_warn("segment list name %s of path %s (plsp %u) is already in use, rejecting the path",
-			  segment_list_name, path->name, path->plsp_id);
-		return PATH_NB_ERR;
-	}
+	/* segment_list_name_taken() checked the name above */
+	assert(segment_list != NULL);
 	segment_list->protocol_origin = path->update_origin;
 	strlcpy(segment_list->originator, path->originator,
 		sizeof(segment_list->originator));
diff --git a/pathd/path_pcep_lib.c b/pathd/path_pcep_lib.c
index 7f6d708cef..4dd7cdebad 100644
--- a/pathd/path_pcep_lib.c
+++ b/pathd/path_pcep_lib.c
@@ -673,6 +673,12 @@ double_linked_list *pcep_lib_format_path(struct pcep_caps *caps,
 		assert(tlv != NULL);
 		dll_append(lsp_tlvs, tlv);
 	}
+	if (path->lsp_error_code != 0) {
+		tlv = (struct pcep_object_tlv_header *)pcep_tlv_create_lsp_error_code(
+			path->lsp_error_code);
+		assert(tlv != NULL);
+		dll_append(lsp_tlvs, tlv);
+	}
 	lsp = pcep_obj_create_lsp(
 		path->plsp_id, path->status, path->was_created /* C Flag */,
 		path->go_active /* A Flag */, path->was_removed /* R Flag */,
diff --git a/pathd/path_pcep_pcc.c b/pathd/path_pcep_pcc.c
index fd5c566e41..8615cffa85 100644
--- a/pathd/path_pcep_pcc.c
+++ b/pathd/path_pcep_pcc.c
@@ -554,6 +554,12 @@ void pcep_pcc_send_report(struct ctrl_state *ctrl_state,
 	PCEP_DEBUG("(%s)%s Send report for candidate path %s", __func__,
 		   pcc_state->tag, path->name);

+	if (path->lsp_error_code != 0) {
+		send_report(pcc_state, path);
+		pcep_free_path(path);
+		return;
+	}
+
 	/* ODL and Cisco requires the first reported
 	 * LSP to have a DOWN status, the later status changes
 	 * will be communicated through hook calls.