diff options
author | Luca Boccassi <bluca@debian.org> | 2022-08-16 23:06:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-16 23:06:16 +0100 |
commit | e4e6cfaad04d93873bc542b072eea2f34e607a01 (patch) | |
tree | fe31df6b9e6fd6362864583f4b21da2665b59a3e /test | |
parent | 21d0ed68eedc47f064a4417126fbd1a38394a843 (diff) | |
parent | ae014ecb3dd8a31286db1316cecf26495a3c75ce (diff) | |
download | systemd-e4e6cfaad04d93873bc542b072eea2f34e607a01.tar.gz |
Merge pull request #24301 from yuwata/network-tuntap
network/tuntap: introduce KeepFileDescriptor= setting
Diffstat (limited to 'test')
-rw-r--r-- | test/fuzz/fuzz-netdev-parser/directives.netdev | 2 | ||||
-rw-r--r-- | test/test-network/conf/25-tap.netdev | 1 | ||||
-rw-r--r-- | test/test-network/conf/25-tun.netdev | 1 | ||||
-rw-r--r-- | test/test-network/conf/26-netdev-link-local-addressing-yes.network | 2 | ||||
-rwxr-xr-x | test/test-network/systemd-networkd-tests.py | 73 |
5 files changed, 76 insertions, 3 deletions
diff --git a/test/fuzz/fuzz-netdev-parser/directives.netdev b/test/fuzz/fuzz-netdev-parser/directives.netdev index d5f3228065..309941f58d 100644 --- a/test/fuzz/fuzz-netdev-parser/directives.netdev +++ b/test/fuzz/fuzz-netdev-parser/directives.netdev @@ -171,6 +171,7 @@ User= Group= PacketInfo= VNetHeader= +KeepCarrier= [IPVLAN] Mode= Flags= @@ -184,6 +185,7 @@ PacketInfo= VNetHeader= Group= User= +KeepCarrier= [NetDev] Kind= MACAddress= diff --git a/test/test-network/conf/25-tap.netdev b/test/test-network/conf/25-tap.netdev index f52d255560..5cbfd0e5b1 100644 --- a/test/test-network/conf/25-tap.netdev +++ b/test/test-network/conf/25-tap.netdev @@ -7,3 +7,4 @@ Kind=tap MultiQueue=true PacketInfo=true VNetHeader=true +KeepCarrier=yes diff --git a/test/test-network/conf/25-tun.netdev b/test/test-network/conf/25-tun.netdev index 8ab2f5a038..a354ebb2b2 100644 --- a/test/test-network/conf/25-tun.netdev +++ b/test/test-network/conf/25-tun.netdev @@ -7,3 +7,4 @@ Kind=tun MultiQueue=true PacketInfo=true VNetHeader=true +KeepCarrier=yes diff --git a/test/test-network/conf/26-netdev-link-local-addressing-yes.network b/test/test-network/conf/26-netdev-link-local-addressing-yes.network index 8ec0190bcb..71521258d3 100644 --- a/test/test-network/conf/26-netdev-link-local-addressing-yes.network +++ b/test/test-network/conf/26-netdev-link-local-addressing-yes.network @@ -22,6 +22,8 @@ Name=nlmon99 Name=xfrm98 xfrm99 Name=vxlan98 Name=hogehogehogehogehogehoge +Name=testtun99 +Name=testtap99 [Network] LinkLocalAddressing=yes diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 3ee734eaf0..c63b21684c 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -13,6 +13,7 @@ import errno import itertools import os import pathlib +import psutil import re import shutil import signal @@ -607,6 +608,9 @@ def restart_networkd(show_logs=True): if show_logs: print(check_output('journalctl _SYSTEMD_INVOCATION_ID=' + invocation_id)) +def networkd_pid(): + return int(check_output('systemctl show --value -p MainPID systemd-networkd.service')) + def networkctl_reconfigure(*links): check_output(*networkctl_cmd, 'reconfigure', *links, env=env) @@ -1321,20 +1325,83 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities): self.assertRegex(output, 'mtu 1800') def test_tuntap(self): - copy_network_unit('25-tun.netdev', '25-tap.netdev') + copy_network_unit('25-tun.netdev', '25-tap.netdev', '26-netdev-link-local-addressing-yes.network') start_networkd() - self.wait_online(['testtun99:off', 'testtap99:off'], setup_state='unmanaged') + self.wait_online(['testtun99:degraded', 'testtap99:degraded']) + + pid = networkd_pid() + name = psutil.Process(pid).name()[:15] + + output = check_output('ip -d tuntap show') + print(output) + self.assertRegex(output, f'(?m)testtap99: tap pi (multi_queue |)vnet_hdr persist filter *(0x100|)\n\tAttached to processes:{name}\({pid}\)systemd\(1\)$') + self.assertRegex(output, f'(?m)testtun99: tun pi (multi_queue |)vnet_hdr persist filter *(0x100|)\n\tAttached to processes:{name}\({pid}\)systemd\(1\)$') output = check_output('ip -d link show testtun99') print(output) # Old ip command does not support IFF_ flags self.assertRegex(output, 'tun (type tun pi on vnet_hdr on multi_queue|addrgenmode) ') + self.assertIn('UP,LOWER_UP', output) output = check_output('ip -d link show testtap99') print(output) - # Old ip command does not support IFF_ flags self.assertRegex(output, 'tun (type tap pi on vnet_hdr on multi_queue|addrgenmode) ') + self.assertIn('UP,LOWER_UP', output) + + remove_network_unit('26-netdev-link-local-addressing-yes.network') + + restart_networkd() + self.wait_online(['testtun99:degraded', 'testtap99:degraded'], setup_state='unmanaged') + + pid = networkd_pid() + name = psutil.Process(pid).name()[:15] + + output = check_output('ip -d tuntap show') + print(output) + self.assertRegex(output, f'(?m)testtap99: tap pi (multi_queue |)vnet_hdr persist filter *(0x100|)\n\tAttached to processes:{name}\({pid}\)systemd\(1\)$') + self.assertRegex(output, f'(?m)testtun99: tun pi (multi_queue |)vnet_hdr persist filter *(0x100|)\n\tAttached to processes:{name}\({pid}\)systemd\(1\)$') + + output = check_output('ip -d link show testtun99') + print(output) + self.assertRegex(output, 'tun (type tun pi on vnet_hdr on multi_queue|addrgenmode) ') + self.assertIn('UP,LOWER_UP', output) + + output = check_output('ip -d link show testtap99') + print(output) + self.assertRegex(output, 'tun (type tap pi on vnet_hdr on multi_queue|addrgenmode) ') + self.assertIn('UP,LOWER_UP', output) + + clear_network_units() + restart_networkd() + self.wait_online(['testtun99:off', 'testtap99:off'], setup_state='unmanaged') + + output = check_output('ip -d tuntap show') + print(output) + self.assertRegex(output, f'(?m)testtap99: tap pi (multi_queue |)vnet_hdr persist filter *(0x100|)\n\tAttached to processes:$') + self.assertRegex(output, f'(?m)testtun99: tun pi (multi_queue |)vnet_hdr persist filter *(0x100|)\n\tAttached to processes:$') + + for i in range(10): + if i != 0: + time.sleep(1) + output = check_output('ip -d link show testtun99') + print(output) + self.assertRegex(output, 'tun (type tun pi on vnet_hdr on multi_queue|addrgenmode) ') + if 'NO-CARRIER' in output: + break + else: + self.fail() + + for i in range(10): + if i != 0: + time.sleep(1) + output = check_output('ip -d link show testtap99') + print(output) + self.assertRegex(output, 'tun (type tap pi on vnet_hdr on multi_queue|addrgenmode) ') + if 'NO-CARRIER' in output: + break + else: + self.fail() @expectedFailureIfModuleIsNotAvailable('vrf') def test_vrf(self): |