networkctl,networkd: add --no-reconfigure flag to networkctl reload

Add a new --no-reconfigure flag to 'networkctl reload' that reloads
.network and .netdev files from disk without reconfiguring any network
interfaces. This may be useful to avoid reconfiguring multiple interfaces
simultaneously when multiple .network files are updated, or when an updated
.network file is applied to multiple interfaces.

On the networkd side, manager_reload() gains a reconfigure_links parameter
that gates the per-link reconfiguration loop. A new io.systemd.Network.Reload
varlink method is added that exposes this as an optional reconfigureLinks
boolean (defaults to true). Both plain 'networkctl reload' and
'--no-reconfigure' now unconditionally call this method first. If an older
networkd returns MethodNotFound, plain reload falls back to
io.systemd.service.Reload for backward compatibility; '--no-reconfigure'
fails with a clear error in that case.
This commit is contained in:
Nandakumar Raghavan
2026-07-20 14:35:04 +09:00
committed by Yu Watanabe
parent 1166f4472d
commit 13aec9fddf
15 changed files with 133 additions and 22 deletions
@@ -1699,6 +1699,35 @@ class NetworkctlTests(unittest.TestCase, Utilities):
networkctl_reload()
self.wait_operstate('test1', 'degraded')
def test_reload_no_reconfigure(self):
copy_network_unit('12-dummy.netdev', '25-address-static.network', copy_dropins=False)
start_networkd()
self.wait_online('dummy98:routable')
output = check_output('ip -4 address show dev dummy98')
print(output)
self.assertIn('inet 10.1.2.3/16 brd 10.1.255.255 scope global dummy98', output)
with open(
os.path.join(network_unit_dir, '25-address-static.network'), mode='w', encoding='utf-8'
) as f:
f.write('[Match]\nName=dummy98\n\n[Network]\nIPv6AcceptRA=no\nAddress=10.99.0.1/24\n')
networkctl('reload', '--no-reconfigure')
output = check_output('ip -4 address show dev dummy98')
print(output)
self.assertIn('inet 10.1.2.3/16 brd 10.1.255.255 scope global dummy98', output)
self.assertNotIn('inet 10.99.0.1/24', output)
networkctl_reconfigure('dummy98')
self.wait_online('dummy98:routable')
output = check_output('ip -4 address show dev dummy98')
print(output)
self.assertIn('inet 10.99.0.1/24 brd 10.99.0.255 scope global dummy98', output)
self.assertNotIn('inet 10.1.2.3/16', output)
def test_glob(self):
copy_network_unit('11-dummy.netdev', '11-dummy.network')
start_networkd()