]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
networkd: add test to ensure that untracked addresses are kept
authorMatteo Croce <teknoraver@meta.com>
Mon, 19 May 2025 03:46:50 +0000 (05:46 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 20 May 2025 12:14:53 +0000 (14:14 +0200)
Users can alter the network configuration manually, but networkd should
not interfere with manually set addresses and routes.

test/test-network/systemd-networkd-tests.py

index dbc4589aa2d173428326fe515affb9eebf77cc84..fbf5354eb58994fc6523a148d170537863ec8e8e 100755 (executable)
@@ -5063,6 +5063,31 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
 
             print('### ip monitor dev dummy98 END')
 
+    def test_keep_untracked_addresses(self):
+        # Add an unmanaged interface with an up address
+
+        copy_network_unit('12-dummy.netdev', '85-static-ipv6.network')
+        start_networkd()
+        self.wait_online('dummy98:routable')
+
+        print('### ip -4 addr add 10.234.77.111/32 dev dummy98')
+        output = check_output('ip -4 addr add 10.234.77.111/32 dev dummy98')
+        print(output)
+
+        print('### ip -6 addr add 2222:3333::4444/64 dev dummy98')
+        output = check_output('ip -6 addr add 2222:3333::4444/64 dev dummy98')
+        print(output)
+
+        restart_networkd()
+
+        output = check_output('ip -4 addr show dev dummy98')
+        print(output)
+        self.assertRegex(output, 'inet 10\.234\.77\.111/32.*dummy98')
+
+        output = check_output('ip -6 addr show dev dummy98')
+        print(output)
+        self.assertRegex(output, 'inet6 2222:3333::4444/64 scope global')
+
     def check_nexthop(self, manage_foreign_nexthops, first):
         self.wait_online('veth99:routable', 'veth-peer:routable', 'dummy98:routable')