diff options
author | William A. Kennington III <william@wkennington.com> | 2019-04-19 02:52:28 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-08-07 13:32:36 +0200 |
commit | 0b1cd3e25abccdb1112d71995d1915696a233baf (patch) | |
tree | 4f8234f4e2194c51313655c757570b5b78dd5b67 /test | |
parent | Merge pull request #13265 from keszybz/timedated-ntp-logging (diff) | |
download | systemd-0b1cd3e25abccdb1112d71995d1915696a233baf.tar.xz systemd-0b1cd3e25abccdb1112d71995d1915696a233baf.zip |
networkd: Routes should take the gateway into account
Otherwise, changing the default gateway doesn't purge old gateway routes
left on the system during daemon restart. This also fixes removing other
foreign gateway routes that don't match the expected configuration.
Tested:
Changed gateway addresses prior to the patch and they lingered on
the system during each reconfiguration. Applied this patch and
reconfigured gateways and other routes multiple times and it removed
the foreign routes that had gateways that didn't match.
Signed-off-by: William A. Kennington III <william@wkennington.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/test-network/conf/25-gateway-next-static.network | 6 | ||||
-rw-r--r-- | test/test-network/conf/25-gateway-static.network | 6 | ||||
-rwxr-xr-x | test/test-network/systemd-networkd-tests.py | 22 |
3 files changed, 34 insertions, 0 deletions
diff --git a/test/test-network/conf/25-gateway-next-static.network b/test/test-network/conf/25-gateway-next-static.network new file mode 100644 index 0000000000..dfac8f48cd --- /dev/null +++ b/test/test-network/conf/25-gateway-next-static.network @@ -0,0 +1,6 @@ +[Match] +Name=dummy98 + +[Network] +Address=149.10.124.58/28 +Gateway=149.10.124.60 diff --git a/test/test-network/conf/25-gateway-static.network b/test/test-network/conf/25-gateway-static.network new file mode 100644 index 0000000000..448a21f2b9 --- /dev/null +++ b/test/test-network/conf/25-gateway-static.network @@ -0,0 +1,6 @@ +[Match] +Name=dummy98 + +[Network] +Address=149.10.124.58/28 +Gateway=149.10.124.59 diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 76313cf026..f133bf4462 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -1430,6 +1430,8 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): '25-link-section-unmanaged.network', '25-route-ipv6-src.network', '25-route-static.network', + '25-gateway-static.network', + '25-gateway-next-static.network', '25-sysctl-disable-ipv6.network', '25-sysctl.network', 'configure-without-carrier.network', @@ -1632,6 +1634,26 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): print(output) self.assertRegex(output, 'prohibit 202.54.1.4 proto static') + def test_gateway_reconfigure(self): + copy_unit_to_networkd_unit_path('25-gateway-static.network', '12-dummy.netdev') + start_networkd() + self.wait_online(['dummy98:routable']) + print('### ip -4 route show dev dummy98 default') + output = check_output('ip -4 route show dev dummy98 default') + print(output) + self.assertRegex(output, 'default via 149.10.124.59 proto static') + self.assertNotRegex(output, '149.10.124.60') + + remove_unit_from_networkd_path(['25-gateway-static.network']) + copy_unit_to_networkd_unit_path('25-gateway-next-static.network') + restart_networkd(3) + self.wait_online(['dummy98:routable']) + print('### ip -4 route show dev dummy98 default') + output = check_output('ip -4 route show dev dummy98 default') + print(output) + self.assertNotRegex(output, '149.10.124.59') + self.assertRegex(output, 'default via 149.10.124.60 proto static') + def test_ip_route_ipv6_src_route(self): # a dummy device does not make the addresses go through tentative state, so we # reuse a bond from an earlier test, which does make the addresses go through |