test-network: add tests for FooOverUDP tunnels

This commit is contained in:
Yu Watanabe 2019-03-31 22:04:00 +09:00
parent 0b145817ff
commit 4b6a6d1e37
7 changed files with 113 additions and 0 deletions

View File

@ -0,0 +1,14 @@
[NetDev]
Name=gretun96
Kind=gre
[Tunnel]
Local=10.65.223.238
Remote=10.65.223.239
Key=1.2.5.103
SerializeTunneledPackets=true
Independent=true
FooOverUDP=yes
FOUDestinationPort=55556
FOUSourcePort=1001

View File

@ -0,0 +1,13 @@
[NetDev]
Name=gretap96
Kind=gretap
[Tunnel]
Local=10.65.223.238
Remote=10.65.223.239
Key=1.2.5.106
SerializeTunneledPackets=true
Independent=true
FooOverUDP=yes
FOUDestinationPort=55556

View File

@ -0,0 +1,12 @@
[NetDev]
Name=ipiptun96
Kind=ipip
MTUBytes=1480
[Tunnel]
Local=192.168.223.238
Remote=192.169.224.239
Independent=true
FooOverUDP=yes
FOUDestinationPort=55555

View File

@ -0,0 +1,8 @@
[NetDev]
Name=fou98
Kind=fou
[FooOverUDP]
Encapsulation=FooOverUDP
Port=55556
Protocol=GRE

View File

@ -0,0 +1,8 @@
[NetDev]
Name=fou99
Kind=fou
[FooOverUDP]
Encapsulation=FooOverUDP
Port=55555
Protocol=ipip

View File

@ -0,0 +1,11 @@
[NetDev]
Name=sittun96
Kind=sit
[Tunnel]
Local=10.65.223.238
Remote=10.65.223.239
Independent=true
FooOverUDP=yes
FOUDestinationPort=55555

View File

@ -201,8 +201,10 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
'erspan98',
'erspan99',
'geneve99',
'gretap96',
'gretap98',
'gretap99',
'gretun96',
'gretun97',
'gretun98',
'gretun99',
@ -214,6 +216,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
'ip6tnl97',
'ip6tnl98',
'ip6tnl99',
'ipiptun96',
'ipiptun97',
'ipiptun98',
'ipiptun99',
@ -221,6 +224,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
'isataptun99',
'macvlan99',
'macvtap99',
'sittun96',
'sittun97',
'sittun98',
'sittun99',
@ -257,6 +261,12 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
'25-bridge.netdev',
'25-erspan-tunnel-local-any.netdev',
'25-erspan-tunnel.netdev',
'25-fou-gretap.netdev',
'25-fou-gre.netdev',
'25-fou-ipip.netdev',
'25-fou-ipproto-gre.netdev',
'25-fou-ipproto-ipip.netdev',
'25-fou-sit.netdev',
'25-geneve.netdev',
'25-gretap-tunnel-local-any.netdev',
'25-gretap-tunnel.netdev',
@ -786,6 +796,43 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
self.assertTrue(self.link_exits('ipiptun99'))
@expectedFailureIfModuleIsNotAvailable('fou')
def test_fou(self):
# The following redundant check is necessary for CentOS CI.
# Maybe, error handling in lookup_id() in sd-netlink/generic-netlink.c needs to be updated.
self.assertTrue(is_module_available('fou'))
self.copy_unit_to_networkd_unit_path('25-fou-ipproto-ipip.netdev', '25-fou-ipproto-gre.netdev',
'25-fou-ipip.netdev', '25-fou-sit.netdev',
'25-fou-gre.netdev', '25-fou-gretap.netdev')
self.start_networkd()
self.assertTrue(self.link_exits('ipiptun96'))
self.assertTrue(self.link_exits('sittun96'))
self.assertTrue(self.link_exits('gretun96'))
self.assertTrue(self.link_exits('gretap96'))
output = subprocess.check_output(['ip', 'fou', 'show']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, 'port 55555 ipproto 4')
self.assertRegex(output, 'port 55556 ipproto 47')
output = subprocess.check_output(['ip', '-d', 'link', 'show', 'ipiptun96']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, 'encap fou encap-sport auto encap-dport 55555')
output = subprocess.check_output(['ip', '-d', 'link', 'show', 'sittun96']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, 'encap fou encap-sport auto encap-dport 55555')
output = subprocess.check_output(['ip', '-d', 'link', 'show', 'gretun96']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, 'encap fou encap-sport 1001 encap-dport 55556')
output = subprocess.check_output(['ip', '-d', 'link', 'show', 'gretap96']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, 'encap fou encap-sport auto encap-dport 55556')
subprocess.call(['ip', 'fou', 'del', 'port', '55555'])
subprocess.call(['ip', 'fou', 'del', 'port', '55556'])
def test_vxlan(self):
self.copy_unit_to_networkd_unit_path('25-vxlan.netdev', 'vxlan.network', '11-dummy.netdev')
self.start_networkd()