summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-11-07 17:33:43 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-11-07 18:42:03 +0100
commit1fa0a4eff719430de8ec15baa38ea697c7579ea2 (patch)
tree8d908fe392b2f88101af31786a2ec10b0180e0ae
parentsd-dhcp-server: support rapid commit (RFC4039) (diff)
downloadsystemd-1fa0a4eff719430de8ec15baa38ea697c7579ea2.tar.xz
systemd-1fa0a4eff719430de8ec15baa38ea697c7579ea2.zip
network: add [DHCPServer] RapidCommit= setting
-rw-r--r--man/systemd.network.xml12
-rw-r--r--src/network/networkd-dhcp-server.c5
-rw-r--r--src/network/networkd-network-gperf.gperf1
-rw-r--r--src/network/networkd-network.c1
-rw-r--r--src/network/networkd-network.h1
5 files changed, 20 insertions, 0 deletions
diff --git a/man/systemd.network.xml b/man/systemd.network.xml
index 3e83caaf18..fe8c8a14c6 100644
--- a/man/systemd.network.xml
+++ b/man/systemd.network.xml
@@ -3768,6 +3768,18 @@ ServerAddress=192.168.0.1/24</programlisting>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><varname>RapidCommit=</varname></term>
+ <listitem>
+ <para>Takes a boolean. When true, the server supports
+ <ulink url="https://datatracker.ietf.org/doc/html/rfc4039">RFC 4039</ulink>. When a client sends
+ a DHCPDISCOVER message with the Rapid Commit option to the server, then the server will reply with
+ a DHCPACK message to the client, instead of DHCPOFFER. Defaults to true.</para>
+
+ <xi:include href="version-info.xml" xpointer="v255"/>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</refsect1>
diff --git a/src/network/networkd-dhcp-server.c b/src/network/networkd-dhcp-server.c
index 17939ce54a..607fe0053c 100644
--- a/src/network/networkd-dhcp-server.c
+++ b/src/network/networkd-dhcp-server.c
@@ -418,6 +418,11 @@ static int dhcp4_server_configure(Link *link) {
if (r < 0)
return log_link_warning_errno(link, r, "Failed to set boot filename for DHCPv4 server instance: %m");
+ r = sd_dhcp_server_set_rapid_commit(link->dhcp_server, link->network->dhcp_server_rapid_commit);
+ if (r < 0)
+ return log_link_warning_errno(link, r, "Failed to %s Rapid Commit support for DHCPv4 server instance: %m",
+ enable_disable(link->network->dhcp_server_rapid_commit));
+
for (sd_dhcp_lease_server_type_t type = 0; type < _SD_DHCP_LEASE_SERVER_TYPE_MAX; type ++) {
if (!link->network->dhcp_server_emit[type].emit)
diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf
index 080f72dc2c..628b1ad19f 100644
--- a/src/network/networkd-network-gperf.gperf
+++ b/src/network/networkd-network-gperf.gperf
@@ -342,6 +342,7 @@ DHCPServer.BindToInterface, config_parse_bool,
DHCPServer.BootServerAddress, config_parse_in_addr_non_null, AF_INET, offsetof(Network, dhcp_server_boot_server_address)
DHCPServer.BootServerName, config_parse_dns_name, 0, offsetof(Network, dhcp_server_boot_server_name)
DHCPServer.BootFilename, config_parse_string, CONFIG_PARSE_STRING_SAFE_AND_ASCII, offsetof(Network, dhcp_server_boot_filename)
+DHCPServer.RapidCommit, config_parse_bool, 0, offsetof(Network, dhcp_server_rapid_commit)
DHCPServerStaticLease.Address, config_parse_dhcp_static_lease_address, 0, 0
DHCPServerStaticLease.MACAddress, config_parse_dhcp_static_lease_hwaddr, 0, 0
Bridge.Cost, config_parse_uint32, 0, offsetof(Network, cost)
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index fbda52f8f3..72ed2abd95 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -428,6 +428,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
.dhcp_server_emit[SD_DHCP_LEASE_SIP].emit = true,
.dhcp_server_emit_router = true,
.dhcp_server_emit_timezone = true,
+ .dhcp_server_rapid_commit = true,
.router_lifetime_usec = RADV_DEFAULT_ROUTER_LIFETIME_USEC,
.router_dns_lifetime_usec = RADV_DEFAULT_VALID_LIFETIME_USEC,
diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h
index 021e7f9182..4995e55b53 100644
--- a/src/network/networkd-network.h
+++ b/src/network/networkd-network.h
@@ -228,6 +228,7 @@ struct Network {
char *dhcp_server_boot_server_name;
char *dhcp_server_boot_filename;
usec_t dhcp_server_ipv6_only_preferred_usec;
+ bool dhcp_server_rapid_commit;
/* link-local addressing support */
AddressFamily link_local;