Options: Preserve v6 vendclass CLI optarg when parsing enterprise number - #725
Options: Preserve v6 vendclass CLI optarg when parsing enterprise number #725nbromberg-dn wants to merge 1 commit into
vendclass CLI optarg when parsing enterprise number #725Conversation
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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. WalkthroughThe vendor class option parser now copies the enterprise-number prefix before parsing it. This prevents modification of the original argument during later per-interface option replays. ChangesVendor class parsing
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to Vendor-class arguments now retain their data while the enterprise number is parsed, so repeated interface configuration can encode and transmit the configured vendor class correctly. The change is ready to merge. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| if (fp) | ||
| *fp++ = '\0'; | ||
| u = (uint32_t)strtou(arg, NULL, 0, 0, UINT32_MAX, &e); | ||
| bp = NULL; |
There was a problem hiding this comment.
bp may not be the best variable for this purpose, wdyt?
There was a problem hiding this comment.
For code readability, bp seems to be used specifically to parsing bit flags.
You may want to add another pointer for this class of data.
fp for field pointer
bp for bit flag pointer
np for network pointer (addresses and such)
dp for byte data pointer?
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)
| if (fp) | ||
| *fp++ = '\0'; | ||
| u = (uint32_t)strtou(arg, NULL, 0, 0, UINT32_MAX, &e); | ||
| bp = NULL; |
There was a problem hiding this comment.
For code readability, bp seems to be used specifically to parsing bit flags.
You may want to add another pointer for this class of data.
fp for field pointer
bp for bit flag pointer
np for network pointer (addresses and such)
dp for byte data pointer?
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: