test: Add comprehensive tests for MultiPathRoute device-only syntax

Add unit tests for config_parse_multipath_route() covering the new
device-only nexthop syntax (@device). Tests verify basic parsing of
device-only routes, gateway with device routes, gateway-only routes,
interface index handling, etc. Also some checks on new hash/duplicate
semantics.

Also add an integration test to verify device-only multipath routes are
correctly installed in the kernel routing table.
This commit is contained in:
Chris Down
2025-11-28 19:09:15 +08:00
parent 645b709a38
commit 23d02f6327
3 changed files with 173 additions and 0 deletions
@@ -115,3 +115,8 @@ Peer=1.1.8.104/31
[Route]
Gateway=1.1.8.104
[Route]
Destination=192.168.20.0/24
MultiPathRoute=@test1 15
MultiPathRoute=@dummy98 25
@@ -4391,6 +4391,13 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
self.assertIn('via 2001:1234:5:8fff:ff:ff:ff:ff dev dummy98', output)
self.assertIn('via 2001:1234:5:9fff:ff:ff:ff:ff dev dummy98', output)
print('### ip route show 192.168.20.0/24')
output = check_output('ip route show 192.168.20.0/24')
print(output)
self.assertIn('192.168.20.0/24 proto static', output)
self.assertIn('nexthop dev test1 weight 15', output)
self.assertIn('nexthop dev dummy98 weight 25', output)
check_json(networkctl_json())
def _check_unreachable_routes_removed(self):