Commit b60cfe9072 for frr
commit b60cfe9072e67f71339a52b15cf5b6797ab74ee4
Author: Lincoln Thurlow <lincoln@isi.edu>
Date: Tue Dec 1 11:00:45 2026 -0800
pathd: refuse PCInitiates with unacceptable names
A PCE-initiated path whose segment list name is already in use is
orphaned without a segment list, and the PCE is not notified of the
problem. path_pcep_config_initiate_path() creates the policy and
candidate path before path_pcep_config_update_path() finds that the
segment list name is already taken.
This commit checks the names before creating anything, and refuses the
PCInitiate with PCErr 24/1 (Unacceptable instantiation parameters, RFC
8281 section 5.3) when the segment list name is in use, when the
symbolic path name is longer than 56 characters, the longest that
keeps "<name>-<plsp_id>" within 64 characters, or when it starts with
the reserved "pcep-hash-".
Signed-off-by: Lincoln Thurlow <lincoln@isi.edu>
diff --git a/pathd/path_pcep.c b/pathd/path_pcep.c
index 766df5f1c2..15d4553384 100644
--- a/pathd/path_pcep.c
+++ b/pathd/path_pcep.c
@@ -250,6 +250,11 @@ static struct pcep_error *initiate_error(struct path *path, int ret)
error_type = PCEP_ERRT_BAD_PARAMETER_VALUE;
error_value = PCEP_ERRV_SYMBOLIC_PATH_NAME_IN_USE;
break;
+ case ERROR_24_1:
+ /* RFC 8281 section 5.3: name too long, reserved, or its list taken */
+ error_type = PCEP_ERRT_LSP_INSTANTIATE_ERROR;
+ error_value = PCEP_ERRV_UNACCEPTABLE_INSTANTIATE_ERROR;
+ break;
default:
return NULL;
}
diff --git a/pathd/path_pcep.h b/pathd/path_pcep.h
index 358d0dd7c4..5536a9385a 100644
--- a/pathd/path_pcep.h
+++ b/pathd/path_pcep.h
@@ -299,6 +299,7 @@ struct pcep_error {
#define ERROR_19_3 1903
#define ERROR_19_9 1909
#define ERROR_23_1 2301
+#define ERROR_24_1 2401
};
/* Path Helper Functions */
diff --git a/pathd/path_pcep_config.c b/pathd/path_pcep_config.c
index 7df85ba9bc..aa460d00a7 100644
--- a/pathd/path_pcep_config.c
+++ b/pathd/path_pcep_config.c
@@ -33,6 +33,8 @@ path_pcep_config_list_path_hops(struct srte_segment_list *segment_list);
static struct srte_candidate *lookup_candidate(struct lsp_nb_key *key);
static struct srte_candidate *lookup_candidate_by_name(const char *name);
static void pcep_segment_list_name(char *buf, size_t size, struct path *path);
+static bool segment_list_name_taken(struct path *path, struct srte_candidate *candidate);
+static bool path_name_too_long(struct path *path);
static bool path_name_reserved(struct path *path);
static char *candidate_name(struct srte_candidate *candidate);
static enum pcep_lsp_operational_status
@@ -315,12 +317,28 @@ int path_pcep_config_initiate_path(struct path *path)
candidate = lookup_candidate(&path->nbkey);
if (!candidate) {
+ if (path_name_too_long(path)) {
+ zlog_warn("PCE %s tried to initiate a path with a symbolic path name longer than %d characters: %s",
+ path->originator, SRTE_PCEP_NAME_MAX_LENGTH, path->name);
+ return ERROR_24_1;
+ }
+ if (path_name_reserved(path)) {
+ zlog_warn("PCE %s tried to initiate a path with a reserved symbolic path name: %s",
+ path->originator, path->name);
+ return ERROR_24_1;
+ }
/* The symbolic path name must not be in use (RFC 8281 section 5.3) */
if (path->name != NULL && lookup_candidate_by_name(path->name) != NULL) {
zlog_warn("PCE %s tried to initiate a path with a symbolic path name already in use: %s",
path->originator, path->name);
return ERROR_23_1;
}
+ /* Refuse before creating anything */
+ if (segment_list_name_taken(path, NULL)) {
+ 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;
+ }
policy = srte_policy_add(
path->nbkey.color, &path->nbkey.endpoint,
SRTE_ORIGIN_PCEP, path->originator);
@@ -506,6 +524,25 @@ void pcep_segment_list_name(char *buf, size_t size, struct path *path)
path->name, hash, path->plsp_id);
}
+/* Segment list name "<name>-<plsp_id>" held by a list other than candidate's */
+bool segment_list_name_taken(struct path *path, struct srte_candidate *candidate)
+{
+ char name[SRTE_NAME_LENGTH];
+ struct srte_segment_list *segment_list;
+
+ pcep_segment_list_name(name, sizeof(name), path);
+ segment_list = srte_segment_list_find(name);
+ if (segment_list == NULL)
+ return false;
+
+ return candidate == NULL || segment_list != candidate->lsp->segment_list;
+}
+
+bool path_name_too_long(struct path *path)
+{
+ return path->name != NULL && strlen(path->name) > SRTE_PCEP_NAME_MAX_LENGTH;
+}
+
bool path_name_reserved(struct path *path)
{
return path->name != NULL &&
diff --git a/pathd/pathd.h b/pathd/pathd.h
index ee1d10f09c..a70ec13de7 100644
--- a/pathd/pathd.h
+++ b/pathd/pathd.h
@@ -198,6 +198,8 @@ RB_PROTOTYPE(srte_segment_entry_head, srte_segment_entry, entry,
/* Name length limit in frr-pathd.yang */
#define SRTE_YANG_NAME_MAX_LENGTH 64
#define SRTE_NAME_LENGTH (SRTE_YANG_NAME_MAX_LENGTH + 1)
+/* PCEP segment lists are "<name>-<plsp_id>", PLSP-ID up to 7 digits */
+#define SRTE_PCEP_NAME_MAX_LENGTH (SRTE_YANG_NAME_MAX_LENGTH - 8)
/* Prefix of hashed PCEP segment list names, reserved from configuration */
#define SRTE_PCEP_HASHED_PREFIX "pcep-hash-"