Skip to content

Generator: Don't rewrite non-6-byte fixed-size 1x: types to PhysAddress48#1648

Merged
SuperQ merged 1 commit into
prometheus:mainfrom
lukeod:physaddress-rewrite-size-gate
Jul 3, 2026
Merged

Generator: Don't rewrite non-6-byte fixed-size 1x: types to PhysAddress48#1648
SuperQ merged 1 commit into
prometheus:mainfrom
lukeod:physaddress-rewrite-size-gate

Conversation

@lukeod

@lukeod lukeod commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

The generator rewrites any node with DISPLAY-HINT 1x: to PhysAddress48, and the collector's PhysAddress48 branch always consumes exactly 6 bytes. When the underlying textual convention is a fixed-size octet string of another length, the index is parsed at the wrong length and every index after it at the wrong offset. For example, ELTEX-LTP8X::ONTSerial (OCTET STRING (SIZE (8)), hint 1x:) is used as a table index: only 6 of its 8 bytes are consumed, and the remaining 2 corrupt whatever index follows. Values are affected too, rendering only their first 6 bytes.

This change gates the rewrite on the parsed fixed size: nodes are rewritten only when the size is 6 or unknown. Keeping size-unknown nodes is deliberate - some MAC conventions have no single fixed size for net-snmp to report, e.g. MacAddressNC from RFC 2024 (OCTET STRING (SIZE (0 | 6)), same hint), and dropping those would change existing generated configs for actual MAC addresses.

Affected nodes now stay OctetString: indexes align correctly, and rendering becomes hex (0x...) instead of a mis-sized MAC-style string.

Out of scope: 1x: conventions whose size net-snmp doesn't report at the TC level (genuinely variable-size ones like LldpV2ManAddress, or sizes refined on the OBJECT-TYPE rather than the TC) still get rewritten and mis-parse when longer than 6 bytes. Those can't be told apart here from MAC conventions whose size simply isn't reported.

This is part of a series of PRs preparing for generator integration of display_hint on indexes (#1610, alongside #1646). Once the rewrite no longer captures non-6-byte conventions, those indexes stay OctetString, where the collector can apply the MIB's DISPLAY-HINT and render them as formatted strings rather than raw hex.

Fixed-size octet string types other than 6 bytes were rewritten to
PhysAddress48, which parses exactly 6 index bytes and misaligns any
subsequent indexes.

Signed-off-by: lukeod <l.odonnell11@gmail.com>

@SuperQ SuperQ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice, thanks.

@SuperQ SuperQ merged commit 67a8528 into prometheus:main Jul 3, 2026
13 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