Commit 0fb41ff1ef for frr
commit 0fb41ff1ef2901ba70881365277eb15ffec9200b
Author: Lincoln Thurlow <lincoln@isi.edu>
Date: Tue Dec 1 09:58:59 2026 -0800
tests: check PCErr 19/3 for an unknown PLSP-ID
The pathd PCEP steering topotest does not check how pathd answers a
PCUpd for a PLSP-ID it never reported.
This commit adds a test where the mock PCE sends such a PCUpd. pathd
must answer with PCErr 19/3 (RFC 8231 section 5.8.3) carrying the
PCUpd's SRP-ID, and keep the session and its policies. The mock PCE
now logs the PCErr messages it receives, and gets an update-plsp
command that sends a PCUpd for any PLSP-ID.
Signed-off-by: Lincoln Thurlow <lincoln@isi.edu>
diff --git a/tests/topotests/pathd_pcep_steering_topo1/mock_pce.py b/tests/topotests/pathd_pcep_steering_topo1/mock_pce.py
index e02a861898..74d49ec55b 100644
--- a/tests/topotests/pathd_pcep_steering_topo1/mock_pce.py
+++ b/tests/topotests/pathd_pcep_steering_topo1/mock_pce.py
@@ -38,6 +38,7 @@ KEEPALIVE_SECONDS = 10 # well inside the 30s keepalive its Open advertises
MSG_OPEN = 1
MSG_KEEPALIVE = 2
+MSG_ERROR = 6
MSG_REPORT = 10
MSG_UPDATE = 11
MSG_INITIATE = 12
@@ -45,6 +46,7 @@ MSG_INITIATE = 12
CLASS_OPEN = 1
CLASS_ENDPOINTS = 4
CLASS_ERO = 7
+CLASS_ERROR = 13
CLASS_LSP = 32
CLASS_SRP = 33
CLASS_VENDOR_INFO = 34
@@ -332,6 +334,32 @@ class MockPce:
self.log("MAPPED name=%s plsp-id=%u" % (name, plsp_id))
index += olen
+ def handle_error(self, body):
+ """Log a PCErr: its PCEP-ERROR objects (class 13) carry the
+ error-type and error-value in the 3rd and 4th bytes of their
+ body, and an SRP object echoes the SRP-ID of the failed request.
+ The whole message is read first, so the SRP is found before or
+ after the PCEP-ERROR."""
+ index = 0
+ srp_id = None
+ errors = []
+ while index + 4 <= len(body):
+ oclass = body[index]
+ olen = struct.unpack(">H", body[index + 2 : index + 4])[0]
+ if olen < 4 or index + olen > len(body):
+ break
+ if oclass == CLASS_SRP and olen >= 12:
+ # SRP body: flags(4) then srp-id(4)
+ srp_id = struct.unpack(">I", body[index + 8 : index + 12])[0]
+ if oclass == CLASS_ERROR and olen >= 8:
+ # PCEP-ERROR body: reserved(1) flags(1) type(1) value(1)
+ errors.append((body[index + 6], body[index + 7]))
+ index += olen
+ for error_type, error_value in errors:
+ self.log(
+ "RECV-ERROR type=%u value=%u srp=%s" % (error_type, error_value, srp_id)
+ )
+
def handle_message(self, mtype, body):
if mtype == MSG_OPEN:
self.log("RECV-OPEN")
@@ -339,6 +367,8 @@ class MockPce:
self.log("RECV-KEEPALIVE")
elif mtype == MSG_REPORT:
self.handle_report(body)
+ elif mtype == MSG_ERROR:
+ self.handle_error(body)
else:
self.log("RECV-TYPE-%u" % mtype)
@@ -348,6 +378,7 @@ class MockPce:
remove <name>
add <endpoint,label,name[,color]>
update <name,label>
+ update-plsp <plsp-id,label>
add is only meaningful once the PCC's state-sync is done (pathd
silently discards earlier PCInitiates); the tests churn well
@@ -377,6 +408,9 @@ class MockPce:
elif len(fields) == 2 and fields[0] == "update":
name, label = fields[1].split(",")
self.send_update(name, int(label))
+ elif len(fields) == 2 and fields[0] == "update-plsp":
+ plsp_id, label = fields[1].split(",")
+ self.send_update_plsp(int(plsp_id), int(label))
elif len(fields) == 2 and fields[0] == "add":
try:
policy = parse_policy(fields[1])
@@ -421,6 +455,14 @@ class MockPce:
self.send(self.build_update(name, plsp_id, srp_id, label))
self.log("UPDATE-SENT name=%s plsp-id=%u srp=%u" % (name, plsp_id, srp_id))
+ def send_update_plsp(self, plsp_id, label):
+ """Send a PCUpd for a PLSP-ID, whether the PCC reported it or not"""
+ srp_id = self.next_srp_id
+ self.next_srp_id += 1
+ name = "plsp-%u" % plsp_id
+ self.send(self.build_update(name, plsp_id, srp_id, label))
+ self.log("UPDATE-PLSP-SENT plsp-id=%u srp=%u" % (plsp_id, srp_id))
+
def send(self, data):
self.conn.sendall(data)
diff --git a/tests/topotests/pathd_pcep_steering_topo1/test_pathd_pcep_steering_topo1.py b/tests/topotests/pathd_pcep_steering_topo1/test_pathd_pcep_steering_topo1.py
index a65742d602..688ad6a94a 100644
--- a/tests/topotests/pathd_pcep_steering_topo1/test_pathd_pcep_steering_topo1.py
+++ b/tests/topotests/pathd_pcep_steering_topo1/test_pathd_pcep_steering_topo1.py
@@ -72,6 +72,8 @@ CAP_COLOR_BASE = 5000
SIBLING_COLOR = 4000
# In the SRGB but no prefix-SID uses it, so a policy on it cannot resolve
UNUSED_LABEL = 16999
+# The largest PLSP-ID, far above any pathd assigns here
+UNKNOWN_PLSP_ID = 0xFFFFF
def build_topo(tgen):
@@ -689,6 +691,41 @@ def test_steering_route_failed_replace():
assert result is None, "sibling not removed: {}".format(result)
+def test_pcupd_unknown_plsp_id():
+ "A PCUpd for a PLSP-ID pathd never reported gets PCErr 19/3"
+
+ tgen = get_topogen()
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ pce_command("update-plsp {},{}".format(UNKNOWN_PLSP_ID, LABEL))
+
+ # RFC 8231 section 5.8.3, with the SRP-ID of the PCUpd
+ def check_error():
+ log = mock_pce_log_text()
+ sent = re.findall(
+ r"UPDATE-PLSP-SENT plsp-id={} srp=(\d+)".format(UNKNOWN_PLSP_ID), log
+ )
+ if not sent:
+ return "mock PCE did not send the PCUpd"
+ if "RECV-ERROR type=19 value=3 srp={}\n".format(sent[-1]) not in log:
+ return "no PCErr 19/3 for SRP-ID {}".format(sent[-1])
+ return None
+
+ _, result = topotest.run_and_expect(check_error, None, count=30, wait=1)
+ if result is not None:
+ print_pce_log()
+ assert result is None, result
+
+ # The session and its policies are kept
+ check = lambda: check_policy_count(2)
+ _, result = topotest.run_and_expect(check, None, count=30, wait=1)
+ assert result is None, "policies changed: {}".format(result)
+ check = lambda: check_steering_route(True)
+ _, result = topotest.run_and_expect(check, None, count=30, wait=1)
+ assert result is None, "steering route changed: {}".format(result)
+
+
def test_pce_restart():
"Kill and restart the PCE; policies must re-establish"