diff options
author | Dan Streetman <ddstreet@canonical.com> | 2020-07-02 16:20:25 -0400 |
---|---|---|
committer | Dan Streetman <ddstreet@canonical.com> | 2020-07-02 16:20:25 -0400 |
commit | 9a12a31a62f1a50cd3a67a164ee34c546809815e (patch) | |
tree | b026a0c3b7fe433e5279fb9ea95edf71f737fe4b | |
parent | c8f7cf02da238a2e2e93564816e9053920211544 (diff) |
Add IgnoreCarrierLoss and default to value of ConfigureWithoutCarrier
LP: #1860926
3 files changed, 153 insertions, 0 deletions
diff --git a/debian/patches/lp1860926/0001-networkd-Allow-to-retain-configs-even-if-carrier-is-.patch b/debian/patches/lp1860926/0001-networkd-Allow-to-retain-configs-even-if-carrier-is-.patch new file mode 100644 index 0000000000..251335eebb --- /dev/null +++ b/debian/patches/lp1860926/0001-networkd-Allow-to-retain-configs-even-if-carrier-is-.patch @@ -0,0 +1,75 @@ +From 93b4dab57e2e13bd804cbee999241be65a443e2e Mon Sep 17 00:00:00 2001 +From: Susant Sahani <susant@redhat.com> +Date: Fri, 1 Jun 2018 15:04:49 +0530 +Subject: [PATCH] networkd: Allow to retain configs even if carrier is lost +Bug: https://github.com/systemd/systemd/issues/9111 +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/bionic/+source/systemd/+bug/1860926 +Origin: upstream, https://github.com/systemd/systemd/commit/93b4dab57e2e13bd804cbee999241be65a443e2e + +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 | 9 +++++++++ + src/network/networkd-link.c | 3 +++ + src/network/networkd-network-gperf.gperf | 1 + + src/network/networkd-network.h | 1 + + test/fuzz/fuzz-network-parser/directives.network | 1 + + 5 files changed, 15 insertions(+) + +--- a/man/systemd.network.xml ++++ b/man/systemd.network.xml +@@ -775,6 +775,15 @@ + </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> +--- a/src/network/networkd-link.c ++++ b/src/network/networkd-link.c +@@ -3392,6 +3392,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. */ +--- a/src/network/networkd-network-gperf.gperf ++++ b/src/network/networkd-network-gperf.gperf +@@ -77,6 +77,7 @@ Network.ProxyARP, + 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 +--- a/src/network/networkd-network.h ++++ b/src/network/networkd-network.h +@@ -226,6 +226,7 @@ struct Network { + int arp; + bool unmanaged; + bool configure_without_carrier; ++ bool ignore_carrier_loss; + uint32_t iaid; + DUID duid; + diff --git a/debian/patches/lp1860926/0002-network-Change-IgnoreCarrierLoss-default-to-value-of.patch b/debian/patches/lp1860926/0002-network-Change-IgnoreCarrierLoss-default-to-value-of.patch new file mode 100644 index 0000000000..786ebf9348 --- /dev/null +++ b/debian/patches/lp1860926/0002-network-Change-IgnoreCarrierLoss-default-to-value-of.patch @@ -0,0 +1,76 @@ +From b520a35de0f1ad99f30fa3e1e9b02cc2d4832971 Mon Sep 17 00:00:00 2001 +From: Dan Streetman <ddstreet@canonical.com> +Date: Mon, 27 Apr 2020 06:38:40 -0400 +Subject: [PATCH 1/3] network: Change IgnoreCarrierLoss default to value of + ConfigureWithoutCarrier +Origin: upstream, https://github.com/systemd/systemd/pull/15619 +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1860926 + +It doesn't make much sense to have ConfigureWithoutCarrier set, but not +IgnoreCarrierLoss; all the configuration added during initial interface +bring-up will be lost at the first carrier up/down. +--- + man/systemd.network.xml | 5 +++-- + src/network/networkd-network-gperf.gperf | 2 +- + src/network/networkd-network.c | 5 +++++ + src/network/networkd-network.h | 2 +- + 4 files changed, 10 insertions(+), 4 deletions(-) + +--- a/man/systemd.network.xml ++++ b/man/systemd.network.xml +@@ -778,8 +778,9 @@ + <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>Takes a boolean. Allows networkd to retain both the static and dynamic configuration ++ of the interface even if its carrier is lost. When unset, the value specified with ++ <option>ConfigureWithoutCarrier=</option> is used. + </para> + </listitem> + </varlistentry> +--- a/src/network/networkd-network-gperf.gperf ++++ b/src/network/networkd-network-gperf.gperf +@@ -77,7 +77,7 @@ Network.ProxyARP, + 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) ++Network.IgnoreCarrierLoss, config_parse_tristate, 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 +--- a/src/network/networkd-network.c ++++ b/src/network/networkd-network.c +@@ -266,6 +266,9 @@ static int network_load_one(Manager *man + network->ipv6_accept_ra_route_table = RT_TABLE_MAIN; + network->ipv6_mtu = 0; + ++ network->configure_without_carrier = false; ++ network->ignore_carrier_loss = -1; ++ + dropin_dirname = strjoina(network->name, ".network.d"); + + r = config_parse_many(filename, network_dirs, dropin_dirname, +@@ -306,6 +309,9 @@ static int network_load_one(Manager *man + if (network->dhcp_use_gateway < 0) + network->dhcp_use_gateway = network->dhcp_use_routes; + ++ if (network->ignore_carrier_loss < 0) ++ network->ignore_carrier_loss = network->configure_without_carrier; ++ + LIST_PREPEND(networks, manager->networks, network); + + r = hashmap_ensure_allocated(&manager->networks_by_name, &string_hash_ops); +--- a/src/network/networkd-network.h ++++ b/src/network/networkd-network.h +@@ -226,7 +226,7 @@ struct Network { + int arp; + bool unmanaged; + bool configure_without_carrier; +- bool ignore_carrier_loss; ++ int ignore_carrier_loss; + uint32_t iaid; + DUID duid; + diff --git a/debian/patches/series b/debian/patches/series index 4fab199450..ce97eb2fb9 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -213,3 +213,5 @@ lp1529152/0003-shell-completion-systemctl-pass-current-word-to-all-.patch lp1529152/0004-bash-completion-systemctl-re-implement-__filter_unit.patch lp1529152/0005-strip-value-from-property-names.patch lp1877159-networkd-fix-attribute-length-for-wireguard-10380.patch +lp1860926/0001-networkd-Allow-to-retain-configs-even-if-carrier-is-.patch +lp1860926/0002-network-Change-IgnoreCarrierLoss-default-to-value-of.patch |