8000 Fix DPID zero-padding when dpid includes a 0x prefix by anandhx · Pull Request #1257 · mininet/mininet · GitHub
[go: up one dir, main page]

Skip to content

Fix DPID zero-padding when dpid includes a 0x prefix - #1257

Open
anandhx wants to merge 1 commit into
mininet:masterfrom
anandhx:fix/dpid-hex-prefix-padding
Open

anandhx wants to merge 1 commit into
mininet:masterfrom
anandhx:fix/dpid-hex-prefix-padding

Conversation

@anandhx
@anandhx anandhx commented Nov 6, 2026
Copy link
Copy Markdown

Summary

  • Fixes invalid DPID generation when callers pass Python hex() strings such as '0x2'.
  • Previously, zero-padding kept the 0x characters and produced values like 00000000000000x2, which later crash with ValueError during int(dpid, 16).
  • Normalize via int(dpid, 16) / format(..., 'x') before padding.

Test plan

  • Switch.defaultDpid('0x2') returns a zero-padded hex string without x
  • Colon-separated DPIDs (e.g. 00:00:00:00:00:00:00:02) still work
  • Default name-derived DPIDs (s1 → ...1) unchanged
  • Starting a switch with dpid=hex(2) no longer raises ValueError

Fixes #684

Normalize dpid through int(..., 16) before zero-padding so values like
hex(2) ('0x2') become '000...002' instead of the invalid '000...00x2'.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

Fix DPID hex string validation and/or allow python hex() strings

1 participant

0