Skip to content

rpl_metrics: end each metric object at its own length - #5272

Open
bIackr0se wants to merge 2 commits into
secdev:masterfrom
bIackr0se:fix/rpl-dagmc-object-bounds
Open

bIackr0se wants to merge 2 commits into
secdev:masterfrom
bIackr0se:fix/rpl-dagmc-object-bounds

Conversation

@bIackr0se

Copy link
Copy Markdown
Contributor

Description

A DAG Metric Container with more than one routing metric object dissects as the first object only. The objects follow each other directly, each a 4-octet header and a body of Length octets (RFC 6551, 2.1), but the metric object classes have no extract_padding, so the first object keeps the rest of the list as its Raw payload.

DAGMCObj now ends each object after its Length octets of body, or after its declared fields if those are longer, so the next object of the list starts there. Body octets beyond the fields scapy declares for an object, such as the second color of a Link Color object, stay in that object's payload.

from scapy.all import load_contrib
load_contrib("rpl")
load_contrib("rpl_metrics")
from scapy.contrib.rpl_metrics import RPLOptDAGMC
# DAG Metric Container: Hop Count 3, Link Latency 1500, Link ETX 256
p = RPLOptDAGMC(bytes.fromhex("021403000002000305000004000005dc070000020100"))
print([o.name for o in p.options])

Before:

['Hop Count']

After:

['Hop Count', 'Link Latency', 'Link ETX']

Five DIOs built by hand from RFC 6551 (one to three objects, Node State and Node Energy, a recorded Link Color object with two colors) now dissect into the same object sequence that tshark decodes, with tshark's value in every field scapy declares, and each rebuilds to the same bytes. The new test in test/contrib/rpl.uts covers the three-object container and the Link Color case.

This message was written with the help of AI (Claude Opus 5.5).

A DAG Metric Container lists its routing metric objects back to back,
each a 4-octet header and a body of Length octets (RFC 6551, 2.1).
The object classes had no extract_padding, so the first object kept
the rest of the list as its payload: a container with ETX and Hop
Count dissected as one ETX object followed by raw bytes. End each
object after its Length octets of body, or after its declared fields
if those are longer, so the next one starts there. Body octets beyond
the declared fields, such as a second Link Color, stay in the object's
payload.

AI-Assisted: yes (Claude Opus 5.5, GPT-6.1 Sol)
RFC 6551 (4.4.1) allows Link Color only as a recorded metric, so the
test object sets the R flag.

AI-Assisted: yes (Claude Opus 5.5, GPT-6.1 Sol)
@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.56%. Comparing base (eec9267) to head (264c01e).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5272   +/-   ##
=======================================
  Coverage   80.56%   80.56%           
=======================================
  Files         375      375           
  Lines       98508    98511    +3     
=======================================
+ Hits        79361    79365    +4     
+ Misses      19147    19146    -1     
Files with missing lines Coverage Δ
scapy/contrib/rpl_metrics.py 98.68% <100.00%> (+0.05%) ⬆️

... and 3 files with indirect coverage changes

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

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