From 01f5c7b68ee13dcc7cd00b5c7ecba933e54ed858 Mon Sep 17 00:00:00 2001 From: Mohamed Solaiman Date: Fri, 1 May 2026 10:19:48 +0000 Subject: [PATCH 1/2] fix wrong layer binding in LDP contrib module 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. --- scapy/contrib/ldp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scapy/contrib/ldp.py b/scapy/contrib/ldp.py index bd08ee8f58f..17a6af2972a 100644 --- a/scapy/contrib/ldp.py +++ b/scapy/contrib/ldp.py @@ -437,7 +437,7 @@ def post_build(self, p, pay): bind_bottom_up(TCP, LDP, sport=646) bind_bottom_up(TCP, LDP, dport=646) -bind_bottom_up(TCP, UDP, sport=646) -bind_bottom_up(TCP, UDP, dport=646) +bind_bottom_up(UDP, LDP, sport=646) +bind_bottom_up(UDP, LDP, dport=646) bind_layers(TCP, LDP, sport=646, dport=646) bind_layers(UDP, LDP, sport=646, dport=646) From 49b4913ade3fc1ea95facec14608171c07dd6c1f Mon Sep 17 00:00:00 2001 From: Mohamed Solaiman Date: Fri, 1 May 2026 10:20:09 +0000 Subject: [PATCH 2/2] add test for LDP over UDP dissection added a test to make sure LDP hello over UDP port 646 gets dissected properly with the fixed bindings --- test/contrib/ldp.uts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/contrib/ldp.uts b/test/contrib/ldp.uts index af6bcbb17d5..409383de577 100644 --- a/test/contrib/ldp.uts +++ b/test/contrib/ldp.uts @@ -43,6 +43,16 @@ assert pkti.params == [180, 0, 0, 0, 0, '1.1.2.2', 0] = Build advanced LDPAddress() with LDPLabelMM() pkta = LDPAddress(address=['1.1.2.2', '172.16.2.1'])/LDPLabelMM(fec=[('172.16.2.0', 31)])/LDPLabelMM(fec=[('1.1.2.2', 32)])/LDPLabelMM(fec=[('1.1.2.1', 32)]) += LDP over UDP dissection +load_contrib("ldp") +pkt = IP()/UDP(sport=646, dport=646)/LDP()/LDPHello() +raw_pkt = raw(pkt) +dissected = IP(raw_pkt) +assert LDP in dissected +assert UDP in dissected +assert dissected[UDP].sport == 646 +assert LDPHello in dissected + = Advanced dissection - complex LDP load_contrib("mpls") pkt = Ether(b"\xcc\x04\x04\xdc\x00\x10\xcc\x03\x04\xdc\x00\x10\x88G\x00\x01-\xfeE\xc0\x014\xfe\x84\x00\x00\xff\x06\xb5z\x01\x01\x02\x02\x01\x01\x02\x01\xe4\xe4\x02\x86\xbf\xfb'\xe4\xb9\xb3\xe4GP\x10\x0e\xb6v\x9f\x00\x00\x00\x01\x01\x08\x01\x01\x02\x02\x00\x00\x03\x00\x00\x12\x00\x00\x00\x0e\x01\x01\x00\n\x00\x01\x01\x01\x02\x02\xac\x10\x02\x01\x04\x00\x00\x18\x00\x00\x00\x0f\x01\x00\x00\x08\x02\x00\x01\x1f\xac\x10\x02\x00\x02\x00\x00\x04\x00\x00\x00\x03\x04\x00\x00\x18\x00\x00\x00\x10\x01\x00\x00\x08\x02\x00\x01 \x01\x01\x02\x02\x02\x00\x00\x04\x00\x00\x00\x03\x04\x00\x00\x18\x00\x00\x00\x11\x01\x00\x00\x08\x02\x00\x01 \x01\x01\x02\x01\x02\x00\x00\x04\x00\x00\x00\x12\x04\x00\x00\x18\x00\x00\x00\x12\x01\x00\x00\x08\x02\x00\x01 \x01\x01\x01\x02\x02\x00\x00\x04\x00\x00\x00\x13\x04\x00\x00\x18\x00\x00\x00\x13\x01\x00\x00\x08\x02\x00\x01 \x01\x01\x01\x01\x02\x00\x00\x04\x00\x00\x00\x14\x04\x00\x00\x18\x00\x00\x00\x14\x01\x00\x00\x08\x02\x00\x01\x1f\xac\x10\x01\x00\x02\x00\x00\x04\x00\x00\x00\x15\x04\x00\x00\x18\x00\x00\x00\x15\x01\x00\x00\x08\x02\x00\x01\x1f\xac\x10\x00\x00\x02\x00\x00\x04\x00\x00\x00\x16\x04\x00\x00$\x00\x00\x00\x16\x01\x00\x00\x14\x80\x80\x05\x0c\x00\x00\x00\x00\x00\x00\x00\n\x01\x04\x05\xdc\x0c\x04\x03\x02\x02\x00\x00\x04\x00\x00\x00\x10")