network: several fixlets for NDisc (#42218)

Unfortunately, previously the path to test-ndisc-send has been wrong, so
some test cases have not been checked in our mkosi CIs. And two test
cases have been broken.

The test case `test_ndisc_redirect` was not updated when the logic in
networkd was changed by 9142bd5a8e. The
change itself should be OK. So, the test case is updated.

The test case `test_ndisc_mtu` was broken when the commit
32417c1723 is merged. The commit is not
correct, as we cannot set IPv6 MTU larger than interface MTU. So, the
offending commit is reverted.
This commit is contained in:
Luca Boccassi
2026-05-21 12:05:34 +01:00
committed by GitHub
2 changed files with 26 additions and 5 deletions
+3 -3
View File
@@ -545,11 +545,11 @@ int link_set_ipv6_mtu(Link *link, int log_level) {
if (mtu == 0)
return 0;
if (mtu > link->max_mtu) {
if (mtu > link->mtu) {
log_link_full(link, log_level,
"Reducing requested IPv6 MTU %"PRIu32" to the interface's maximum MTU %"PRIu32".",
mtu, link->max_mtu);
mtu = link->max_mtu;
mtu, link->mtu);
mtu = link->mtu;
}
r = sysctl_write_ip_property_uint32(AF_INET6, link->ifname, "mtu", mtu, manager_get_sysctl_shadow(link->manager));
+23 -2
View File
@@ -7592,15 +7592,36 @@ class NetworkdRATests(unittest.TestCase, Utilities):
timeout_sec=10,
)
print('### before sending NA without router flag')
output = check_output('ip -6 route show dev veth99')
print(output)
self.assertIn('2002:da8:1::/64 proto ra', output)
self.assertIn('2002:da8:2::/64 proto ra', output)
self.assertRegex(output, 'default .* proto ra')
self.assertRegex(output, '2002:da8:1:1:1a:2b:3c:4d .* proto redirect')
self.assertRegex(output, '2002:da8:1:2:1a:2b:3c:4d .* proto redirect')
self.assertIn('2002:da8:1:3:1a:2b:3c:4d proto redirect', output)
# Send Neighbor Advertisement without the router flag to announce the default router is not available
# anymore. Then, verify that all redirect routes and the default route are dropped.
output = check_output('ip -6 address show dev veth-peer scope link')
veth_peer_ipv6ll = re.search('fe80:[:0-9a-f]*', output).group()
print(f'veth-peer IPv6LL address: {veth_peer_ipv6ll}')
check_output(f'{test_ndisc_send} --interface veth-peer --type neighbor-advertisement --target-address {veth_peer_ipv6ll} --is-router no') # fmt: skip
self.wait_route_dropped('veth99', 'proto ra', ipv='-6', timeout_sec=10)
self.wait_route_dropped('veth99', 'default .* proto ra', ipv='-6', timeout_sec=10)
self.wait_route_dropped('veth99', 'proto redirect', ipv='-6', timeout_sec=10)
# Check if the non-default routes are unchanged, and others are actually dropped.
print('### after sending NA without router flag')
output = check_output('ip -6 route show dev veth99')
print(output)
self.assertIn('2002:da8:1::/64 proto ra', output)
self.assertIn('2002:da8:2::/64 proto ra', output)
self.assertNotRegex(output, 'default .* proto ra')
self.assertNotRegex(output, '2002:da8:1:1:1a:2b:3c:4d .* proto redirect')
self.assertNotRegex(output, '2002:da8:1:2:1a:2b:3c:4d .* proto redirect')
self.assertNotIn('2002:da8:1:3:1a:2b:3c:4d proto redirect', output)
# Check if sd-radv refuses RS from the same interface.
# See https://github.com/systemd/systemd/pull/32267#discussion_r1566721306
since = datetime.datetime.now()
@@ -11096,7 +11117,7 @@ if __name__ == '__main__':
if build_dir:
test_ndisc_send = os.path.normpath(os.path.join(build_dir, 'test-ndisc-send'))
else:
test_ndisc_send = '/usr/lib/tests/test-ndisc-send'
test_ndisc_send = '/usr/lib/systemd/tests/unit-tests/manual/test-ndisc-send'
if build_dir:
test_modem_manager_mock = os.path.normpath(os.path.join(build_dir, 'test-modem-manager-mock'))