diff options
Diffstat (limited to 'test/test-network/systemd-networkd-tests.py')
-rwxr-xr-x | test/test-network/systemd-networkd-tests.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index a596537ffa..687fda7b3d 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -8034,6 +8034,38 @@ class NetworkdMTUTests(unittest.TestCase, Utilities): copy_network_unit('12-dummy.netdev', '12-dummy-mtu.link', '12-dummy.network.d/ipv6-mtu-1550.conf') self.check_mtu('1600', '1550', reset=False) +class NetworkdSysctlTest(unittest.TestCase, Utilities): + + def setUp(self): + setup_common() + + def tearDown(self): + tear_down_common() + + @unittest.skipUnless(compare_kernel_version("6.12"), reason="On kernels <= 6.12, bpf_current_task_under_cgroup() isn't available for program types BPF_PROG_TYPE_CGROUP_SYSCTL") + def check_sysctl_watch(self): + copy_network_unit('12-dummy.network', '12-dummy.netdev', '12-dummy.link') + start_networkd() + + self.wait_online('dummy98:routable') + + # Change managed sysctls + call('sysctl -w net.ipv6.conf.dummy98.accept_ra=1') + call('sysctl -w net.ipv6.conf.dummy98.mtu=1360') + call('sysctl -w net.ipv4.conf.dummy98.promote_secondaries=0') + call('sysctl -w net.ipv6.conf.dummy98.proxy_ndp=1') + + # And unmanaged ones + call('sysctl -w net.ipv6.conf.dummy98.hop_limit=4') + call('sysctl -w net.ipv6.conf.dummy98.max_addresses=10') + + log=read_networkd_log() + self.assertRegex(log, r"Foreign process 'sysctl\[\d+\]' changed sysctl '/proc/sys/net/ipv6/conf/dummy98/accept_ra' from '0' to '1', conflicting with our setting to '0'") + self.assertRegex(log, r"Foreign process 'sysctl\[\d+\]' changed sysctl '/proc/sys/net/ipv6/conf/dummy98/mtu' from '1550' to '1360', conflicting with our setting to '1550'") + self.assertRegex(log, r"Foreign process 'sysctl\[\d+\]' changed sysctl '/proc/sys/net/ipv4/conf/dummy98/promote_secondaries' from '1' to '0', conflicting with our setting to '1'") + self.assertRegex(log, r"Foreign process 'sysctl\[\d+\]' changed sysctl '/proc/sys/net/ipv6/conf/dummy98/proxy_ndp' from '0' to '1', conflicting with our setting to '0'") + self.assertNotIn("changed sysctl '/proc/sys/net/ipv6/conf/dummy98/hop_limit'", log) + self.assertNotIn("changed sysctl '/proc/sys/net/ipv6/conf/dummy98/max_addresses'", log) if __name__ == '__main__': parser = argparse.ArgumentParser() |