Skip to content

Commit 10b10ab

Browse files
committed
mctp: Add retry for one-time peer property queries on timeout
The function `query_peer_properties()` is called once during peer initialization to query basic information after the EID becomes routable. To improve reliability, this change adds a retry mechanism when the query fails with `-ETIMEDOUT`. Since these queries are one-time initialization steps, a single successful attempt is sufficient, and retrying enhances stability under transient MCTP bus contention or multi-master timing issues. Testing: ``` root@bmc:~# journalctl -xeu mctpd.service | grep Retrying Oct 29 00:35:21 bmc mctpd[31801]: mctpd: Retrying to get endpoint types for peer eid 10 net 1 phys physaddr if 4 hw len 1 0x20 state 1. Attempt 1 Oct 29 00:39:00 bmc mctpd[32065]: mctpd: Retrying to get endpoint types for peer eid 10 net 1 phys physaddr if 4 hw len 1 0x20 state 1. Attempt 1 Oct 29 00:39:01 bmc mctpd[32065]: mctpd: Retrying to get endpoint types for peer eid 10 net 1 phys physaddr if 4 hw len 1 0x20 state 1. Attempt 2 Oct 29 00:45:08 bmc mctpd[32360]: mctpd: Retrying to get endpoint types for peer eid 10 net 1 phys physaddr if 4 hw len 1 0x20 state 1. Attempt 1 ``` Signed-off-by: Daniel Hsu <Daniel-Hsu@quantatw.com>
1 parent 8b019a3 commit 10b10ab

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/mctpd.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2836,21 +2836,42 @@ static int method_learn_endpoint(sd_bus_message *call, void *data,
28362836
static int query_peer_properties(struct peer *peer)
28372837
{
28382838
int rc;
2839+
const int max_retries = 4;
28392840

28402841
rc = query_get_peer_msgtypes(peer);
28412842
if (rc < 0) {
28422843
// Warn here, it's a mandatory command code.
28432844
// It might be too noisy if some devices don't implement it.
28442845
warnx("Error getting endpoint types for %s. Ignoring error %d %s",
2845-
peer_tostr(peer), rc, strerror(-rc));
2846+
peer_tostr(peer), rc, strerror(-rc));
2847+
if (rc == -ETIMEDOUT) {
2848+
for (int i = 0; i < max_retries; i++) {
2849+
if (peer->ctx->verbose)
2850+
warnx("Retrying to get endpoint types for %s. Attempt %d",
2851+
peer_tostr(peer), i + 1);
2852+
rc = query_get_peer_msgtypes(peer);
2853+
if (rc == 0)
2854+
break;
2855+
}
2856+
}
28462857
rc = 0;
28472858
}
28482859

28492860
rc = query_get_peer_uuid(peer);
28502861
if (rc < 0) {
28512862
if (peer->ctx->verbose)
28522863
warnx("Error getting UUID for %s. Ignoring error %d %s",
2853-
peer_tostr(peer), rc, strerror(-rc));
2864+
peer_tostr(peer), rc, strerror(-rc));
2865+
if (rc == -ETIMEDOUT) {
2866+
for (int i = 0; i < max_retries; i++) {
2867+
if (peer->ctx->verbose)
2868+
warnx("Retrying to get peer UUID for %s. Attempt %d",
2869+
peer_tostr(peer), i + 1);
2870+
rc = query_get_peer_uuid(peer);
2871+
if (rc == 0)
2872+
break;
2873+
}
2874+
}
28542875
rc = 0;
28552876
}
28562877

0 commit comments

Comments
 (0)