]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: change UseGateway= default to UseRoutes= setting
authorDan Streetman <ddstreet@canonical.com>
Wed, 15 Apr 2020 18:40:21 +0000 (14:40 -0400)
committerDan Streetman <ddstreet@canonical.com>
Tue, 21 Apr 2020 20:56:48 +0000 (16:56 -0400)
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.

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

index 75a581816d3877c4336376dc095df04f879a98b4..864dd6500b3ca079c2621542678a8cd6c2cc6a33 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 9597176b1c678fe710f41c12af8ea3092d533dcb..1a37c4ac9e75f318451ca9713df9d948bee9cb8c 100644 (file)
@@ -164,7 +164,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 9edf9e15616d7c93db39cbebeb6db160b2fc0070..d9646a21cba844626c6861ae7818ab1d9029ef17 100644 (file)
@@ -267,6 +267,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. "
@@ -385,7 +388,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 240f6689dd2ba4532cf56aaf07ac883cb96bb4c4..26656861436e8a8f29b8d6eb208295681bb514d4 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;