mirror of
https://github.com/systemd/systemd.git
synced 2024-12-23 21:35:11 +03:00
test-network: add tests for erspan version 0 and 2
This commit is contained in:
parent
98406eda8a
commit
2f0260c1bb
15
test/test-network/conf/25-erspan0-tunnel-local-any.netdev
Normal file
15
test/test-network/conf/25-erspan0-tunnel-local-any.netdev
Normal file
@ -0,0 +1,15 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
[NetDev]
|
||||
Name=erspan98
|
||||
Kind=erspan
|
||||
|
||||
[Tunnel]
|
||||
ERSPANVersion=0
|
||||
# The three settings below will be ignored
|
||||
ERSPANIndex=124
|
||||
ERSPANDirection=egress
|
||||
ERSPANHardwareId=0x2f
|
||||
Local = any
|
||||
Remote = 172.16.1.100
|
||||
Key=102
|
||||
SerializeTunneledPackets=true
|
15
test/test-network/conf/25-erspan0-tunnel.netdev
Normal file
15
test/test-network/conf/25-erspan0-tunnel.netdev
Normal file
@ -0,0 +1,15 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
[NetDev]
|
||||
Name=erspan99
|
||||
Kind=erspan
|
||||
|
||||
[Tunnel]
|
||||
ERSPANVersion=0
|
||||
# The three settings below will be ignored
|
||||
ERSPANIndex=123
|
||||
ERSPANDirection=ingress
|
||||
ERSPANHardwareId=0x1f
|
||||
Local = 172.16.1.200
|
||||
Remote = 172.16.1.100
|
||||
Key=101
|
||||
SerializeTunneledPackets=true
|
15
test/test-network/conf/25-erspan1-tunnel-local-any.netdev
Normal file
15
test/test-network/conf/25-erspan1-tunnel-local-any.netdev
Normal file
@ -0,0 +1,15 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
[NetDev]
|
||||
Name=erspan98
|
||||
Kind=erspan
|
||||
|
||||
[Tunnel]
|
||||
ERSPANVersion=1
|
||||
ERSPANIndex=124
|
||||
# The two settings below will be ignored
|
||||
ERSPANDirection=egress
|
||||
ERSPANHardwareId=0x2f
|
||||
Local = any
|
||||
Remote = 172.16.1.100
|
||||
Key=102
|
||||
SerializeTunneledPackets=true
|
15
test/test-network/conf/25-erspan1-tunnel.netdev
Normal file
15
test/test-network/conf/25-erspan1-tunnel.netdev
Normal file
@ -0,0 +1,15 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
[NetDev]
|
||||
Name=erspan99
|
||||
Kind=erspan
|
||||
|
||||
[Tunnel]
|
||||
ERSPANVersion=1
|
||||
ERSPANIndex=123
|
||||
# The two settings below will be ignored
|
||||
ERSPANDirection=ingress
|
||||
ERSPANHardwareId=0x1f
|
||||
Local = 172.16.1.200
|
||||
Remote = 172.16.1.100
|
||||
Key=101
|
||||
SerializeTunneledPackets=true
|
@ -4,7 +4,11 @@ Name=erspan98
|
||||
Kind=erspan
|
||||
|
||||
[Tunnel]
|
||||
ERSPANVersion=2
|
||||
# ERSPANIndex= will be ignored
|
||||
ERSPANIndex=124
|
||||
ERSPANDirection=egress
|
||||
ERSPANHardwareId=0x2f
|
||||
Local = any
|
||||
Remote = 172.16.1.100
|
||||
Key=102
|
@ -4,7 +4,11 @@ Name=erspan99
|
||||
Kind=erspan
|
||||
|
||||
[Tunnel]
|
||||
ERSPANVersion=2
|
||||
# ERSPANIndex= will be ignored
|
||||
ERSPANIndex=123
|
||||
ERSPANDirection=ingress
|
||||
ERSPANHardwareId=0x1f
|
||||
Local = 172.16.1.200
|
||||
Remote = 172.16.1.100
|
||||
Key=101
|
@ -85,9 +85,22 @@ def expectedFailureIfModuleIsNotAvailable(module_name):
|
||||
|
||||
return f
|
||||
|
||||
def expectedFailureIfERSPANModuleIsNotAvailable():
|
||||
def expectedFailureIfERSPANv0IsNotSupported():
|
||||
# erspan version 0 is supported since f989d546a2d5a9f001f6f8be49d98c10ab9b1897 (v5.8)
|
||||
def f(func):
|
||||
rc = call('ip link add dev erspan99 type erspan seq key 30 local 192.168.1.4 remote 192.168.1.1 erspan_ver 1 erspan 123', stderr=subprocess.DEVNULL)
|
||||
rc = call('ip link add dev erspan99 type erspan seq key 30 local 192.168.1.4 remote 192.168.1.1 erspan_ver 0', stderr=subprocess.DEVNULL)
|
||||
if rc == 0:
|
||||
call('ip link del erspan99')
|
||||
return func
|
||||
|
||||
return unittest.expectedFailure(func)
|
||||
|
||||
return f
|
||||
|
||||
def expectedFailureIfERSPANv2IsNotSupported():
|
||||
# erspan version 2 is supported since f551c91de262ba36b20c3ac19538afb4f4507441 (v4.16)
|
||||
def f(func):
|
||||
rc = call('ip link add dev erspan99 type erspan seq key 30 local 192.168.1.4 remote 192.168.1.1 erspan_ver 2', stderr=subprocess.DEVNULL)
|
||||
if rc == 0:
|
||||
call('ip link del erspan99')
|
||||
return func
|
||||
@ -993,8 +1006,12 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
|
||||
'25-bridge.netdev',
|
||||
'25-bridge-configure-without-carrier.network',
|
||||
'25-bridge.network',
|
||||
'25-erspan-tunnel-local-any.netdev',
|
||||
'25-erspan-tunnel.netdev',
|
||||
'25-erspan0-tunnel-local-any.netdev',
|
||||
'25-erspan0-tunnel.netdev',
|
||||
'25-erspan1-tunnel-local-any.netdev',
|
||||
'25-erspan1-tunnel.netdev',
|
||||
'25-erspan2-tunnel-local-any.netdev',
|
||||
'25-erspan2-tunnel.netdev',
|
||||
'25-fou-gretap.netdev',
|
||||
'25-fou-gre.netdev',
|
||||
'25-fou-ipip.netdev',
|
||||
@ -1795,29 +1812,93 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
|
||||
print(output)
|
||||
self.assertRegex(output, '6rd-prefix 2602::/24')
|
||||
|
||||
@expectedFailureIfERSPANModuleIsNotAvailable()
|
||||
def test_erspan_tunnel(self):
|
||||
@expectedFailureIfERSPANv0IsNotSupported()
|
||||
def test_erspan_tunnel_v0(self):
|
||||
copy_unit_to_networkd_unit_path('12-dummy.netdev', '25-erspan.network',
|
||||
'25-erspan-tunnel.netdev', '25-tunnel.network',
|
||||
'25-erspan-tunnel-local-any.netdev', '25-tunnel-local-any.network')
|
||||
'25-erspan0-tunnel.netdev', '25-tunnel.network',
|
||||
'25-erspan0-tunnel-local-any.netdev', '25-tunnel-local-any.network')
|
||||
start_networkd()
|
||||
self.wait_online(['erspan99:routable', 'erspan98:routable', 'dummy98:degraded'])
|
||||
|
||||
output = check_output('ip -d link show erspan99')
|
||||
print(output)
|
||||
self.assertRegex(output, 'erspan remote 172.16.1.100 local 172.16.1.200')
|
||||
self.assertRegex(output, 'ikey 0.0.0.101')
|
||||
self.assertRegex(output, 'okey 0.0.0.101')
|
||||
self.assertRegex(output, 'iseq')
|
||||
self.assertRegex(output, 'oseq')
|
||||
self.assertIn('erspan remote 172.16.1.100 local 172.16.1.200', output)
|
||||
self.assertIn('erspan_ver 0', output)
|
||||
self.assertNotIn('erspan_index 123', output)
|
||||
self.assertNotIn('erspan_dir ingress', output)
|
||||
self.assertNotIn('erspan_hwid 1f', output)
|
||||
self.assertIn('ikey 0.0.0.101', output)
|
||||
self.assertIn('iseq', output)
|
||||
output = check_output('ip -d link show erspan98')
|
||||
print(output)
|
||||
self.assertRegex(output, 'erspan remote 172.16.1.100 local any')
|
||||
self.assertRegex(output, '102')
|
||||
self.assertRegex(output, 'ikey 0.0.0.102')
|
||||
self.assertRegex(output, 'okey 0.0.0.102')
|
||||
self.assertRegex(output, 'iseq')
|
||||
self.assertRegex(output, 'oseq')
|
||||
self.assertIn('erspan remote 172.16.1.100 local any', output)
|
||||
self.assertIn('erspan_ver 0', output)
|
||||
self.assertNotIn('erspan_index 124', output)
|
||||
self.assertNotIn('erspan_dir egress', output)
|
||||
self.assertNotIn('erspan_hwid 2f', output)
|
||||
self.assertIn('ikey 0.0.0.102', output)
|
||||
self.assertIn('iseq', output)
|
||||
|
||||
def test_erspan_tunnel_v1(self):
|
||||
copy_unit_to_networkd_unit_path('12-dummy.netdev', '25-erspan.network',
|
||||
'25-erspan1-tunnel.netdev', '25-tunnel.network',
|
||||
'25-erspan1-tunnel-local-any.netdev', '25-tunnel-local-any.network')
|
||||
start_networkd()
|
||||
self.wait_online(['erspan99:routable', 'erspan98:routable', 'dummy98:degraded'])
|
||||
|
||||
output = check_output('ip -d link show erspan99')
|
||||
print(output)
|
||||
self.assertIn('erspan remote 172.16.1.100 local 172.16.1.200', output)
|
||||
self.assertIn('erspan_ver 1', output)
|
||||
self.assertIn('erspan_index 123', output)
|
||||
self.assertNotIn('erspan_dir ingress', output)
|
||||
self.assertNotIn('erspan_hwid 1f', output)
|
||||
self.assertIn('ikey 0.0.0.101', output)
|
||||
self.assertIn('okey 0.0.0.101', output)
|
||||
self.assertIn('iseq', output)
|
||||
self.assertIn('oseq', output)
|
||||
output = check_output('ip -d link show erspan98')
|
||||
print(output)
|
||||
self.assertIn('erspan remote 172.16.1.100 local any', output)
|
||||
self.assertIn('erspan_ver 1', output)
|
||||
self.assertIn('erspan_index 124', output)
|
||||
self.assertNotIn('erspan_dir egress', output)
|
||||
self.assertNotIn('erspan_hwid 2f', output)
|
||||
self.assertIn('ikey 0.0.0.102', output)
|
||||
self.assertIn('okey 0.0.0.102', output)
|
||||
self.assertIn('iseq', output)
|
||||
self.assertIn('oseq', output)
|
||||
|
||||
@expectedFailureIfERSPANv2IsNotSupported()
|
||||
def test_erspan_tunnel_v2(self):
|
||||
copy_unit_to_networkd_unit_path('12-dummy.netdev', '25-erspan.network',
|
||||
'25-erspan2-tunnel.netdev', '25-tunnel.network',
|
||||
'25-erspan2-tunnel-local-any.netdev', '25-tunnel-local-any.network')
|
||||
start_networkd()
|
||||
self.wait_online(['erspan99:routable', 'erspan98:routable', 'dummy98:degraded'])
|
||||
|
||||
output = check_output('ip -d link show erspan99')
|
||||
print(output)
|
||||
self.assertIn('erspan remote 172.16.1.100 local 172.16.1.200', output)
|
||||
self.assertIn('erspan_ver 2', output)
|
||||
self.assertNotIn('erspan_index 123', output)
|
||||
self.assertIn('erspan_dir ingress', output)
|
||||
self.assertIn('erspan_hwid 0x1f', output)
|
||||
self.assertIn('ikey 0.0.0.101', output)
|
||||
self.assertIn('okey 0.0.0.101', output)
|
||||
self.assertIn('iseq', output)
|
||||
self.assertIn('oseq', output)
|
||||
output = check_output('ip -d link show erspan98')
|
||||
print(output)
|
||||
self.assertIn('erspan remote 172.16.1.100 local any', output)
|
||||
self.assertIn('erspan_ver 2', output)
|
||||
self.assertNotIn('erspan_index 124', output)
|
||||
self.assertIn('erspan_dir egress', output)
|
||||
self.assertIn('erspan_hwid 0x2f', output)
|
||||
self.assertIn('ikey 0.0.0.102', output)
|
||||
self.assertIn('okey 0.0.0.102', output)
|
||||
self.assertIn('iseq', output)
|
||||
self.assertIn('oseq', output)
|
||||
|
||||
def test_tunnel_independent(self):
|
||||
copy_unit_to_networkd_unit_path('25-ipip-tunnel-independent.netdev', '26-netdev-link-local-addressing-yes.network')
|
||||
|
Loading…
Reference in New Issue
Block a user