[Toybox] [PATCH] dhcp: Add a new option to unset broadcast bit

Zikai Chen chenzikai at google.com
Wed Oct 1 15:48:29 PDT 2025


Hi Rob,

Unsetting the broadcast bit does not mean sending unicast discover.
The discover (and request) from the client is still broadcast. Only the
offer and ack responses from the server becomes unicast. The client
is still able to recognize the responses from its L2 address.

I tested this with dhcpd (not toybox's dhcpd though) and it worked quite
well.
It also solved our pain points because somehow in some of our environments,
the broadcast server responses cannot be relayed. Only unicast can do.

The code is sync'ed to our internal codebase three weeks ago.
I guess the external one is not updated yet.

Zikai

On Thu, Oct 2, 2025 at 6:43 AM Rob Landley <rob at landley.net> wrote:

> On 9/3/25 10:56, Zikai Chen wrote:
> > Hi,
> >
> > I'm using the dhcp client in Android, and I need the functionality that
> the
> > dhcp client can trigger unicast dhcp offer/ack from the server, so I
> added
> > a new option to the dhcp client.
>
> I'm trying to put together a release so I'm reviewing the commits since
> last time, and... how does this work?
>
> @@ -996,7 +999,7 @@ static int dhcpc_sendmsg(int msgtype)
>     // Handle the message specific settings
>     switch (msgtype) {
>     case DHCPDISCOVER: // Broadcast DISCOVER message to all servers
> -    state->pdhcp.flags = htons(BOOTP_BROADCAST); //  Broadcast bit.
> +    state->pdhcp.flags = htons(broadcast_bit);
>       if (toys.optflags & FLAG_r) {
>         inet_aton(TT.req_ip, &rqsd);
>         pend = dhcpc_addreqipaddr(&rqsd, pend);
>
> If your discover doesn't have the broadcast bit set, how does it know
> where the dhcp server lives?
>
> Presumably the server is sending a packet back via ethernet address
> (does toybox's dhcpd know how to do that?) but how did the request get
> to the dhcp server in the first place if it wasn't broadcast?
>
> Did you test this? Does it work for you? (Nothing on
> https://android.googlesource.com/platform/external/toybox/ has been
> updated in the past 6 months.)
>
> Rob
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20251002/b23780fe/attachment.htm>


More information about the Toybox mailing list