Fix BGP pcap parsing in test_bgp_suppress_fib with scapy TCPSession#24007
Open
mike-dubrovsky wants to merge 1 commit into
Open
Fix BGP pcap parsing in test_bgp_suppress_fib with scapy TCPSession#24007mike-dubrovsky wants to merge 1 commit into
mike-dubrovsky wants to merge 1 commit into
Conversation
Use scapy's TCPSession to reassemble BGP messages that span multiple TCP segments before parsing. Without this, large BGP UPDATE messages (especially with many IPv6 routes) get parsed per-packet, producing malformed route objects that lack a 'prefix' attribute and cause AttributeError. Signed-off-by: mike-dubrovsky <mdubrovs@cisco.com>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of PR
Summary:
Enable scapy TCP reassembly (
TCPSession) when parsing BGP pcap captures intest_bgp_suppress_fib.py, fixingAttributeError: prefixcrashes caused by BGP UPDATE messages that span multiple TCP segments.This is a follow-up to #21843 which added
hasattrguards for IPv4 routes as a workaround for the same underlying issue. That PR treated the symptom (malformed route objects) but not the root cause (lack of TCP reassembly).Type of change
Back port request
Approach
What is the motivation for this PR?
test_suppress_fib_performancefails withAttributeError: prefixwhen parsing IPv6 BGP routes from pcap files. The root cause is thatscapy.sniff()withoutsession=TCPSessionparses each TCP segment independently. When a large BGP UPDATE message (carrying many IPv6 routes) spans multiple TCP segments, scapy produces malformed/incomplete NLRI route objects that lack aprefixattribute.#21843 partially addressed this by adding
hasattr(route, 'prefix')guards for the IPv4 loops, but the IPv6 loops were left unprotected, and the root cause (missing TCP reassembly) was not fixed.Scapy 2.7.0 added BGP TCP reassembly support (secdev/scapy#4756), but it must be explicitly enabled by passing
session=TCPSessiontosniff().How did you do it?
from scapy.sessions import TCPSessionimport.session=TCPSessionto thesniff()call invalidate_route_process_perf(), so scapy reassembles the TCP stream before parsing BGP messages.How did you verify/test it?
Tested on T1 isolated Cisco-8101 DUT. The
test_suppress_fib_performancetest that previously failed withAttributeError: prefixnow passes consistently.Any platform specific information?
No platform specific changes. The fix applies to all platforms.
Supported testbed topology if it's a new test case?
N/A - existing test case fix.
Documentation
N/A