-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DHCPv6: Add support for sending Option 17 (VSIO) #383
Conversation
Signed-off-by: Stipe Poljak (EXT) <[email protected]>
I recommend adding a few config examples to src/dhcpcd-definitions.conf |
No problem, but just to double-check, isn't dhcpcd-definitions.conf just for decoding options? This improvement is actually to enable dhcpcd to send those options. |
Good point
Maybe put it in dhcpcd.conf instead. |
Done, updated as requested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good so for, just a few formatting nits.
I'll see if I can find the time to actually test it soon.
nvm, I was being dumb |
The config could potentially be re-used for the same option in DHCP which works in a very similar way, just with different sub option codes in the same EN.
@spoljak-ent @ColinMcInnes I added a change to simplify things, which looks good from here. Does this look OK to everyone? |
This will allow vsio to be used for DHCP in a separate option space.
Looks OK from my side :) |
@spoljak-ent @ColinMcInnes ok, DHCP option 125 now works! It's different from option 43 in that it splits the options via EN. Please test this before I merge, ideally later today. |
Tested with the following configs. DHCPv6: DHCPv4: Edit (again): However for Option 125, every sub-option is immediately split with every enterprise ID while according to RFC 3925, it must contain multiple enterprise IDs with their sub-options within the same option: RFC 3925: My implementation was for that case, however separating into multiple options should be done when the size of the whole option exceeds 255 bytes. From RFC 3925:
And going into RFC 3396 [4]:
|
Ensure everything fits when loading config to make message creation easier.
@spoljak-ent OK, I agree. I've added some code to encode as RFC3396 - not tested that it will overflow the 255 boundary yet though. If you have the time, I'd appreciate it if you could test that. |
@rsmarples Thanks for the update... I'll test it right now. |
Gah, you posted pictures! I'll manually copy into my config and see if I can fix it later. |
Sorry, here's the text: vsio 193 1,"ShortEntry" vsio 193 1,"ShortEntryExample01" |
Note wireshark doesn't decode option 125 correctly when this happens.
@spoljak-ent ok, I've pushed a fix for that, but please note this test data:
Wireshark still thinks it's a malformed packet as it overflows by a few bytes, but the encoding looks correct to me as per https://datatracker.ietf.org/doc/html/rfc3396#section-8 I added another change to easily test small boundaries and it still looks bad in wireshark but looks correct to me. |
I've been looking at this a bit locally with Wireshark... Going back to RFC3396 section 8 which you linked, from what I understood, the split should be done by making a completely new option, taking into account everything that option needs (new total length, enterprise ID and sub-opt length) and then adding the rest of the concatenation. Here the total length is 10, while the subopt length is 11. Tbh, not really sure if Wireshark is taking those lengths into account. |
From section 6:
So the split option is just code and length - anything else is just a blob to be concatenation to the previous blob. We cannot adjust any sub-opt length. From section 7, decoding:
Once re-assembled the sub option lengths are now valid. Note that at the end of the initial wireshark decoded 125 option, you can see another 125 option immediately afterwards and a length. |
I see... You're right. |
Referenced upstream here: https://gitlab.com/wireshark/wireshark/-/issues/20201 |
Thanks! :) |
@rsmarples |
*(*ctx->buf)++ = ctx->code; | ||
ctx->len = (*ctx->buf)++; | ||
*ctx->len = 0; | ||
r += 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we not risk a buffer overrun because we do not adjust ctx->buflen by the two bytes we just inserted? We appear to not account for those two header bytes on each invocation (it seems the same context can be passed in sequential invocations of rfc3396_write), or even if there is a large write, we don't account for those two bytes in each iteration of the loop. We could even have a buffer overrun writing these two bytes because of this miscalculation, although perhaps more likely the overrun happens in the subsequent memcpy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do and this should be fixed in 0f303ab
return -1; | ||
} | ||
|
||
memcpy(*ctx->buf, datap, wlen); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The result being that it is possible to have a buffer overrun here.
My apologies, some lines were not included in #ifndef SMALL
Original pull request:
#374