query->getCiaddr().isV4Zero()) {
response->setFlags(BOOTP_BROADCAST);
}
+ // DHCPNAK to a client on a different subnet: the client may not
+ // have a correct network address or subnet mask, and may not be
+ // answering ARP requests, so set the broadcast bit to amke the
+ // relay to broadcast the DHCPNAK to the client.
+ if ((query->getType() == DHCPREQUEST) &&
+ (response->getType() == DHCPNAK)) {
+ response->setFlags(BOOTP_BROADCAST);
+ }
response->setRemoteAddr(query->getGiaddr());
// If giaddr is 0 but client set ciaddr, server should unicast the
auto resp = client.getContext().response_;
ASSERT_TRUE(resp);
EXPECT_EQ(DHCPNAK, static_cast<int>(resp->getType()));
+ // The DHCPNAK is relayed and its broadcast flag is set.
+ EXPECT_TRUE(resp->isRelayed());
+ EXPECT_EQ(BOOTP_BROADCAST, resp->getFlags());
}
TEST_F(DORATest, authoritativeSubnetSelectionFail) {