mirror of
https://github.com/systemd/systemd.git
synced 2025-01-26 14:04:03 +03:00
test-network: add testcases for configuring SR-IOV by .link file
This commit is contained in:
parent
a03ff4c0fe
commit
1e8e9730d2
7
test/test-network/conf/25-sriov-udev.network
Normal file
7
test/test-network/conf/25-sriov-udev.network
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
[Match]
|
||||||
|
Name=eni99np1
|
||||||
|
|
||||||
|
[Network]
|
||||||
|
Address=192.168.100.100/24
|
||||||
|
IPv6AcceptRA=no
|
40
test/test-network/conf/25-sriov.link
Normal file
40
test/test-network/conf/25-sriov.link
Normal file
@ -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
|
@ -3974,6 +3974,8 @@ class NetworkdBridgeTests(unittest.TestCase, Utilities):
|
|||||||
|
|
||||||
class NetworkdSRIOVTests(unittest.TestCase, Utilities):
|
class NetworkdSRIOVTests(unittest.TestCase, Utilities):
|
||||||
units = [
|
units = [
|
||||||
|
'25-sriov-udev.network',
|
||||||
|
'25-sriov.link',
|
||||||
'25-sriov.network',
|
'25-sriov.network',
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -4010,6 +4012,93 @@ class NetworkdSRIOVTests(unittest.TestCase, Utilities):
|
|||||||
'vf 2 .*00:11:22:33:44:57.*vlan 7, qos 3, spoof checking off, link-state auto, trust off, query_rss off'
|
'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):
|
class NetworkdLLDPTests(unittest.TestCase, Utilities):
|
||||||
links = ['veth99']
|
links = ['veth99']
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user