* [PATCH] dhcp: put option 53 at the beginning
@ 2023-10-03 8:01 Stas Sergeev
2023-10-05 6:19 ` Stefano Brivio
0 siblings, 1 reply; 2+ messages in thread
From: Stas Sergeev @ 2023-10-03 8:01 UTC (permalink / raw)
To: passt-dev; +Cc: Stas Sergeev
... unless it is listed in 55.
Many clients expect option 53 at the beginning.
mTCP has this code:
if ( resp->options[0] != 53 ) {
TRACE_WARN(( "Dhcp: first option was not a Dhcp msg type\n" ));
return;
}
wattcp32 has this:
static int DHCP_is_ack (void)
{
const BYTE *opt = (const BYTE*) &dhcp_in.dh_opt[4];
return (opt[0] == DHCP_OPT_MSG_TYPE && opt[1] == 1 && opt[2] == DHCP_ACK);
}
static int DHCP_is_nack (void)
{
const BYTE *opt = (const BYTE*) &dhcp_in.dh_opt[4];
return (opt[0] == DHCP_OPT_MSG_TYPE && opt[1] == 1 && opt[2] == DHCP_NAK);
}
Link: https://bugs.passt.top/show_bug.cgi?id=77
Signed-off-by: Stas Sergeev <stsp2@yandex.ru>
---
dhcp.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/dhcp.c b/dhcp.c
index 46c258e..eed1b4a 100644
--- a/dhcp.c
+++ b/dhcp.c
@@ -149,6 +149,12 @@ static int fill(struct msg *m)
for (o = 0; o < 255; o++)
opts[o].sent = 0;
+ /* Some clients (wattcp32, mTCP, maybe some other) expect
+ * options 53 at the beginning of the list.
+ * Put it there explicitly, unless requested via option 55.
+ */
+ if (!memchr(opts[55].c, 53, opts[55].clen))
+ fill_one(m, 53, &offset);
for (i = 0; i < opts[55].clen; i++) {
o = opts[55].c[i];
if (opts[o].slen)
--
@@ -149,6 +149,12 @@ static int fill(struct msg *m)
for (o = 0; o < 255; o++)
opts[o].sent = 0;
+ /* Some clients (wattcp32, mTCP, maybe some other) expect
+ * options 53 at the beginning of the list.
+ * Put it there explicitly, unless requested via option 55.
+ */
+ if (!memchr(opts[55].c, 53, opts[55].clen))
+ fill_one(m, 53, &offset);
for (i = 0; i < opts[55].clen; i++) {
o = opts[55].c[i];
if (opts[o].slen)
--
2.40.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] dhcp: put option 53 at the beginning
2023-10-03 8:01 [PATCH] dhcp: put option 53 at the beginning Stas Sergeev
@ 2023-10-05 6:19 ` Stefano Brivio
0 siblings, 0 replies; 2+ messages in thread
From: Stefano Brivio @ 2023-10-05 6:19 UTC (permalink / raw)
To: Stas Sergeev; +Cc: passt-dev
On Tue, 3 Oct 2023 13:01:22 +0500
Stas Sergeev <stsp2@yandex.ru> wrote:
> ... unless it is listed in 55.
> Many clients expect option 53 at the beginning.
> mTCP has this code:
> if ( resp->options[0] != 53 ) {
> TRACE_WARN(( "Dhcp: first option was not a Dhcp msg type\n" ));
> return;
> }
>
> wattcp32 has this:
> static int DHCP_is_ack (void)
> {
> const BYTE *opt = (const BYTE*) &dhcp_in.dh_opt[4];
>
> return (opt[0] == DHCP_OPT_MSG_TYPE && opt[1] == 1 && opt[2] == DHCP_ACK);
> }
> static int DHCP_is_nack (void)
> {
> const BYTE *opt = (const BYTE*) &dhcp_in.dh_opt[4];
>
> return (opt[0] == DHCP_OPT_MSG_TYPE && opt[1] == 1 && opt[2] == DHCP_NAK);
> }
>
> Link: https://bugs.passt.top/show_bug.cgi?id=77
> Signed-off-by: Stas Sergeev <stsp2@yandex.ru>
Applied, thanks!
--
Stefano
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-10-05 6:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-03 8:01 [PATCH] dhcp: put option 53 at the beginning Stas Sergeev
2023-10-05 6:19 ` Stefano Brivio
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).