networkd: Allow to retain configs even if carrier is lost
authorSusant Sahani <susant@redhat.com>
Fri, 1 Jun 2018 09:34:49 +0000 (15:04 +0530)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 6 Feb 2019 12:35:11 +0000 (13:35 +0100)
When there is bad link in the network the carrier goes up/down.
This makes networkd stops all the clients and drop config.
But if the remote router/dhcpserver running a prevention
of DHCP Starvation attack or DHCP Flood attack it does not allow
networkd to take a DHCP lease resulting failure in configuration.
This patch allows to keep the client running and keep the conf
also for this scenario.

Closes #9111

man/systemd.network.xml
src/network/networkd-link.c
src/network/networkd-network-gperf.gperf
src/network/networkd-network.h
test/fuzz/fuzz-network-parser/directives.network

index ee464ff..25a6bc1 100644 (file)
           </para>
         </listitem>
       </varlistentry>
+      <varlistentry>
+        <term><varname>IgnoreCarrierLoss=</varname></term>
+        <listitem>
+          <para>A boolean. Allows networkd to retain both the static and dynamic configuration of the
+          interface even if its carrier is lost. Defaults to false.
+          </para>
+        </listitem>
+      </varlistentry>
+
       </variablelist>
 
   </refsect1>
index 736373a..463c207 100644 (file)
@@ -3500,6 +3500,9 @@ static int link_carrier_lost(Link *link) {
 
         assert(link);
 
+        if (link->network->ignore_carrier_loss)
+                return 0;
+
         /* Some devices reset itself while setting the MTU. This causes the DHCP client fall into a loop.
          * setting_mtu keep track whether the device got reset because of setting MTU and does not drop the
          * configuration and stop the clients as well. */
index 5d8aede..0a0c24c 100644 (file)
@@ -81,6 +81,7 @@ Network.ProxyARP,                       config_parse_tristate,
 Network.IPv6ProxyNDPAddress,            config_parse_ipv6_proxy_ndp_address,            0,                             0
 Network.BindCarrier,                    config_parse_strv,                              0,                             offsetof(Network, bind_carrier)
 Network.ConfigureWithoutCarrier,        config_parse_bool,                              0,                             offsetof(Network, configure_without_carrier)
+Network.IgnoreCarrierLoss,              config_parse_bool,                              0,                             offsetof(Network, ignore_carrier_loss)
 Address.Address,                        config_parse_address,                           0,                             0
 Address.Peer,                           config_parse_address,                           0,                             0
 Address.Broadcast,                      config_parse_broadcast,                         0,                             0
index f6e62cd..d1cdba5 100644 (file)
@@ -224,6 +224,7 @@ struct Network {
         int allmulticast;
         bool unmanaged;
         bool configure_without_carrier;
+        bool ignore_carrier_loss;
         uint32_t iaid;
         DUID duid;
 
index 209132f..3fb785b 100644 (file)
@@ -116,6 +116,7 @@ VLAN=
 DHCPServer=
 BindCarrier=
 VRF=
+IgnoreCarrierLoss=
 [IPv6Prefix]
 Prefix=
 OnLink=