diff --git a/base/pf-bb-config/debian/patches/0001-Reject-device-configuration-if-not-enabled.patch b/base/pf-bb-config/debian/patches/0001-Reject-device-configuration-if-not-enabled.patch new file mode 100644 index 000000000..7d3a35f26 --- /dev/null +++ b/base/pf-bb-config/debian/patches/0001-Reject-device-configuration-if-not-enabled.patch @@ -0,0 +1,50 @@ +From a12967eba299f63f3abe5a906765d5beb16db81c Mon Sep 17 00:00:00 2001 +From: Andre Kantek +Date: Wed, 23 Nov 2022 08:27:52 -0300 +Subject: [PATCH] Reject device configuration if not enabled + +Check if device is enabled in the return logic of get_device_id() + +Signed-off-by: Andre Kantek +--- + config_app.c | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/config_app.c b/config_app.c +index 6acd8f1..4f72764 100644 +--- a/config_app.c ++++ b/config_app.c +@@ -85,6 +85,7 @@ static bool + get_device_id(hw_device *device, const char *location) + { + unsigned long vendor_id = -1, device_id = -1; ++ unsigned int device_enabled = 0; + struct dirent *dirent; + DIR *dir; + char pci_path[PATH_MAX]; +@@ -112,6 +113,12 @@ get_device_id(hw_device *device, const char *location) + if (snprintf_ret < 0) + LOG(ERR, "Failed to format PCI path"); + ++ /* Is device enabled? */ ++ if (strncmp(dirent->d_name, "enable", ++ strlen(dirent->d_name)) == 0 && ++ dirent->d_type == DT_REG) ++ device_enabled = get_file_val(file_path); ++ + /* Get Device ID */ + if (strncmp(dirent->d_name, DEVICE_FILE, + strlen(dirent->d_name)) == 0 && +@@ -127,7 +134,8 @@ get_device_id(hw_device *device, const char *location) + + closedir(dir); + /* Check if device is found */ +- return (vendor_id == device->vendor_id && ++ return (device_enabled && ++ vendor_id == device->vendor_id && + device_id == device->device_id); + } + +-- +2.17.1 + diff --git a/base/pf-bb-config/debian/patches/0002-Fix-check-return-of-configure_device.patch b/base/pf-bb-config/debian/patches/0002-Fix-check-return-of-configure_device.patch new file mode 100644 index 000000000..07b9c5c44 --- /dev/null +++ b/base/pf-bb-config/debian/patches/0002-Fix-check-return-of-configure_device.patch @@ -0,0 +1,37 @@ +From b1b29494ab8b9395c36c1b5664af324c7f67245c Mon Sep 17 00:00:00 2001 +From: Andre Kantek +Date: Wed, 23 Nov 2022 08:36:08 -0300 +Subject: [PATCH] Fix: check return of configure_device() + +Takes the result of configure_device() as the return code of the +application, allowing any script running pf-bb-config to stop on +bad device configuration. + +Signed-off-by: Andre Kantek +--- + config_app.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/config_app.c b/config_app.c +index 4f72764..066fb55 100644 +--- a/config_app.c ++++ b/config_app.c +@@ -431,11 +431,15 @@ main(int argc, char *argv[]) + return -1; + } + ++ ret = 0; + if (device.config_all) { + for (i = 0; i < num_devices; i++) { + strncpy(device.pci_address, found_devices[i], + sizeof(device.pci_address) - NULL_PAD); + ret = configure_device(&device); ++ if (ret != 0) { ++ break; ++ } + } + } else { + select_device(&device, found_devices, num_devices); +-- +2.17.1 + diff --git a/base/pf-bb-config/debian/patches/series b/base/pf-bb-config/debian/patches/series new file mode 100644 index 000000000..6020ab03a --- /dev/null +++ b/base/pf-bb-config/debian/patches/series @@ -0,0 +1,2 @@ +0001-Reject-device-configuration-if-not-enabled.patch +0002-Fix-check-return-of-configure_device.patch \ No newline at end of file