pyke369 / pdhcp

an efficient programmable BOOTP/DHCP client/server/relay
MIT License
19 stars 3 forks source link

Read the broacast flag in the query and use it. #3

Closed xhenner closed 7 years ago

xhenner commented 7 years ago

Be aware of the broadcast flag, see RFC2131 (page 24):

A client that cannot receive unicast IP datagrams until its protocol software has been configured with an IP address SHOULD set the BROADCAST bit in the 'flags' field to 1 in any DHCPDISCOVER or DHCPREQUEST messages that client sends. The BROADCAST bit will provide a hint to the DHCP server and BOOTP relay agent to broadcast any messages to the client on the client's subnet.

We are in a relay setup.

The client (here an UEFI PXE network card) set the BROADCAST bit to 1 in its DHCPDISCOVER message. The juniper gateway forward the message to the pdhcp server, with the bit set to 1

The server replies, but with the bit unset. Then the juniper gateway send the response as an unicast packet which is ignored.

When using a local pdhcp server, since it's not in relay mode, it replies to the broadcast address, regardless of the BROADCAST bit

For our setup to work, pdhcp must read the BROADCAST bit and set it to the same value when used with a relay setup. As a bonus, when used in broadcast mode, it should respect the BROADCAST bit too.

Attached are network dumps of a valid query, and of the issue detected, client side, and pdhcp server side

pdhcpbug.zip

pyke369 commented 7 years ago

Fixed in 1.1.2