mirror of
https://github.com/systemd/systemd.git
synced 2024-12-26 03:22:00 +03:00
sd-dhcp-server: also send DNS servers or friends on DHCPOFFER
From RFC 2131 section 4.3.1 (https://www.rfc-editor.org/rfc/rfc2131#section-4.3.1): ---- The server MUST return to the client: - Parameters requested by the client, according to the following rules: -- IF the server has been explicitly configured with a default value for the parameter, the server MUST include that value in an appropriate option in the 'option' field, ---- The sentence is not only for ACK, but for all (positive) responses, that is DHCPOFFER and DHCPACK. Fixes #27471.
This commit is contained in:
parent
d5e6c4be91
commit
0c3ea0c222
@ -564,6 +564,15 @@ static int server_send_offer_or_ack(
|
||||
be32_t address,
|
||||
uint8_t type) {
|
||||
|
||||
static const uint8_t option_map[_SD_DHCP_LEASE_SERVER_TYPE_MAX] = {
|
||||
[SD_DHCP_LEASE_DNS] = SD_DHCP_OPTION_DOMAIN_NAME_SERVER,
|
||||
[SD_DHCP_LEASE_NTP] = SD_DHCP_OPTION_NTP_SERVER,
|
||||
[SD_DHCP_LEASE_SIP] = SD_DHCP_OPTION_SIP_SERVER,
|
||||
[SD_DHCP_LEASE_POP3] = SD_DHCP_OPTION_POP3_SERVER,
|
||||
[SD_DHCP_LEASE_SMTP] = SD_DHCP_OPTION_SMTP_SERVER,
|
||||
[SD_DHCP_LEASE_LPR] = SD_DHCP_OPTION_LPR_SERVER,
|
||||
};
|
||||
|
||||
_cleanup_free_ DHCPPacket *packet = NULL;
|
||||
sd_dhcp_option *j;
|
||||
be32_t lease_time;
|
||||
@ -619,38 +628,26 @@ static int server_send_offer_or_ack(
|
||||
return r;
|
||||
}
|
||||
|
||||
if (type == DHCP_ACK) {
|
||||
static const uint8_t option_map[_SD_DHCP_LEASE_SERVER_TYPE_MAX] = {
|
||||
[SD_DHCP_LEASE_DNS] = SD_DHCP_OPTION_DOMAIN_NAME_SERVER,
|
||||
[SD_DHCP_LEASE_NTP] = SD_DHCP_OPTION_NTP_SERVER,
|
||||
[SD_DHCP_LEASE_SIP] = SD_DHCP_OPTION_SIP_SERVER,
|
||||
[SD_DHCP_LEASE_POP3] = SD_DHCP_OPTION_POP3_SERVER,
|
||||
[SD_DHCP_LEASE_SMTP] = SD_DHCP_OPTION_SMTP_SERVER,
|
||||
[SD_DHCP_LEASE_LPR] = SD_DHCP_OPTION_LPR_SERVER,
|
||||
};
|
||||
for (sd_dhcp_lease_server_type_t k = 0; k < _SD_DHCP_LEASE_SERVER_TYPE_MAX; k++) {
|
||||
if (server->servers[k].size <= 0)
|
||||
continue;
|
||||
|
||||
for (sd_dhcp_lease_server_type_t k = 0; k < _SD_DHCP_LEASE_SERVER_TYPE_MAX; k++) {
|
||||
if (server->servers[k].size <= 0)
|
||||
continue;
|
||||
r = dhcp_option_append(
|
||||
&packet->dhcp, req->max_optlen, &offset, 0,
|
||||
option_map[k],
|
||||
sizeof(struct in_addr) * server->servers[k].size,
|
||||
server->servers[k].addr);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
r = dhcp_option_append(
|
||||
&packet->dhcp, req->max_optlen, &offset, 0,
|
||||
option_map[k],
|
||||
sizeof(struct in_addr) * server->servers[k].size,
|
||||
server->servers[k].addr);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
if (server->timezone) {
|
||||
r = dhcp_option_append(
|
||||
&packet->dhcp, req->max_optlen, &offset, 0,
|
||||
SD_DHCP_OPTION_TZDB_TIMEZONE,
|
||||
strlen(server->timezone), server->timezone);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
if (server->timezone) {
|
||||
r = dhcp_option_append(
|
||||
&packet->dhcp, req->max_optlen, &offset, 0,
|
||||
SD_DHCP_OPTION_TZDB_TIMEZONE,
|
||||
strlen(server->timezone), server->timezone);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
ORDERED_SET_FOREACH(j, server->extra_options) {
|
||||
|
Loading…
Reference in New Issue
Block a user