Skip to content

Commit ad53826

Browse files
committed
tests/platforms: add test for Azure SR-IOV udev rules
Introduce a new test which verifies that udev rules for Azure SR-IOV network interfaces correctly mark them as unmanaged by NetworkManager. It only runs on Azure and uses Standard_D2s_v3 or larger instance type with Accelerated Networking enabled. The test checks that SR-IOV interfaces (PCI devices with vendor drivers like mlx5_core) have the AZURE_UNMANAGED_SRIOV property set, and that NetworkManager respects this property by leaving them unmanaged.
1 parent fa2c589 commit ad53826

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../data/commonlib.sh
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
## kola:
3+
## # This test is targeted at Azure
4+
## platforms: azure
5+
## # This test requires an instance type that supports Accelerated Networking (SRIOV)
6+
## # Standard_D2s_v3 and larger sizes support Accelerated Networking
7+
## instanceType: "Standard_D2s_v3"
8+
## description: Verify that udev rules for Azure SRIOV network interfaces
9+
## correctly mark them as unmanaged by NetworkManager.
10+
11+
set -xeuo pipefail
12+
13+
. "$KOLA_EXT_DATA/commonlib.sh"
14+
15+
# Find SRIOV network interfaces
16+
# Azure SR-IOV interfaces use vendor drivers like mlx5_core
17+
sriov_interfaces=()
18+
for iface in /sys/class/net/*; do
19+
iface_name=$(basename "$iface")
20+
# Skip loopback
21+
if [ "$iface_name" = "lo" ]; then
22+
continue
23+
fi
24+
25+
if [ -e "$iface/device/driver" ]; then
26+
driver=$(basename "$(readlink "$iface/device/driver")")
27+
# SR-IOV interfaces are on PCI bus and not vmbus (hv_netvsc is the synthetic interface)
28+
if [ "$driver" != "hv_netvsc" ] && [ -e "$iface/device/subsystem" ]; then
29+
subsystem=$(basename "$(readlink "$iface/device/subsystem")")
30+
if [ "$subsystem" = "pci" ]; then
31+
sriov_interfaces+=("$iface_name")
32+
fi
33+
fi
34+
fi
35+
done
36+
37+
# If no SRIOV interfaces found then this might be a VM size without Accelerated Networking
38+
# or the feature might not be enabled. We should have at least one SRIOV interface.
39+
if [ ${#sriov_interfaces[@]} -eq 0 ]; then
40+
fatal "No SRIOV interfaces found, expected at least one PCI network interface (non-hv_netvsc)."
41+
fi
42+
43+
# Check that each SRIOV interface has the AZURE_UNMANAGED_SRIOV property set
44+
# This property is set by the azure-vm-utils udev rules
45+
for iface in "${sriov_interfaces[@]}"; do
46+
# Check the interface properties
47+
if ! udevadm info --query=property --path="/sys/class/net/$iface" | grep -q "AZURE_UNMANAGED_SRIOV=1"; then
48+
fatal "SRIOV interface $iface does not have AZURE_UNMANAGED_SRIOV=1 property."
49+
fi
50+
done
51+
52+
# Verify that NetworkManager is not managing these interfaces
53+
echo "Verifying NetworkManager is not managing SRIOV interfaces..."
54+
nm_devices=$(nmcli -t -f DEVICE,STATE device)
55+
56+
for iface in "${sriov_interfaces[@]}"; do
57+
# Check NetworkManager's device list from cached output
58+
if echo "$nm_devices" | grep -q "^$iface:"; then
59+
# If the interface appears in nmcli output, check its state
60+
state=$(echo "$nm_devices" | grep "^$iface:" | cut -d: -f2)
61+
if [ "$state" != "unmanaged" ]; then
62+
fatal "NetworkManager is managing SRIOV interface $iface (state: $state). It should be unmanaged."
63+
fi
64+
fi
65+
66+
echo "✓ NetworkManager correctly ignores $iface"
67+
done

0 commit comments

Comments
 (0)