Skip to content

Fix incorrect layer bindings in LDP contrib module#4985

Merged
gpotter2 merged 2 commits intosecdev:masterfrom
mohamedsolaiman:fix-ldp-bindings
May 1, 2026
Merged

Fix incorrect layer bindings in LDP contrib module#4985
gpotter2 merged 2 commits intosecdev:masterfrom
mohamedsolaiman:fix-ldp-bindings

Conversation

@mohamedsolaiman
Copy link
Copy Markdown
Contributor

Found a bug while testing LDP discovery over UDP. The bind_bottom_up calls for UDP were wrong:

# before (broken)
bind_bottom_up(TCP, UDP, sport=646)
bind_bottom_up(TCP, UDP, dport=646)

# after (fixed)
bind_bottom_up(UDP, LDP, sport=646)
bind_bottom_up(UDP, LDP, dport=646)

This meant LDP packets received over UDP on port 646 (used for LDP discovery/hello messages) would not be properly dissected. The old code was binding TCP to UDP which doesnt make any sense. LDP discovery uses UDP port 646, sessions use TCP port 646.

Added a test case to verify UDP-based LDP dissection works.

was testing LDP discovery over UDP and noticed it wasnt dissecting
properly. the bind_bottom_up calls for UDP were wrong - they had
(TCP, UDP) instead of (UDP, LDP). LDP discovery uses UDP port 646
so this needs to bind UDP to LDP not TCP to UDP.
added a test to make sure LDP hello over UDP port 646
gets dissected properly with the fixed bindings
Copy link
Copy Markdown
Member

@gpotter2 gpotter2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely, thanks for catching this.

@gpotter2 gpotter2 enabled auto-merge (squash) May 1, 2026 15:33
@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.27%. Comparing base (1e75eb3) to head (49b4913).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4985      +/-   ##
==========================================
- Coverage   80.28%   80.27%   -0.01%     
==========================================
  Files         383      383              
  Lines       94685    94685              
==========================================
- Hits        76015    76010       -5     
- Misses      18670    18675       +5     
Files with missing lines Coverage Δ
scapy/contrib/ldp.py 86.12% <100.00%> (ø)

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gpotter2 gpotter2 merged commit 0447516 into secdev:master May 1, 2026
24 checks passed
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.

2 participants