network: change UseGateway= default to UseRoutes= setting
authorDan Streetman <ddstreet@canonical.com>
Wed, 15 Apr 2020 18:40:21 +0000 (14:40 -0400)
committerMichael Biebl <biebl@debian.org>
Sun, 5 Jul 2020 09:44:39 +0000 (10:44 +0100)
Anyone previously using the UseRoutes=false parameter expected their
dhcp4-provided gateway route to be ignored, as well.  However, with
the introduction of the UseGateway= parameter, this is no longer true.

In order to keep backwards compatibility, this sets the UseGateway=
default value to whatever UseRoutes= has been set to.

(cherry picked from commit 589397a27759bd650b3674029cb0ef73347c913b)

Gbp-Pq: Name network-change-UseGateway-default-to-UseRoutes-setting.patch

man/systemd.network.xml
src/network/networkd-network-gperf.gperf
src/network/networkd-network.c
src/network/networkd-network.h

index 120347d231bbbc11a11207520ac4c2ca1a805422..5175704cadbf81c330ce92aaaf511d2d5a93163d 100644 (file)
         <varlistentry>
           <term><varname>UseGateway=</varname></term>
           <listitem>
-            <para>When true (the default), the gateway will be requested from the DHCP server and added to the
-            routing table with a metric of 1024, and a scope of "link".</para>
+            <para>When true, the gateway will be requested from the DHCP server and added to the routing table with a
+            metric of 1024, and a scope of "link".  When unset, the value specified with <option>UseRoutes=</option>
+            is used.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
index d3dda3df6b103a0c7c17497046c3385a95e165eb..1a07ae96717bf26351368a8c63950a3ab8f4f571 100644 (file)
@@ -162,7 +162,7 @@ DHCPv4.UseMTU,                               config_parse_bool,
 DHCPv4.UseHostname,                          config_parse_bool,                                        0,                             offsetof(Network, dhcp_use_hostname)
 DHCPv4.UseDomains,                           config_parse_dhcp_use_domains,                            0,                             offsetof(Network, dhcp_use_domains)
 DHCPv4.UseRoutes,                            config_parse_bool,                                        0,                             offsetof(Network, dhcp_use_routes)
-DHCPv4.UseGateway,                           config_parse_bool,                                        0,                             offsetof(Network, dhcp_use_gateway)
+DHCPv4.UseGateway,                           config_parse_tristate,                                    0,                             offsetof(Network, dhcp_use_gateway)
 DHCPv4.RequestOptions,                       config_parse_dhcp_request_options,                        0,                             0
 DHCPv4.Anonymize,                            config_parse_bool,                                        0,                             offsetof(Network, dhcp_anonymize)
 DHCPv4.SendHostname,                         config_parse_bool,                                        0,                             offsetof(Network, dhcp_send_hostname)
index c643419142b1f6b1464d0aa112600755d6b6a83c..093d298cd757e1290a45173080142439eef6caf5 100644 (file)
@@ -265,6 +265,9 @@ int network_verify(Network *network) {
                 network->dhcp_use_mtu = false;
         }
 
+        if (network->dhcp_use_gateway < 0)
+                network->dhcp_use_gateway = network->dhcp_use_routes;
+
         if (network->dhcp_critical >= 0) {
                 if (network->keep_configuration >= 0)
                         log_warning("%s: Both KeepConfiguration= and deprecated CriticalConnection= are set. "
@@ -383,7 +386,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
                 .dhcp_use_dns = true,
                 .dhcp_use_hostname = true,
                 .dhcp_use_routes = true,
-                .dhcp_use_gateway = true,
+                .dhcp_use_gateway = -1,
                 /* NOTE: this var might be overwritten by network_apply_anonymize_if_set */
                 .dhcp_send_hostname = true,
                 .dhcp_send_release = true,
index 0d46dbb8de4a1bd8e34bb23752993a0764103b3a..6231618d35db43fec4ff718792e3e48a9f0ff4f7 100644 (file)
@@ -110,7 +110,7 @@ struct Network {
         bool dhcp_use_sip;
         bool dhcp_use_mtu;
         bool dhcp_use_routes;
-        bool dhcp_use_gateway;
+        int dhcp_use_gateway;
         bool dhcp_use_timezone;
         bool rapid_commit;
         bool dhcp_use_hostname;