Repository navigation
Options: Preserve v6 vendclass CLI optarg when parsing enterprise number - #725
nbromberg-dn wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughThe vendor class option parser copies the enterprise-number prefix before parsing it. It leaves the original argument unchanged for later per-interface option replay. ChangesVendor class parsing
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to
|
The vendclass parser split the enterprise number from its class data by writing a NUL into optarg. dhcpcd applies command-line options more than once: first while processing global options, then again when each interface is configured. That made the first pass succeed because it kept a local pointer to the bytes after the separator, but it permanently shortened the shared argv string to the enterprise number for later passes. Parse the enterprise number from a temporary NUL-terminated copy instead, leaving argv intact so the per-interface pass can still see and encode the vendor-class data. (cherry picked from commit 261851a from NetworkConfiguration#725)
The vendclass parser split the enterprise number from its class data by writing a NUL into optarg. dhcpcd applies command-line options more than once: first while processing global options, then again when each interface is configured. That made the first pass succeed because it kept a local pointer to the bytes after the separator, but it permanently shortened the shared argv string to the enterprise number for later passes. Parse the enterprise number from a temporary NUL-terminated copy instead, leaving argv intact so the per-interface pass can still see and encode the vendor-class data.
261851a to
eb70f4d
Compare
|
Thanks @ColinMcInnes for the approval. |
The issue
When passing
--vendclass '<EN> <DATA>'via CLI arguments, the packet itself is sent with empty data (only with the EN).The
vendclassparser split the enterprise number from its class data by writing aNULintooptarg.The command-line options are applied more than once: first while processing global options, then again when configuring each interface.
That made the first pass succeed because it kept a local pointer to the bytes after the separator, but it permanently shortened the shared
argvstring to the EN for later passes.Example
Calling
Transmitted on the wire (dissected using
tshark):Live-debugging with GDB confirms:
The proposed fix
Parse the enterprise number from a temporary NUL-terminated copy instead, leaving
argvintact so the per-interface pass can still see and encode the vendor-class data.fpstill advances viastrskipwhiteinto the vendor-class portion - behavior matches the old in-place split without mutating shared optarg.With this fix, calling the same
dhcpcdcommand as above now trasmits:And GDB showing: