From 7fb6fca84119909f2f0c1bb5302bcd29609e7d6c Mon Sep 17 00:00:00 2001 From: Douglas Henrique Koerich Date: Mon, 26 Jul 2021 17:04:15 -0300 Subject: [PATCH] Patch pf-bb-config to return -1 on failed config Current implementation of pf-bb-config utility (tag 21.6) does not check the result of configure_device() function. Thus, if pf-bb-config is running in a script or automated procedure (like when applying a puppet manifest), any configuration failure cannot be detected unless the output is parsed. This change patches the source code of pf-bb-config in the same way that was proposed by the PR: https://github.com/intel/pf-bb-config/pull/3. If that change is merged, then in the future when pf-bb-config is upgraded the patch can be removed. Task: 42877 Story: 2009036 Signed-off-by: Douglas Henrique Koerich Change-Id: Ic0ec0c7b9088a573cadf468839be1c4445d7abb2 --- base/pf-bb-config/centos/pf-bb-config.spec | 2 + ...Fix-check-return-of-configure_device.patch | 49 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 base/pf-bb-config/files/Fix-check-return-of-configure_device.patch diff --git a/base/pf-bb-config/centos/pf-bb-config.spec b/base/pf-bb-config/centos/pf-bb-config.spec index b2ebbfdde..4d9e4c4f3 100644 --- a/base/pf-bb-config/centos/pf-bb-config.spec +++ b/base/pf-bb-config/centos/pf-bb-config.spec @@ -10,6 +10,7 @@ Packager: Wind River URL: https://github.com/intel/pf-bb-config/tree/v21.6 Source0: %{name}-%{git_sha}.tar.gz Patch0: Reject-device-configuration-if-not-enabled.patch +Patch1: Fix-check-return-of-configure_device.patch BuildRequires: gcc BuildRequires: inih @@ -23,6 +24,7 @@ space and sets the various parameters through memory-mapped IO read/writes. %prep %setup %patch0 -p1 +%patch1 -p1 %build make diff --git a/base/pf-bb-config/files/Fix-check-return-of-configure_device.patch b/base/pf-bb-config/files/Fix-check-return-of-configure_device.patch new file mode 100644 index 000000000..598e4a66a --- /dev/null +++ b/base/pf-bb-config/files/Fix-check-return-of-configure_device.patch @@ -0,0 +1,49 @@ +From 9d2809308feb10bc74130cea0b677be0bbe3f2dd Mon Sep 17 00:00:00 2001 +From: Douglas Henrique Koerich +Date: Tue, 27 Jul 2021 12:31:45 -0400 +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: Douglas Henrique Koerich +--- + config_app.c | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +diff --git a/config_app.c b/config_app.c +index f1aa52b..f6dab5e 100644 +--- a/config_app.c ++++ b/config_app.c +@@ -390,20 +390,24 @@ 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); +- configure_device(&device); ++ ret = configure_device(&device); ++ if (ret != 0) { ++ break; ++ } + } + } else { + select_device(&device, found_devices, num_devices); +- configure_device(&device); ++ ret = configure_device(&device); + } + + /* Free memory for stored PCI slots */ + for (i = 0; i < num_devices; i++) + free(found_devices[i]); + +- return 0; ++ return ret; + } +-- +2.29.2 +