networkd: DHCPv6 client allow to configure Rapid Commit (#6930)
authorSusant Sahani <145210+ssahani@users.noreply.github.com>
Mon, 22 Jan 2018 08:09:18 +0000 (13:39 +0530)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 22 Jan 2018 08:09:18 +0000 (17:09 +0900)
The DHCPv6 client can obtain configuration parameters from a
DHCPv6 server through a rapid two-message exchange solicit and reply).
When the rapid commit option is enabled by both the DHCPv6 client and
the DHCPv6 server, the two-message exchange is used, rather than the default
four-method exchange (solicit, advertise, request, and reply). The two-message
exchange provides faster client configuration and is beneficial in environments
in which networks are under a heavy load.

Closes #5845

man/systemd.network.xml
src/libsystemd-network/sd-dhcp6-client.c
src/network/networkd-dhcp6.c
src/network/networkd-network-gperf.gperf
src/network/networkd-network.c
src/network/networkd-network.h

index dfd9ea2..80d2802 100644 (file)
             <para>Allow setting custom port for the DHCP client to listen on.</para>
           </listitem>
         </varlistentry>
+
+        <varlistentry>
+          <term><varname>RapidCommit=</varname></term>
+          <listitem>
+            <para>A boolean. The DHCPv6 client can obtain configuration parameters from a DHCPv6 server through
+            a rapid two-message exchange (solicit and reply). When the rapid commit option is enabled by both
+            the DHCPv6 client and the DHCPv6 server, the two-message exchange is used, rather than the default
+            four-method exchange (solicit, advertise, request, and reply). The two-message exchange provides
+            faster client configuration and is beneficial in environments in which networks are under a heavy load.
+            See <ulink url="https://tools.ietf.org/html/rfc3315#section-17.2.1">RFC 3315</ulink> for details.
+            Defaults to true.</para>
+          </listitem>
+        </varlistentry>
+
       </variablelist>
     </refsect1>
 
index f98a182..6ff8712 100644 (file)
@@ -282,6 +282,7 @@ int sd_dhcp6_client_set_request_option(sd_dhcp6_client *client, uint16_t option)
         case SD_DHCP6_OPTION_DOMAIN_LIST:
         case SD_DHCP6_OPTION_SNTP_SERVERS:
         case SD_DHCP6_OPTION_NTP_SERVER:
+        case SD_DHCP6_OPTION_RAPID_COMMIT:
                 break;
 
         default:
index d54fb05..234e0a4 100644 (file)
@@ -471,10 +471,11 @@ static int dhcp6_set_hostname(sd_dhcp6_client *client, Link *link) {
 
 int dhcp6_configure(Link *link) {
         sd_dhcp6_client *client = NULL;
-        int r;
         const DUID *duid;
+        int r;
 
         assert(link);
+        assert(link->network);
 
         if (link->dhcp6_client)
                 return 0;
@@ -513,6 +514,12 @@ int dhcp6_configure(Link *link) {
         if (r < 0)
                 goto error;
 
+        if (link->network->rapid_commit) {
+                r = sd_dhcp6_client_set_request_option(client, SD_DHCP6_OPTION_RAPID_COMMIT);
+                if (r < 0)
+                        goto error;
+        }
+
         r = sd_dhcp6_client_set_callback(client, dhcp6_handler, link);
         if (r < 0)
                 goto error;
index 6181f35..281ba65 100644 (file)
@@ -131,6 +131,7 @@ DHCP.RouteTable,                        config_parse_dhcp_route_table,
 DHCP.UseTimezone,                       config_parse_bool,                              0,                             offsetof(Network, dhcp_use_timezone)
 DHCP.IAID,                              config_parse_iaid,                              0,                             offsetof(Network, iaid)
 DHCP.ListenPort,                        config_parse_uint16,                            0,                             offsetof(Network, dhcp_client_port)
+DHCP.RapidCommit,                       config_parse_bool,                              0,                             offsetof(Network, rapid_commit)
 IPv6AcceptRA.UseDNS,                    config_parse_bool,                              0,                             offsetof(Network, ipv6_accept_ra_use_dns)
 IPv6AcceptRA.UseDomains,                config_parse_dhcp_use_domains,                  0,                             offsetof(Network, ipv6_accept_ra_use_domains)
 IPv6AcceptRA.RouteTable,                config_parse_uint32,                            0,                             offsetof(Network, ipv6_accept_ra_route_table)
index b037fc6..2dc3de3 100644 (file)
@@ -228,6 +228,7 @@ static int network_load_one(Manager *manager, const char *filename) {
         network->dhcp_use_mtu = false;
         /* NOTE: from man: UseTimezone=... Defaults to "no".*/
         network->dhcp_use_timezone = false;
+        network->rapid_commit = true;
 
         network->dhcp_server_emit_dns = true;
         network->dhcp_server_emit_ntp = true;
index ad56fc5..7b40ba5 100644 (file)
@@ -148,6 +148,7 @@ struct Network {
         bool dhcp_use_mtu;
         bool dhcp_use_routes;
         bool dhcp_use_timezone;
+        bool rapid_commit;
         bool dhcp_use_hostname;
         bool dhcp_route_table_set;
         DHCPUseDomains dhcp_use_domains;