A process only answers an IPC request if it registered an action for
that name. When no action is found the request is dropped silently
unless EAL init is still in progress, so the requester waits for the
full timeout and then sees ETIMEDOUT.
This is what happens when a primary broadcasts a pdump request and any
secondary did not call rte_pdump_init() then the primary would
wait for timeout on response. The secondary should just respond
with MP_IGN.
When secondary sends a request to primary that has not registered
an action, then the primary needs to respond to secondary with
new reply MP_ERR indicating that this action is not supported.
A secondary request to a primary that is still initializing now
fails with ENOTSUP. Before it got MP_IGN and the request returned
success with no replies. Waiting is not an option since there is no
way to know whether the primary will ever register that action.
The async path counts an MP_ERR as processed so the callback still
runs. No in tree user can reach that case today, since the only
async requests go from secondary to primary, but rte_mp_request_async
is public and dropping the reply would leave its callback pending.
Fixes: 579a4ccc345c ("eal: ignore IPC messages until init is complete")
Cc: [email protected]
Signed-off-by: Stephen Hemminger <[email protected]>
---
lib/eal/common/eal_common_proc.c | 55 ++++++++++++++++++++------------
1 file changed, 35 insertions(+), 20 deletions(-)
diff --git a/lib/eal/common/eal_common_proc.c b/lib/eal/common/eal_common_proc.c
index b70e9189a4..65dceed1b6 100644
--- a/lib/eal/common/eal_common_proc.c
+++ b/lib/eal/common/eal_common_proc.c
@@ -32,7 +32,6 @@
#include "eal_memcfg.h"
#include "eal_private.h"
#include "eal_filesystem.h"
-#include "eal_internal_cfg.h"
static RTE_ATOMIC(int) mp_fd = -1;
static rte_thread_t mp_handle_tid;
@@ -58,6 +57,7 @@ enum mp_type {
MP_REQ, /* Request for information, Will block for a reply */
MP_REP, /* Response to previously-received request */
MP_IGN, /* Response telling requester to ignore this response */
+ MP_ERR, /* Response telling requester that request not handled */
};
/* Message sent from primary EAL to secondary EAL */
@@ -357,25 +357,27 @@ cleanup_msg_fds(const struct rte_mp_msg *msg)
static void
process_msg(struct mp_msg_internal *m, struct sockaddr_un *s)
{
- struct pending_request *pending_req;
struct action_entry *entry;
struct rte_mp_msg *msg = &m->msg;
rte_mp_t action = NULL;
- const struct internal_config *internal_conf =
- eal_get_internal_configuration();
EAL_LOG(DEBUG, "msg: %s", msg->name);
- if (m->type == MP_REP || m->type == MP_IGN) {
+ if (m->type == MP_REP || m->type == MP_IGN || m->type == MP_ERR) {
+ struct pending_request *pending_req;
struct pending_request *req = NULL;
pthread_mutex_lock(&pending_requests.lock);
pending_req = find_request_by_name(s->sun_path, msg->name);
if (pending_req) {
memcpy(pending_req->reply, msg, sizeof(*msg));
- /* -1 indicates that we've been asked to ignore */
- pending_req->reply_received =
- m->type == MP_REP ? 1 : -1;
+
+ if (m->type == MP_REP)
+ pending_req->reply_received = 1;
+ else if (m->type == MP_IGN)
+ pending_req->reply_received = -1;
+ else /* MP_ERR */
+ pending_req->reply_received = -2;
if (pending_req->type == REQUEST_TYPE_SYNC)
pthread_cond_signal(&pending_req->sync.cond);
@@ -398,18 +400,20 @@ process_msg(struct mp_msg_internal *m, struct sockaddr_un
*s)
action = entry->action;
pthread_mutex_unlock(&mp_mutex_action);
- if (!action) {
- if (m->type == MP_REQ && !internal_conf->init_complete) {
- /* if this is a request, and init is not yet complete,
- * and callback wasn't registered, we should tell the
- * requester to ignore our existence because we're not
- * yet ready to process this request.
+ if (action == NULL) {
+ if (m->type == MP_REQ) {
+ /*
+ * No handler is registered, either because init is not
+ * complete or because this process does not use the
+ * feature. A secondary only gets broadcasts from the
+ * primary and can ignore them. A primary must tell the
+ * requester it is unsupported.
*/
- struct rte_mp_msg dummy;
+ struct rte_mp_msg dummy = { 0 };
- memset(&dummy, 0, sizeof(dummy));
strlcpy(dummy.name, msg->name, sizeof(dummy.name));
- mp_send(&dummy, s->sun_path, MP_IGN);
+ mp_send(&dummy, s->sun_path,
+ rte_eal_process_type() == RTE_PROC_PRIMARY ?
MP_ERR : MP_IGN);
} else {
EAL_LOG(ERR, "Cannot find action: %s",
msg->name);
@@ -501,6 +505,13 @@ process_async_request(struct pending_request *sr, const
struct timespec *now)
} else if (sr->reply_received == -1) {
/* we were asked to ignore this process */
reply->nb_sent--;
+ } else if (sr->reply_received == -2) {
+ /*
+ * peer has no handler for this request. Count it as
+ * processed so the callback still runs, but not as
+ * received since there is no reply to pass up.
+ */
+ param->n_responses_processed++;
} else if (timeout) {
/* count it as processed response, but don't increment
* nb_received.
@@ -1019,19 +1030,23 @@ mp_request_sync(const char *dst, struct rte_mp_msg *req,
TAILQ_REMOVE(&pending_requests.requests, &pending_req, next);
- if (pending_req.reply_received == 0) {
+ switch (pending_req.reply_received) {
+ case 0:
EAL_LOG(ERR, "Fail to recv reply for request %s:%s",
dst, req->name);
rte_errno = ETIMEDOUT;
return -1;
- }
- if (pending_req.reply_received == -1) {
+ case -1:
EAL_LOG(DEBUG, "Asked to ignore response");
/* not receiving this message is not an error, so decrement
* number of sent messages
*/
reply->nb_sent--;
return 0;
+ case -2:
+ EAL_LOG(DEBUG, "Request not supported");
+ rte_errno = ENOTSUP;
+ return -1;
}
tmp = realloc(reply->msgs, sizeof(msg) * (reply->nb_received + 1));
--
2.53.0