diff options
author | Luca Boccassi <luca.boccassi@microsoft.com> | 2022-01-19 23:38:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-19 23:38:00 +0100 |
commit | de843f8582c15da075a3f5aa7e2af0b9cccad034 (patch) | |
tree | f445079d4fc364df0ece0ee9ee07fe40c25325c1 /test | |
parent | boot: Use -ffile-prefix-map when present (diff) | |
parent | test-network: add testcases for configuring SR-IOV by .link file (diff) | |
download | systemd-de843f8582c15da075a3f5aa7e2af0b9cccad034.tar.xz systemd-de843f8582c15da075a3f5aa7e2af0b9cccad034.zip |
Merge pull request #21865 from yuwata/network-sr-iov
udev/net: support configuring SR-IOV virtual functions through .link file
Diffstat (limited to 'test')
-rw-r--r-- | test/fuzz/fuzz-link-parser/directives.link | 11 | ||||
-rw-r--r-- | test/test-network/conf/25-sriov-udev.network | 7 | ||||
-rw-r--r-- | test/test-network/conf/25-sriov.link | 40 | ||||
-rwxr-xr-x | test/test-network/systemd-networkd-tests.py | 156 |
4 files changed, 186 insertions, 28 deletions
diff --git a/test/fuzz/fuzz-link-parser/directives.link b/test/fuzz/fuzz-link-parser/directives.link index 7586e35b49..a5773826c5 100644 --- a/test/fuzz/fuzz-link-parser/directives.link +++ b/test/fuzz/fuzz-link-parser/directives.link @@ -80,3 +80,14 @@ RxMaxCoalescedHighFrames= TxCoalesceHighSec= TxMaxCoalescedHighFrames= CoalescePacketRateSampleIntervalSec= +SR-IOVVirtualFunctions= +[SR-IOV] +VirtualFunction= +MACSpoofCheck= +VLANId= +VLANProtocol= +QualityOfService= +QueryReceiveSideScaling= +Trust= +LinkState= +MACAddress= diff --git a/test/test-network/conf/25-sriov-udev.network b/test/test-network/conf/25-sriov-udev.network new file mode 100644 index 0000000000..e9141310b7 --- /dev/null +++ b/test/test-network/conf/25-sriov-udev.network @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +[Match] +Name=eni99np1 + +[Network] +Address=192.168.100.100/24 +IPv6AcceptRA=no diff --git a/test/test-network/conf/25-sriov.link b/test/test-network/conf/25-sriov.link new file mode 100644 index 0000000000..cc19561306 --- /dev/null +++ b/test/test-network/conf/25-sriov.link @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +[Match] +Driver=netdevsim + +[Link] +NamePolicy=keep kernel database onboard slot path +AlternativeNamesPolicy=database onboard slot path mac +MACAddressPolicy=persistent + +[SR-IOV] +VirtualFunction=0 +VLANId=5 +VLANProtocol=802.1ad +QualityOfService=1 +MACSpoofCheck=yes +QueryReceiveSideScaling=yes +Trust=yes +LinkState=yes +MACAddress=00:11:22:33:44:55 + +[SR-IOV] +VirtualFunction=1 +VLANId=6 +VLANProtocol=802.1Q +QualityOfService=2 +MACSpoofCheck=no +QueryReceiveSideScaling=no +Trust=no +LinkState=no +MACAddress=00:11:22:33:44:56 + +[SR-IOV] +VirtualFunction=2 +VLANId=7 +QualityOfService=3 +MACSpoofCheck=no +QueryReceiveSideScaling=no +Trust=no +LinkState=auto +MACAddress=00:11:22:33:44:57 diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 2207f36245..0233c4dd1f 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -176,7 +176,7 @@ def expectedFailureIfAlternativeNameIsNotAvailable(): call('ip link add dummy98 type dummy', stderr=subprocess.DEVNULL) rc = call('ip link prop add dev dummy98 altname hogehogehogehogehoge', stderr=subprocess.DEVNULL) if rc == 0: - rc = call('ip link show dev hogehogehogehogehoge', stderr=subprocess.DEVNULL) + rc = call('ip link show dev hogehogehogehogehoge', stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) if rc == 0: supported = True @@ -2065,7 +2065,6 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): '25-route-vrf.network', '25-gateway-static.network', '25-gateway-next-static.network', - '25-sriov.network', '25-sysctl-disable-ipv6.network', '25-sysctl.network', '25-test1.network', @@ -3450,32 +3449,6 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): self.assertRegex(output, 'qdisc fq_pie 3a: root') self.assertRegex(output, 'limit 200000p') - @expectedFailureIfNetdevsimWithSRIOVIsNotAvailable() - def test_sriov(self): - call('rmmod netdevsim', stderr=subprocess.DEVNULL) - call('modprobe netdevsim', stderr=subprocess.DEVNULL) - with open('/sys/bus/netdevsim/new_device', mode='w') as f: - f.write('99 1') - - call('udevadm settle') - call('udevadm info -w10s /sys/devices/netdevsim99/net/eni99np1', stderr=subprocess.DEVNULL) - with open('/sys/class/net/eni99np1/device/sriov_numvfs', mode='w') as f: - f.write('3') - - copy_unit_to_networkd_unit_path('25-sriov.network') - start_networkd() - self.wait_online(['eni99np1:routable']) - - output = check_output('ip link show dev eni99np1') - print(output) - self.assertRegex(output, - 'vf 0 .*00:11:22:33:44:55.*vlan 5, qos 1, vlan protocol 802.1ad, spoof checking on, link-state enable, trust on, query_rss on\n *' - 'vf 1 .*00:11:22:33:44:56.*vlan 6, qos 2, spoof checking off, link-state disable, trust off, query_rss off\n *' - 'vf 2 .*00:11:22:33:44:57.*vlan 7, qos 3, spoof checking off, link-state auto, trust off, query_rss off' - ) - - call('rmmod netdevsim', stderr=subprocess.DEVNULL) - def test_wait_online_ipv4(self): copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-with-ipv6-prefix.network', 'dhcp-client-ipv4-ipv6ra-prefix-client-with-delay.network') start_networkd() @@ -3999,6 +3972,133 @@ class NetworkdBridgeTests(unittest.TestCase, Utilities): print(output) self.assertIn('from all to 8.8.8.8 lookup 100', output) +class NetworkdSRIOVTests(unittest.TestCase, Utilities): + units = [ + '25-sriov-udev.network', + '25-sriov.link', + '25-sriov.network', + ] + + def setUp(self): + stop_networkd(show_logs=False) + call('rmmod netdevsim', stderr=subprocess.DEVNULL) + + def tearDown(self): + remove_unit_from_networkd_path(self.units) + stop_networkd(show_logs=True) + call('rmmod netdevsim', stderr=subprocess.DEVNULL) + + @expectedFailureIfNetdevsimWithSRIOVIsNotAvailable() + def test_sriov(self): + call('modprobe netdevsim', stderr=subprocess.DEVNULL) + + with open('/sys/bus/netdevsim/new_device', mode='w') as f: + f.write('99 1') + + call('udevadm settle') + call('udevadm info -w10s /sys/devices/netdevsim99/net/eni99np1', stderr=subprocess.DEVNULL) + with open('/sys/class/net/eni99np1/device/sriov_numvfs', mode='w') as f: + f.write('3') + + copy_unit_to_networkd_unit_path('25-sriov.network') + start_networkd() + self.wait_online(['eni99np1:routable']) + + output = check_output('ip link show dev eni99np1') + print(output) + self.assertRegex(output, + 'vf 0 .*00:11:22:33:44:55.*vlan 5, qos 1, vlan protocol 802.1ad, spoof checking on, link-state enable, trust on, query_rss on\n *' + 'vf 1 .*00:11:22:33:44:56.*vlan 6, qos 2, spoof checking off, link-state disable, trust off, query_rss off\n *' + 'vf 2 .*00:11:22:33:44:57.*vlan 7, qos 3, spoof checking off, link-state auto, trust off, query_rss off' + ) + + @expectedFailureIfNetdevsimWithSRIOVIsNotAvailable() + def test_sriov_udev(self): + call('modprobe netdevsim', stderr=subprocess.DEVNULL) + + copy_unit_to_networkd_unit_path('25-sriov.link', '25-sriov-udev.network') + call('udevadm control --reload') + + with open('/sys/bus/netdevsim/new_device', mode='w') as f: + f.write('99 1') + + start_networkd() + self.wait_online(['eni99np1:routable']) + + output = check_output('ip link show dev eni99np1') + print(output) + self.assertRegex(output, + 'vf 0 .*00:11:22:33:44:55.*vlan 5, qos 1, vlan protocol 802.1ad, spoof checking on, link-state enable, trust on, query_rss on\n *' + 'vf 1 .*00:11:22:33:44:56.*vlan 6, qos 2, spoof checking off, link-state disable, trust off, query_rss off\n *' + 'vf 2 .*00:11:22:33:44:57.*vlan 7, qos 3, spoof checking off, link-state auto, trust off, query_rss off' + ) + self.assertNotIn('vf 3', output) + self.assertNotIn('vf 4', output) + + with open(os.path.join(network_unit_file_path, '25-sriov.link'), mode='a') as f: + f.write('[Link]\nSR-IOVVirtualFunctions=4\n') + + call('udevadm control --reload') + call('udevadm trigger --action add --settle /sys/devices/netdevsim99/net/eni99np1') + + output = check_output('ip link show dev eni99np1') + print(output) + self.assertRegex(output, + 'vf 0 .*00:11:22:33:44:55.*vlan 5, qos 1, vlan protocol 802.1ad, spoof checking on, link-state enable, trust on, query_rss on\n *' + 'vf 1 .*00:11:22:33:44:56.*vlan 6, qos 2, spoof checking off, link-state disable, trust off, query_rss off\n *' + 'vf 2 .*00:11:22:33:44:57.*vlan 7, qos 3, spoof checking off, link-state auto, trust off, query_rss off\n *' + 'vf 3' + ) + self.assertNotIn('vf 4', output) + + with open(os.path.join(network_unit_file_path, '25-sriov.link'), mode='a') as f: + f.write('[Link]\nSR-IOVVirtualFunctions=\n') + + call('udevadm control --reload') + call('udevadm trigger --action add --settle /sys/devices/netdevsim99/net/eni99np1') + + output = check_output('ip link show dev eni99np1') + print(output) + self.assertRegex(output, + 'vf 0 .*00:11:22:33:44:55.*vlan 5, qos 1, vlan protocol 802.1ad, spoof checking on, link-state enable, trust on, query_rss on\n *' + 'vf 1 .*00:11:22:33:44:56.*vlan 6, qos 2, spoof checking off, link-state disable, trust off, query_rss off\n *' + 'vf 2 .*00:11:22:33:44:57.*vlan 7, qos 3, spoof checking off, link-state auto, trust off, query_rss off\n *' + 'vf 3' + ) + self.assertNotIn('vf 4', output) + + with open(os.path.join(network_unit_file_path, '25-sriov.link'), mode='a') as f: + f.write('[Link]\nSR-IOVVirtualFunctions=2\n') + + call('udevadm control --reload') + call('udevadm trigger --action add --settle /sys/devices/netdevsim99/net/eni99np1') + + output = check_output('ip link show dev eni99np1') + print(output) + self.assertRegex(output, + 'vf 0 .*00:11:22:33:44:55.*vlan 5, qos 1, vlan protocol 802.1ad, spoof checking on, link-state enable, trust on, query_rss on\n *' + 'vf 1 .*00:11:22:33:44:56.*vlan 6, qos 2, spoof checking off, link-state disable, trust off, query_rss off' + ) + self.assertNotIn('vf 2', output) + self.assertNotIn('vf 3', output) + self.assertNotIn('vf 4', output) + + with open(os.path.join(network_unit_file_path, '25-sriov.link'), mode='a') as f: + f.write('[Link]\nSR-IOVVirtualFunctions=\n') + + call('udevadm control --reload') + call('udevadm trigger --action add --settle /sys/devices/netdevsim99/net/eni99np1') + + output = check_output('ip link show dev eni99np1') + print(output) + self.assertRegex(output, + 'vf 0 .*00:11:22:33:44:55.*vlan 5, qos 1, vlan protocol 802.1ad, spoof checking on, link-state enable, trust on, query_rss on\n *' + 'vf 1 .*00:11:22:33:44:56.*vlan 6, qos 2, spoof checking off, link-state disable, trust off, query_rss off\n *' + 'vf 2 .*00:11:22:33:44:57.*vlan 7, qos 3, spoof checking off, link-state auto, trust off, query_rss off' + ) + self.assertNotIn('vf 3', output) + self.assertNotIn('vf 4', output) + class NetworkdLLDPTests(unittest.TestCase, Utilities): links = ['veth99'] |