pldm: pldm-scripts: Fix filter and sibling abort

A caller that wants only some of the matching devices updated writes
their EIDs to /tmp/pldm-images/eid_filter.txt and then runs
pldm_update_fw.sh. The script deleted that file while it cleared
leftover bundles, so pldmd updated every matching device. The script
also stopped waiting at the first failed update step and cancelled
every device, including those still updating. With an ownership
bundle the NICs that are already claimed fail the apply step early,
so the unclaimed ones never finished.

Keep the filter file during cleanup. Print a NOTE with the listed
EIDs before staging and before the final SUCCESS line, because a
filter left behind by an earlier caller restricts the update just the
same. End the wait early only once every matched device has completed
or failed a step. If the matched devices are unknown, fall back to
the stall detector, which asks every PLDM endpoint whether it is
still busy. After a failed activation, send CancelUpdate only to the
devices that pldmd did not report as updated. A retry still cancels
whatever is in update mode when it begins.

Smaller fixes in pldm_update_fw.sh:

- Measure elapsed time from /proc/uptime. The transmit rate that
  tells a transfer from idle traffic was divided by the nominal poll
  period, so a slow poll looked like a transfer. bash's SECONDS is
  not used because it follows the wall clock, which jumps when a BMC
  without an RTC first syncs its time.
- Work without the timeout command, which some BusyBox builds omit.
  The fallback watchdog returns 124 on expiry, leaves no process
  behind and keeps Ctrl-C working.
- Find PLDM endpoints through mctpd, as pldmd does, instead of
  through MCTPReactor.
- Accept --force after the bundle path. An unknown option or a
  second positional argument is now an error wherever it appears.
- Unlock explicitly on exit. A process that inherited the lock
  descriptor could keep the lock held and make the next run fail.

pldm_list_fw_version.sh and pldm_dump_fw_status.sh:

- Treat only leaf endpoint objects as endpoints, not association
  subpaths such as /endpoints/<eid>/configured_by.
- Still list an endpoint that has no configured_by association or no
  active version string.
- Match PLDM (type 1) exactly in SupportedMessageTypes. The old grep
  for '1,' missed a single or last entry and matched 11 and 21.

Tested: one self-checking suite, 14 of 14 checks passed on each of
two platforms. Both ran signed development image
gbmc-release-11.24.20.37 with these scripts installed. Its pldmd
carries changes that are not merged yet. Each paste holds the verbose
output followed by the suite itself.

platform39 (4 NIC SMA MCUs, 8 NICs, 15 PLDM endpoints):
https://paste.googleplex.com/6755399437425030
platform31 (2 NIC SMA MCUs, 4 NICs, 6 PLDM endpoints):
https://paste.googleplex.com/6755399437425204

With the real pldmd and real devices (the SMA MCUs on platform39,
the NICs on platform31):
- A forced update with 2 of the 4 EIDs in eid_filter.txt updated
  those 2 and skipped the other 2. The file survived the cleanup
  before staging, three rejected attempts and SIGTERM during an
  update, and the NOTE lines were printed.
- "<bundle> --force" re-flashed one device. An unknown option after
  the path and a second path were rejected.
- Endpoint discovery returned exactly the PLDM endpoints, also with
  MCTPReactor stopped.
- With a process still holding a copy of the lock descriptor, the
  lock was free after the run and a second run started. A control
  shows that closing the descriptor alone leaves the lock held.
- Both listing scripts listed exactly the PLDM endpoints that mctpd
  reports.

With mock busctl, journalctl and pldmtool on the BMC:
- The ownership flow of the calling shell library, with 6 devices
  failing the apply step and 2 completing: the filter stayed in
  place through three attempts, the 2 got no CancelUpdate and the
  library returned success.
- A pldmd that leaves a failed activation in Activating: one failing
  device ends the attempt at the first poll, with two devices the
  wait lasts until the second has finished, and with the matched
  devices unknown the stall detector ends the attempt.
- Slow polls no longer count idle traffic as a transfer.
- Without the timeout command, a hung command ends on budget with
  status 124 and nothing is left behind.
- The listing scripts against endpoints with association subpaths,
  types [1], [0,1] and [0,11,21], a missing association, a missing
  version string and an endpoint on network 2.

Not tested: a real partial failure on hardware. On platform31, two
NICs do not answer GetStatus until their first update since
power-on, so the baseline check accepted them without a status.

shellcheck reports nothing on all three scripts.

Fusion-Link: fusion2,n/a
Google-Bug-Id: 585096554
Change-Id: Id8363ecbc742c947a67b1b52b1eb5fa7ae9f1ff6
Signed-off-by: Kenneth Lamar <kennethlamar@google.com>
1 file changed
tree: 76bdafbd7e1677a8c3e9f67112bd1b2c25a4d7ae
  1. linux/
  2. .gitmodules