Merge pull request #24074 from yuwata/network-dhcp6-rapid-commit
network: dhcp6: re-introduce RapidCommit= setting
This commit is contained in:
@@ -71,6 +71,7 @@ struct sd_dhcp6_client {
|
||||
char **vendor_class;
|
||||
OrderedHashmap *extra_options;
|
||||
OrderedSet *vendor_options;
|
||||
bool rapid_commit;
|
||||
|
||||
struct sd_dhcp6_lease *lease;
|
||||
|
||||
|
||||
@@ -491,6 +491,14 @@ int dhcp6_client_set_transaction_id(sd_dhcp6_client *client, uint32_t transactio
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_dhcp6_client_set_rapid_commit(sd_dhcp6_client *client, int enable) {
|
||||
assert_return(client, -EINVAL);
|
||||
assert_return(!sd_dhcp6_client_is_running(client), -EBUSY);
|
||||
|
||||
client->rapid_commit = enable;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_dhcp6_client_get_lease(sd_dhcp6_client *client, sd_dhcp6_lease **ret) {
|
||||
assert_return(client, -EINVAL);
|
||||
|
||||
@@ -714,9 +722,11 @@ int dhcp6_client_send_message(sd_dhcp6_client *client) {
|
||||
break;
|
||||
|
||||
case DHCP6_STATE_SOLICITATION:
|
||||
r = dhcp6_option_append(&opt, &optlen, SD_DHCP6_OPTION_RAPID_COMMIT, 0, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (client->rapid_commit) {
|
||||
r = dhcp6_option_append(&opt, &optlen, SD_DHCP6_OPTION_RAPID_COMMIT, 0, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
r = client_append_common_options_in_managed_mode(client, &opt, &optlen,
|
||||
&client->ia_na, &client->ia_pd);
|
||||
@@ -1160,6 +1170,10 @@ static int client_process_advertise_or_rapid_commit_reply(
|
||||
if (message->type == DHCP6_MESSAGE_REPLY) {
|
||||
bool rapid_commit;
|
||||
|
||||
if (!client->rapid_commit)
|
||||
return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL),
|
||||
"Received unexpected reply message, even we sent a solicit message without the rapid commit option, ignoring.");
|
||||
|
||||
r = dhcp6_lease_get_rapid_commit(lease, &rapid_commit);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@@ -1467,6 +1481,7 @@ int sd_dhcp6_client_new(sd_dhcp6_client **ret) {
|
||||
.ifindex = -1,
|
||||
.request_ia = DHCP6_REQUEST_IA_NA | DHCP6_REQUEST_IA_PD,
|
||||
.fd = -1,
|
||||
.rapid_commit = true,
|
||||
};
|
||||
|
||||
*ret = TAKE_PTR(client);
|
||||
|
||||
@@ -695,6 +695,12 @@ static int dhcp6_configure(Link *link) {
|
||||
return log_link_debug_errno(link, r, "DHCPv6 CLIENT: Failed to set prefix delegation hint: %m");
|
||||
}
|
||||
|
||||
r = sd_dhcp6_client_set_rapid_commit(client, link->network->dhcp6_use_rapid_commit);
|
||||
if (r < 0)
|
||||
return log_link_debug_errno(link, r,
|
||||
"DHCPv6 CLIENT: Failed to %s rapid commit: %m",
|
||||
enable_disable(link->network->dhcp6_use_rapid_commit));
|
||||
|
||||
link->dhcp6_client = TAKE_PTR(client);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -262,6 +262,7 @@ DHCPv6.SendOption, config_parse_dhcp_send_option,
|
||||
DHCPv6.IAID, config_parse_iaid, AF_INET6, 0
|
||||
DHCPv6.DUIDType, config_parse_duid_type, 0, offsetof(Network, dhcp6_duid)
|
||||
DHCPv6.DUIDRawData, config_parse_duid_rawdata, 0, offsetof(Network, dhcp6_duid)
|
||||
DHCPv6.RapidCommit, config_parse_bool, 0, offsetof(Network, dhcp6_use_rapid_commit)
|
||||
IPv6AcceptRA.UseGateway, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_gateway)
|
||||
IPv6AcceptRA.UseRoutePrefix, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_route_prefix)
|
||||
IPv6AcceptRA.UseAutonomousPrefix, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_autonomous_prefix)
|
||||
@@ -555,12 +556,11 @@ DHCP.RouteMetric, config_parse_dhcp_or_ra_route_metri
|
||||
DHCP.RouteTable, config_parse_dhcp_or_ra_route_table, AF_INET, 0
|
||||
DHCP.UseTimezone, config_parse_bool, 0, offsetof(Network, dhcp_use_timezone)
|
||||
DHCP.ListenPort, config_parse_uint16, 0, offsetof(Network, dhcp_client_port)
|
||||
DHCP.RapidCommit, config_parse_warn_compat, DISABLED_LEGACY, 0
|
||||
DHCP.RapidCommit, config_parse_bool, 0, offsetof(Network, dhcp6_use_rapid_commit)
|
||||
DHCP.ForceDHCPv6PDOtherInformation, config_parse_warn_compat, DISABLED_LEGACY, 0
|
||||
DHCPv4.UseDomainName, config_parse_dhcp_use_domains, AF_INET, 0
|
||||
DHCPv4.CriticalConnection, config_parse_tristate, 0, offsetof(Network, dhcp_critical)
|
||||
DHCPv6.RouteMetric, config_parse_dhcp_or_ra_route_metric, AF_INET6, 0
|
||||
DHCPv6.RapidCommit, config_parse_warn_compat, DISABLED_LEGACY, 0
|
||||
DHCPv6.ForceDHCPv6PDOtherInformation, config_parse_warn_compat, DISABLED_LEGACY, 0
|
||||
DHCPv6PrefixDelegation.SubnetId, config_parse_dhcp_pd_subnet_id, 0, offsetof(Network, dhcp_pd_subnet_id)
|
||||
DHCPv6PrefixDelegation.Announce, config_parse_bool, 0, offsetof(Network, dhcp_pd_announce)
|
||||
|
||||
@@ -414,6 +414,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
|
||||
.dhcp6_use_dns = true,
|
||||
.dhcp6_use_hostname = true,
|
||||
.dhcp6_use_ntp = true,
|
||||
.dhcp6_use_rapid_commit = true,
|
||||
.dhcp6_duid.type = _DUID_TYPE_INVALID,
|
||||
.dhcp6_client_start_mode = _DHCP6_CLIENT_START_MODE_INVALID,
|
||||
|
||||
|
||||
@@ -164,6 +164,7 @@ struct Network {
|
||||
bool dhcp6_use_hostname;
|
||||
bool dhcp6_use_ntp;
|
||||
bool dhcp6_use_ntp_set;
|
||||
bool dhcp6_use_rapid_commit;
|
||||
DHCPUseDomains dhcp6_use_domains;
|
||||
bool dhcp6_use_domains_set;
|
||||
uint32_t dhcp6_iaid;
|
||||
|
||||
@@ -262,6 +262,7 @@ int sd_dhcp6_client_set_address_request(sd_dhcp6_client *client,
|
||||
int request);
|
||||
int sd_dhcp6_client_add_vendor_option(sd_dhcp6_client *client,
|
||||
sd_dhcp6_option *v);
|
||||
int sd_dhcp6_client_set_rapid_commit(sd_dhcp6_client *client, int enable);
|
||||
|
||||
int sd_dhcp6_client_get_lease(
|
||||
sd_dhcp6_client *client,
|
||||
|
||||
Reference in New Issue
Block a user