pceplib, pathd: improve pcep parsing and error-handling#21208
pceplib, pathd: improve pcep parsing and error-handling#21208riw777 merged 4 commits intoFRRouting:masterfrom
Conversation
Greptile SummaryThis PR improves robustness of PCEP message parsing in FRR's pathd/pceplib by replacing crash-inducing Key changes:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Socket as pcep_socket_comm_loop
participant Decoder as pcep_msg_objects_encoding
participant TLVDec as pcep_msg_tlvs_encoding
participant PathLib as path_pcep_lib
participant PCC as path_pcep_pcc
Socket->>Decoder: raw bytes after write_message fix
Decoder->>Decoder: pcep_decode_obj_ro - validate subobj lengths
alt parse error detected
Decoder->>Decoder: err_p=true, pcep_obj_free_object
Decoder-->>PathLib: return NULL
else all subobjects valid
Decoder-->>PathLib: return pcep_object_ro
end
TLVDec->>TLVDec: pcep_decode_tlv_pol_name - cap len at MAX_POLICY_NAME
PathLib->>PathLib: pcep_lib_parse_path - if-guards replace asserts
PathLib->>PathLib: pcep_lib_parse_ero - iterate tail to head
loop each RO subobject
PathLib->>PathLib: pcep_lib_parse_ero_sr - validate flag_s and nai_list
alt hop valid
PathLib->>PathLib: prepend hop to path->first_hop
else hop NULL
PathLib->>PathLib: flog_warn, skip subobject
end
end
PCC->>PCC: pcep_pcc_enable - guard invalid state with flog_warn
|
8ecc2a0 to
243fc75
Compare
|
pushed updates to address the greptile comments |
|
@greptileai review |
243fc75 to
4aeeed2
Compare
|
Updated to fix the comment about the error-handling for ERO subobjects |
|
@greptileai review |
4aeeed2 to
e8ac707
Compare
|
And updating again to fix another greptile comment |
|
@greptileai review |
e8ac707 to
9ffe8d6
Compare
|
@greptileai review |
9ffe8d6 to
387246e
Compare
|
@greptileai review |
|
I don't think the lint is something that needs to be addressed here ... ?? |
|
yeah, I'm afraid it is - it's better not to let those things in. I also want to wait to ensure greptile is clean
|
387246e to
2ee9699
Compare
|
ok, pushed a checkpatch fix, and greptile seems satisfied now. |
|
@greptile review |
Limit the number of POLICY_NAME octets copied to avoid overrun. Signed-off-by: Mark Stapp <mjs@cisco.com>
Correct the arithmetic in packet-sending: test the correct message-length, continue sending from offset into buffer rather than start of buffer. Signed-off-by: Mark Stapp <mjs@cisco.com>
Compute and test required bytes available before accessing message buffer. Avoid unaligned integer casts. Signed-off-by: Mark Stapp <mjs@cisco.com>
Avoid asserts in some paths that involve incoming messages; handle messages with errors more cleanly. Improve error-handling with EROs; be more careful to avoid invalid subobjects. Signed-off-by: Mark Stapp <mjs@cisco.com>
2ee9699 to
22959e4
Compare
|
greptile has three complaints; I think only one was valid, and I've pushed a fix for that.
|
Make handling of pcep messages more robust; fix several packet-handling errors and add validation in several paths. Replace some pathd asserts with less-dramatic error handling.