mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-10 01:17:44 +03:00
Merge pull request #9262 from ssahani/ignore-carrier-9111
networkd: allow to retain configs even if carrier is lost
This commit is contained in:
commit
19df3047f3
@ -800,6 +800,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>
|
||||
|
@ -3565,6 +3565,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. */
|
||||
|
@ -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
|
||||
|
@ -224,6 +224,7 @@ struct Network {
|
||||
int allmulticast;
|
||||
bool unmanaged;
|
||||
bool configure_without_carrier;
|
||||
bool ignore_carrier_loss;
|
||||
uint32_t iaid;
|
||||
DUID duid;
|
||||
|
||||
|
@ -116,6 +116,7 @@ VLAN=
|
||||
DHCPServer=
|
||||
BindCarrier=
|
||||
VRF=
|
||||
IgnoreCarrierLoss=
|
||||
[IPv6Prefix]
|
||||
Prefix=
|
||||
OnLink=
|
||||
|
@ -0,0 +1,7 @@
|
||||
[Match]
|
||||
Name=bridge99
|
||||
|
||||
[Network]
|
||||
Address=192.168.0.15/24
|
||||
Gateway=192.168.0.1
|
||||
IgnoreCarrierLoss=true
|
@ -1009,6 +1009,7 @@ class NetworkdNetWorkBridgeTests(unittest.TestCase, Utilities):
|
||||
'26-bridge.netdev',
|
||||
'26-bridge-slave-interface-1.network',
|
||||
'26-bridge-slave-interface-2.network',
|
||||
'bridge99-ignore-carrier-loss.network',
|
||||
'bridge99.network']
|
||||
|
||||
def setUp(self):
|
||||
@ -1054,6 +1055,42 @@ class NetworkdNetWorkBridgeTests(unittest.TestCase, Utilities):
|
||||
if (os.path.exists('/sys/devices/virtual/net/bridge00/lower_dummy98/brport/multicast_to_unicast')):
|
||||
self.assertEqual(self.read_bridge_port_attr('bridge99', 'dummy98', 'multicast_to_unicast'), '1')
|
||||
|
||||
self.assertEqual(subprocess.call(['ip', 'address', 'add', '192.168.0.16/24', 'dev', 'bridge99']), 0)
|
||||
time.sleep(1)
|
||||
|
||||
self.assertEqual(subprocess.call(['ip', 'link', 'del', 'test1']), 0)
|
||||
self.assertEqual(subprocess.call(['ip', 'link', 'del', 'dummy98']), 0)
|
||||
time.sleep(3)
|
||||
|
||||
output = subprocess.check_output(['ip', 'address', 'show', 'bridge99']).rstrip().decode('utf-8')
|
||||
print(output)
|
||||
self.assertRegex(output, 'NO-CARRIER')
|
||||
self.assertNotRegex(output, '192.168.0.15/24')
|
||||
self.assertNotRegex(output, '192.168.0.16/24')
|
||||
|
||||
def test_bridge_ignore_carrier_loss(self):
|
||||
self.copy_unit_to_networkd_unit_path('11-dummy.netdev', '12-dummy.netdev', '26-bridge.netdev',
|
||||
'26-bridge-slave-interface-1.network', '26-bridge-slave-interface-2.network',
|
||||
'bridge99-ignore-carrier-loss.network')
|
||||
self.start_networkd()
|
||||
|
||||
self.assertTrue(self.link_exits('dummy98'))
|
||||
self.assertTrue(self.link_exits('test1'))
|
||||
self.assertTrue(self.link_exits('bridge99'))
|
||||
|
||||
self.assertEqual(subprocess.call(['ip', 'address', 'add', '192.168.0.16/24', 'dev', 'bridge99']), 0)
|
||||
time.sleep(1)
|
||||
|
||||
self.assertEqual(subprocess.call(['ip', 'link', 'del', 'test1']), 0)
|
||||
self.assertEqual(subprocess.call(['ip', 'link', 'del', 'dummy98']), 0)
|
||||
time.sleep(3)
|
||||
|
||||
output = subprocess.check_output(['ip', 'address', 'show', 'bridge99']).rstrip().decode('utf-8')
|
||||
print(output)
|
||||
self.assertRegex(output, 'NO-CARRIER')
|
||||
self.assertRegex(output, 'inet 192.168.0.15/24 brd 192.168.0.255 scope global bridge99')
|
||||
self.assertRegex(output, 'inet 192.168.0.16/24 scope global secondary bridge99')
|
||||
|
||||
class NetworkdNetWorkLLDPTests(unittest.TestCase, Utilities):
|
||||
links = ['veth99']
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user