Skip to content

ldp: make the Label TLV optional in Withdraw and Release - #5316

Open
leninworld wants to merge 1 commit into
secdev:masterfrom
leninworld:ldp-optional-label-tlv
Open

leninworld wants to merge 1 commit into
secdev:masterfrom
leninworld:ldp-optional-label-tlv

Conversation

@leninworld

Copy link
Copy Markdown

Description

The Label TLV is optional in Label Withdraw and Label Release messages (RFC 5036 sections 3.5.10 and 3.5.11), but contrib/ldp always reads one:

from scapy.contrib.ldp import LDPLabelRelM, LDPLabelWM

msg = bytes.fromhex("000f000000010100000702000118c0a802")  # FEC TLV only
keepalive = bytes.fromhex("0201000400000002")

LDPLabelRelM(b"\x04\x03" + msg)              # struct.error
LDPLabelWM(b"\x04\x02" + msg + keepalive)    # label=2, the KeepAlive is consumed

The two messages now read a label only when the message length leaves room for it and the next TLV is a Label TLV (0x0200 to 0x0202). Otherwise label is None, and label=None builds a message without the TLV. The default build is unchanged.

Not covered: other TLVs, such as Status, are still not decoded. They are dissected as a following layer, and messages after them are not dissected correctly.

This message was written with the help of AI (Codex GPT-5.6-Sol and Claude Opus 5.5).

RFC 5036 sections 3.5.10 and 3.5.11 make the Label TLV optional. A
Release without it raised struct.error, and a Withdraw or Release
without it consumed the following message as the label.

AI-Assisted: yes (Codex GPT-5.6-Sol, Claude Opus 5.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant