network: add support for HSR netdev

Add support for creating HSR/PRP interfaces. HSR (High-availability Seamless
Redundancy) and PRP (Parallel Redundancy Protocol) are two protocols that
provide seamless failover against failure of any single network component. They
are both implemented by the "hsr" kernel driver.
This commit is contained in:
Beniamino Galvani
2025-04-05 05:23:53 +09:00
committed by Yu Watanabe
parent c1b0e39ffd
commit f7996e2a33
11 changed files with 276 additions and 1 deletions
+7
View File
@@ -0,0 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[NetDev]
Name=hsr99
Kind=hsr
[HSR]
Ports=test1 dummy98
+6
View File
@@ -0,0 +1,6 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Match]
Name=hsr99
[Network]
IPv6AcceptRA=no
@@ -2057,6 +2057,39 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
networkctl_reload()
self.wait_online('ipvlan99:degraded', 'test1:degraded')
@expectedFailureIfModuleIsNotAvailable('hsr')
def test_hsr(self):
first = True
for proto, supervision in [['hsr', 9], ['prp', 127]]:
if first:
first = False
else:
self.tearDown()
print(f'### test_hsr(proto={proto}, supervision={supervision})')
with self.subTest(proto=proto, supervision=supervision):
copy_network_unit('25-hsr.netdev', '25-hsr.network',
'11-dummy.netdev', '11-dummy.network',
'12-dummy.netdev', '12-dummy-no-address.network')
with open(os.path.join(network_unit_dir, '25-hsr.netdev'), mode='a', encoding='utf-8') as f:
f.write('Protocol=' + proto + '\nSupervision=' + str(supervision))
start_networkd()
self.wait_online('hsr99:degraded')
self.networkctl_check_unit('hsr99', '25-hsr', '25-hsr')
self.networkctl_check_unit('test1', '11-dummy', '11-dummy')
self.networkctl_check_unit('dummy98', '12-dummy', '12-dummy-no-address')
output = check_output('ip -d link show hsr99')
print(output)
self.assertRegex(output, 'hsr slave1 test1 slave2 dummy98')
self.assertRegex(output, f'supervision 01:15:4e:00:01:{supervision:02x}')
self.assertRegex(output, 'proto ' + ('0' if proto == 'hsr' else '1') + ' ')
touch_network_unit('25-hsr.netdev')
networkctl_reload()
self.wait_online('hsr99:degraded')
@expectedFailureIfModuleIsNotAvailable('ipvtap')
def test_ipvtap(self):
first = True