-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switchdev-bind service rebinds VF to its driver and executes after NetworkManager service, this is required for features such as VF LAG to take effect when bond or other network configurtion are configured through NetworkManager service. Signed-off-by: Zenghui Shi <[email protected]>
- Loading branch information
1 parent
f4cc0f3
commit dcefeab
Showing
3 changed files
with
54 additions
and
7 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
bindata/manifests/switchdev-config/files/bind-switchdev.sh.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
mode: 0755 | ||
overwrite: true | ||
path: "/usr/local/bin/bind-switchdev.sh" | ||
contents: | ||
inline: | | ||
#!/bin/bash | ||
set -eux | ||
input="/etc/sriov_config.json" | ||
if [ ! -f $input ]; then | ||
echo "File /etc/sriov_config.json not exist." | ||
exit | ||
fi | ||
# Required for NetworkManager configuration(e.g. bond) to settle down | ||
sleep 3 | ||
jq -c '.interfaces[]' $input | while read iface; | ||
do | ||
eswitch_mode=$(echo $iface | jq '.eSwitchMode' -r) | ||
if [[ "$eswitch_mode" == "switchdev" ]]; then | ||
pci_addr=$(echo $iface | jq '.pciAddress' -r) | ||
name=$(echo $iface | jq '.name' -r) | ||
echo "load VF driver for $pci_addr" | ||
VfDirs=$(ls /sys/bus/pci/devices/${pci_addr} | grep virtfn) | ||
# load VF driver | ||
for VfDir in $VfDirs | ||
do | ||
VfPciAddr=$(basename "$( readlink -f /sys/bus/pci/devices/${pci_addr}/$VfDir )") | ||
echo $VfPciAddr > /sys/bus/pci/drivers_probe | ||
done | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
bindata/manifests/switchdev-config/switchdev-units/switchdev-bind.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
contents: | | ||
[Unit] | ||
Description=Binds SRIOV VFs into switchdev driver | ||
# Removal of this file signals firstboot completion | ||
ConditionPathExists=!/etc/ignition-machine-config-encapsulated.json | ||
# This service is used to move a SRIOV NIC into switchdev mode | ||
Wants=NetworkManager.service | ||
After=NetworkManager.service | ||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/local/bin/bind-switchdev.sh | ||
StandardOutput=journal+console | ||
StandardError=journal+console | ||
[Install] | ||
WantedBy=network-online.target | ||
enabled: true | ||
name: switchdev-bind.service |