Skip to content

Commit 1a22da4

Browse files
authored
Merge pull request #443 from s4heid/ubuntu-jammy-sriov
Ignore SR-IOV VF interfaces for Azure stemcells
2 parents 9f0ca57 + 532b8f6 commit 1a22da4

File tree

4 files changed

+75
-0
lines changed

4 files changed

+75
-0
lines changed

bosh-stemcell/spec/stemcells/azure_spec.rb

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,41 @@
4242
its(:content) { should include('"PartitionerType": "parted"') }
4343
end
4444
end
45+
46+
context 'installed by system_azure_network', {
47+
exclude_on_alicloud: true,
48+
exclude_on_aws: true,
49+
exclude_on_google: true,
50+
exclude_on_vcloud: true,
51+
exclude_on_vsphere: true,
52+
exclude_on_warden: true,
53+
exclude_on_openstack: true,
54+
exclude_on_softlayer: true,
55+
} do
56+
describe 'SR-IOV VF udev rules' do
57+
subject { file('/etc/udev/rules.d/10-azure-sriov-unmanaged.rules') }
58+
59+
it { should be_mode(644) }
60+
it { should be_owned_by('root') }
61+
62+
its(:content) { should match /SUBSYSTEM=="net"/ }
63+
its(:content) { should match /ATTR\{flags\}=="0\?\?\[89ABCDEF\]\*"/ }
64+
its(:content) { should match /ENV\{AZURE_UNMANAGED_SRIOV\}="1"/ }
65+
its(:content) { should match /ENV\{ID_NET_MANAGED_BY\}="unmanaged"/ }
66+
its(:content) { should match /ENV\{NM_UNMANAGED\}="1"/ }
67+
its(:content) { should match /ATTR\{ifalias\}="sriov-vf"/ }
68+
end
69+
70+
describe 'systemd network configuration for unmanaged SR-IOV devices' do
71+
subject { file('/etc/systemd/network/01-azure-sriov-unmanaged.network') }
72+
73+
it { should be_mode(644) }
74+
it { should be_owned_by('root') }
75+
76+
its(:content) { should match /\[Match\]/ }
77+
its(:content) { should match /Property=AZURE_UNMANAGED_SRIOV=1/ }
78+
its(:content) { should match /\[Link\]/ }
79+
its(:content) { should match /Unmanaged=yes/ }
80+
end
81+
end
4582
end

stemcell_builder/stages/system_azure_network/apply.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,11 @@ EOS
2020
# The port 65330 is unusable on Azure
2121
cp $dir/assets/90-azure-sysctl.conf $chroot/etc/sysctl.d
2222
chmod 0644 $chroot/etc/sysctl.d/90-azure-sysctl.conf
23+
24+
# Install SR-IOV VF udev rule to mark network interfaces as unmanaged and set ifalias
25+
cp $dir/assets/10-azure-sriov-unmanaged.rules $chroot/etc/udev/rules.d
26+
chmod 0644 $chroot/etc/udev/rules.d/10-azure-sriov-unmanaged.rules
27+
28+
# Apply the systemd.network configuration, to ignore unmanaged devices
29+
cp $dir/assets/01-azure-sriov-unmanaged.network $chroot/etc/systemd/network
30+
chmod 0644 $chroot/etc/systemd/network/01-azure-sriov-unmanaged.network
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Azure VMs with accelerated networking may have MANA, mlx4, or mlx5 SR-IOV
2+
# devices which are transparently bonded to a synthetic hv_netvsc device.
3+
#
4+
# 10-azure-unmanaged-sriov.rules will mark these devices with
5+
# AZURE_UNMANAGED_SRIOV=1, allowing this configuration to set them as unmanaged.
6+
7+
[Match]
8+
Property=AZURE_UNMANAGED_SRIOV=1
9+
10+
[Link]
11+
Unmanaged=yes
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Azure VMs with accelerated networking may have MANA, mlx4, or mlx5 SR-IOV devices
2+
# which are transparently bonded to a synthetic hv_netvsc device.
3+
#
4+
# Mark devices with the IFF_SLAVE bit set as unmanaged devices:
5+
# AZURE_UNMANAGED_SRIOV=1: Custom tag to mark the interface as unmanaged in systemd-networkd (01-azure-sriov-unmanaged.network).
6+
# ID_NET_MANAGED_BY=unmanaged: Standard tag for systemd-networkd (v255+).
7+
# NM_UNMANAGED=1: Tells NetworkManager to ignore the interface.
8+
#
9+
# Additionally, set an ifalias to allow the bosh-agent to ignore the device, as both
10+
# interfaces, the synthetic and the VF interface, share the same MAC address and only
11+
# the synthetic interface should be used by the application.
12+
13+
SUBSYSTEM=="net", ACTION!="remove", KERNEL!="lo", \
14+
DRIVERS=="mana|mlx4_core|mlx5_core", \
15+
ATTR{flags}=="0x?[89ABCDEF]*", \
16+
ENV{AZURE_UNMANAGED_SRIOV}="1", \
17+
ENV{ID_NET_MANAGED_BY}="unmanaged", \
18+
ENV{NM_UNMANAGED}="1", \
19+
ATTR{ifalias}="sriov-vf"

0 commit comments

Comments
 (0)