Users may specify MAC addresses in the network interface pinning map in an uppercase format, which is more common than lowercase in some environments.
This would then cause the auto-installer to mistakenly consider these addresses as unknown - thus just unconditionally convert all MAC addresses to lowercase while parsing. Reported-by: Aaron Lauterer <[email protected]> Signed-off-by: Christoph Heiss <[email protected]> --- proxmox-auto-installer/src/answer.rs | 7 ++++- proxmox-auto-installer/tests/parse-answer.rs | 1 + ...terface_pinning_uppercase_mac_address.json | 30 +++++++++++++++++++ ...terface_pinning_uppercase_mac_address.toml | 22 ++++++++++++++ 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 proxmox-auto-installer/tests/resources/parse_answer/network_interface_pinning_uppercase_mac_address.json create mode 100644 proxmox-auto-installer/tests/resources/parse_answer/network_interface_pinning_uppercase_mac_address.toml diff --git a/proxmox-auto-installer/src/answer.rs b/proxmox-auto-installer/src/answer.rs index 1e455ca..d12e088 100644 --- a/proxmox-auto-installer/src/answer.rs +++ b/proxmox-auto-installer/src/answer.rs @@ -225,8 +225,13 @@ impl TryFrom<NetworkInAnswer> for Network { let interface_name_pinning = match network.interface_name_pinning { Some(opts) if opts.enabled => { let opts = NetworkInterfacePinningOptions { - mapping: opts.mapping, + mapping: opts + .mapping + .iter() + .map(|(k, v)| (k.to_lowercase(), v.clone())) + .collect(), }; + opts.verify()?; Some(opts) } diff --git a/proxmox-auto-installer/tests/parse-answer.rs b/proxmox-auto-installer/tests/parse-answer.rs index 696fe1f..7dd4a9d 100644 --- a/proxmox-auto-installer/tests/parse-answer.rs +++ b/proxmox-auto-installer/tests/parse-answer.rs @@ -130,6 +130,7 @@ mod tests { hashed_root_password, minimal, network_interface_pinning, + network_interface_pinning_uppercase_mac_address, nic_matching, specific_nic, zfs, diff --git a/proxmox-auto-installer/tests/resources/parse_answer/network_interface_pinning_uppercase_mac_address.json b/proxmox-auto-installer/tests/resources/parse_answer/network_interface_pinning_uppercase_mac_address.json new file mode 100644 index 0000000..76723c8 --- /dev/null +++ b/proxmox-auto-installer/tests/resources/parse_answer/network_interface_pinning_uppercase_mac_address.json @@ -0,0 +1,30 @@ +{ + "autoreboot": 1, + "cidr": "192.168.1.114/24", + "country": "at", + "dns": "192.168.1.254", + "domain": "testinstall", + "filesys": "ext4", + "gateway": "192.168.1.1", + "hdsize": 223.57088470458984, + "existing_storage_auto_rename": 1, + "hostname": "pveauto", + "keymap": "de", + "mailto": "[email protected]", + "mngmt_nic": "mgmt", + "network_interface_pin_map": { + "1c:34:da:5c:5e:24": "nic2", + "1c:34:da:5c:5e:25": "nic3", + "24:8a:07:1e:05:bc": "lan0", + "24:8a:07:1e:05:bd": "lan1", + "5a:47:32:dd:c7:47": "nic8", + "a0:36:9f:0a:b3:82": "nic6", + "a0:36:9f:0a:b3:83": "nic7", + "b4:2e:99:ac:ad:b4": "mgmt", + "b4:2e:99:ac:ad:b5": "nic1" + }, + "root_password": { "plain": "12345678" }, + "target_hd": "/dev/sda", + "timezone": "Europe/Vienna", + "first_boot": { "enabled": 0 } +} diff --git a/proxmox-auto-installer/tests/resources/parse_answer/network_interface_pinning_uppercase_mac_address.toml b/proxmox-auto-installer/tests/resources/parse_answer/network_interface_pinning_uppercase_mac_address.toml new file mode 100644 index 0000000..6681fe9 --- /dev/null +++ b/proxmox-auto-installer/tests/resources/parse_answer/network_interface_pinning_uppercase_mac_address.toml @@ -0,0 +1,22 @@ +[global] +keyboard = "de" +country = "at" +fqdn = "pveauto.testinstall" +mailto = "[email protected]" +timezone = "Europe/Vienna" +root-password = "12345678" + +[network] +source = "from-dhcp" + +[network.interface-name-pinning] +enabled = true + +[network.interface-name-pinning.mapping] +"24:8A:07:1E:05:BC" = "lan0" +"24:8A:07:1E:05:BD" = "lan1" +"B4:2E:99:AC:AD:B4" = "mgmt" + +[disk-setup] +filesystem = "ext4" +disk-list = ["sda"] -- 2.52.0 _______________________________________________ pve-devel mailing list [email protected] https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
