forked from coreos/fedora-coreos-config
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
overlay.d/05core: add ifname= karg udev rule propagation
This adds to coreos-teardown-initramfs.{service,sh} the ability to propagate udev rules that were generated by ifname-genrules.sh [1] to the real root of the machine to allow for an ephemeral ifname= karg on the first boot to have persistent configuration effect (similar to our other networking kernel arguments). This also adds tests for both the firstboot and everyboot case for the ifname= karg. Fixes coreos/fedora-coreos-tracker#553 [1] https://github.com/dracutdevs/dracut/blob/5c3d0a96473ac339fa2d1b25213b8f301c1cfd0d/modules.d/40network/ifname-genrules.sh
- Loading branch information
1 parent
a5569fa
commit d69fe24
Showing
8 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
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
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 @@ | ||
../../../data/commonlib.sh |
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,36 @@ | ||
# This is a library created for our ifname-karg tests | ||
|
||
. $KOLA_EXT_DATA/commonlib.sh | ||
|
||
# check IP for given NIC name | ||
check_ip() { | ||
# User provides the NIC name. | ||
local nic_name=$1 | ||
# The expected IP is the first one in the range given out by QEMU | ||
# user mode networking: https://www.qemu.org/docs/master/system/devices/net.html#using-the-user-mode-network-stack | ||
local expected_ip="10.0.2.15" | ||
# Verify the given nic name has the expected IP. | ||
local nic_ip=$(get_ipv4_for_nic ${nic_name}) | ||
if [ "${nic_ip}" != "${expected_ip}" ]; then | ||
fatal "Error: get ${nic_name} ip = ${nic_ip}, expected is ${expected_ip}" | ||
fi | ||
ok "get ${nic_name} ip is ${expected_ip}" | ||
} | ||
|
||
# simple file existence check | ||
check_file_exists() { | ||
local file=$1 | ||
if [ ! -f $file ]; then | ||
fatal "expected file ${file} doesn't exist on disk" | ||
fi | ||
ok "expected file ${file} exists on disk" | ||
} | ||
|
||
# simple file non-existence check | ||
check_file_not_exists() { | ||
local file=$1 | ||
if [ -f $file ]; then | ||
fatal "expected file ${file} to not exist on disk" | ||
fi | ||
ok "file ${file} does not exist on disk" | ||
} |
7 changes: 7 additions & 0 deletions
7
tests/kola/networking/ifname-karg/everyboot-systemd-link-file/config.bu
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,7 @@ | ||
variant: fcos | ||
version: 1.4.0 | ||
kernel_arguments: | ||
should_exist: | ||
# Persistently set the ifname kernel argument to set the given MAC to the | ||
# NIC named `kolatest`. The MAC address is the default one QEMU assigns. | ||
- ifname=kolatest:52:54:00:12:34:56 |
1 change: 1 addition & 0 deletions
1
tests/kola/networking/ifname-karg/everyboot-systemd-link-file/data/commonlib.sh
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 @@ | ||
../../../../data/commonlib.sh |
1 change: 1 addition & 0 deletions
1
tests/kola/networking/ifname-karg/everyboot-systemd-link-file/data/ifname-karg-lib.sh
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 @@ | ||
../../data/ifname-karg-lib.sh |
43 changes: 43 additions & 0 deletions
43
tests/kola/networking/ifname-karg/everyboot-systemd-link-file/test.sh
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,43 @@ | ||
#!/bin/bash | ||
## kola: | ||
## description: Verify persistent ifname= karg works via systemd-network-generator. | ||
## # appendFirstbootKernelArgs is only supported on QEMU | ||
## platforms: qemu | ||
## # Don't run the propagate code. With this test we want to | ||
## # validate that the systemd.link file gets created by | ||
## # systemd-network-generator. | ||
## appendFirstbootKernelArgs: "coreos.no_persist_ip" | ||
## # appendFirstbootKernelArgs doesn't work on s390x | ||
## # https://github.com/coreos/coreos-assembler/issues/2776 | ||
## architectures: "!s390x" | ||
|
||
set -xeuo pipefail | ||
|
||
. $KOLA_EXT_DATA/commonlib.sh | ||
. $KOLA_EXT_DATA/ifname-karg-lib.sh | ||
|
||
nicname='kolatest' | ||
|
||
run_tests() { | ||
# Make sure nothing was persisted from the initramfs | ||
check_file_not_exists '/etc/udev/rules.d/80-ifname.rules' | ||
# Make sure systemd-network-generator ran (from the real root) | ||
check_file_exists "/run/systemd/network/90-${nicname}.link" | ||
# Make sure the NIC is in use and got the expected IP address | ||
check_ip "${nicname}" | ||
} | ||
|
||
case "${AUTOPKGTEST_REBOOT_MARK:-}" in | ||
"") | ||
ok "first boot" | ||
run_tests | ||
/tmp/autopkgtest-reboot rebooted | ||
;; | ||
|
||
rebooted) | ||
ok "second boot" | ||
run_tests | ||
;; | ||
|
||
*) fatal "unexpected mark: ${AUTOPKGTEST_REBOOT_MARK}";; | ||
esac |
47 changes: 47 additions & 0 deletions
47
tests/kola/networking/ifname-karg/udev-rule-firstboot-propagation
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,47 @@ | ||
#!/bin/bash | ||
## kola: | ||
## description: Verify firstboot ifname= karg udev rule propoagation works. | ||
## # appendFirstbootKernelArgs is only supported on QEMU | ||
## platforms: qemu | ||
## # Append ifname kernel argument to set the given MAC address to the NIC | ||
## # named `kolatest`. The MAC address is the default one QEMU assigns. | ||
## appendFirstbootKernelArgs: "ifname=kolatest:52:54:00:12:34:56" | ||
## # appendFirstbootKernelArgs doesn't work on s390x | ||
## # https://github.com/coreos/coreos-assembler/issues/2776 | ||
## architectures: "!s390x" | ||
|
||
# Part of https://github.com/coreos/fedora-coreos-tracker/issues/553 | ||
|
||
set -xeuo pipefail | ||
|
||
. $KOLA_EXT_DATA/commonlib.sh | ||
. $KOLA_EXT_DATA/ifname-karg-lib.sh | ||
|
||
nicname='kolatest' | ||
|
||
case "${AUTOPKGTEST_REBOOT_MARK:-}" in | ||
"") | ||
ok "first boot" | ||
# Make sure the rules were persisted from the initramfs | ||
check_file_exists '/etc/udev/rules.d/80-ifname.rules' | ||
# On first boot we expect systemd-network-generator to run too | ||
# because the ifname= karg was present, but only for first boot | ||
check_file_exists "/run/systemd/network/90-${nicname}.link" | ||
# Make sure the NIC is in use and got the expected IP address | ||
check_ip "${nicname}" | ||
/tmp/autopkgtest-reboot rebooted | ||
;; | ||
|
||
rebooted) | ||
ok "second boot" | ||
# Make sure the rules are still there | ||
check_file_exists '/etc/udev/rules.d/80-ifname.rules' | ||
# On second boot the ifname= karg isn't there so the file | ||
# created by systemd-network-generator shouldn't exist. | ||
check_file_not_exists "/run/systemd/network/90-${nicname}.link" | ||
# Make sure the NIC is in use and got the expected IP address | ||
check_ip "${nicname}" | ||
;; | ||
|
||
*) fatal "unexpected mark: ${AUTOPKGTEST_REBOOT_MARK}";; | ||
esac |