Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1736 from ldorau/rpma-add-fault-injection-also-in…
Browse files Browse the repository at this point in the history
…side-functions

rpma: add fault injection also inside functions
  • Loading branch information
ldorau authored May 16, 2022
2 parents 1f4ff1b + 91827e3 commit 338e099
Show file tree
Hide file tree
Showing 17 changed files with 181 additions and 130 deletions.
51 changes: 31 additions & 20 deletions src/conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ rpma_conn_new(struct rpma_peer *peer, struct rdma_cm_id *id,
struct ibv_comp_channel *channel, struct rpma_conn **conn_ptr)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_PROVIDER, {});

if (peer == NULL || id == NULL || cq == NULL || conn_ptr == NULL)
return RPMA_E_INVAL;
Expand All @@ -62,6 +62,7 @@ rpma_conn_new(struct rpma_peer *peer, struct rdma_cm_id *id,
return RPMA_E_PROVIDER;
}

RPMA_FAULT_INJECTION_GOTO(RPMA_E_PROVIDER, err_destroy_evch);
if (rdma_migrate_id(id, evch)) {
RPMA_LOG_ERROR_WITH_ERRNO(errno, "rdma_migrate_id()");
ret = RPMA_E_PROVIDER;
Expand Down Expand Up @@ -132,7 +133,7 @@ int
rpma_conn_get_event_fd(const struct rpma_conn *conn, int *fd)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});

if (conn == NULL || fd == NULL)
return RPMA_E_INVAL;
Expand All @@ -149,7 +150,11 @@ int
rpma_conn_next_event(struct rpma_conn *conn, enum rpma_conn_event *event)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_PROVIDER, {});
RPMA_FAULT_INJECTION(RPMA_E_NO_EVENT,
{
errno = ENODATA;
});

int ret;

Expand Down Expand Up @@ -180,6 +185,7 @@ rpma_conn_next_event(struct rpma_conn *conn, enum rpma_conn_event *event)
ret = RPMA_E_PROVIDER;
goto err_private_data_discard;
}
RPMA_FAULT_INJECTION_GOTO(RPMA_E_UNKNOWN, err_private_data_discard);

switch (cm_event) {
case RDMA_CM_EVENT_ESTABLISHED:
Expand Down Expand Up @@ -226,7 +232,7 @@ int
rpma_conn_wait(struct rpma_conn *conn, struct rpma_cq **cq, bool *is_rcq)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_NO_COMPLETION, {});

if (conn == NULL || cq == NULL)
return RPMA_E_INVAL;
Expand Down Expand Up @@ -262,6 +268,10 @@ rpma_conn_wait(struct rpma_conn *conn, struct rpma_cq **cq, bool *is_rcq)
ibv_ack_cq_events(ev_cq, 1 /* # of CQ events */);

/* request for the next event on the CQ channel */
RPMA_FAULT_INJECTION(RPMA_E_PROVIDER,
{
*cq = NULL;
});
errno = ibv_req_notify_cq(ev_cq, 0 /* all completions */);
if (errno) {
*cq = NULL;
Expand All @@ -280,7 +290,7 @@ int
rpma_conn_get_compl_fd(const struct rpma_conn *conn, int *fd)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});

if (conn == NULL || fd == NULL)
return RPMA_E_INVAL;
Expand All @@ -301,7 +311,7 @@ rpma_conn_get_private_data(const struct rpma_conn *conn,
struct rpma_conn_private_data *pdata)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});

if (conn == NULL || pdata == NULL)
return RPMA_E_INVAL;
Expand Down Expand Up @@ -330,7 +340,7 @@ rpma_conn_disconnect(struct rpma_conn *conn)

RPMA_LOG_NOTICE("Requesting for disconnection");

RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_PROVIDER, {});
return 0;
}

Expand Down Expand Up @@ -370,6 +380,7 @@ rpma_conn_delete(struct rpma_conn **conn_ptr)
ret = RPMA_E_PROVIDER;
goto err_destroy_comp_channel;
}
RPMA_FAULT_INJECTION_GOTO(RPMA_E_PROVIDER, err_destroy_comp_channel);

if (conn->channel) {
errno = ibv_destroy_comp_channel(conn->channel);
Expand All @@ -379,6 +390,7 @@ rpma_conn_delete(struct rpma_conn **conn_ptr)
ret = RPMA_E_PROVIDER;
goto err_destroy_event_channel;
}
RPMA_FAULT_INJECTION_GOTO(RPMA_E_PROVIDER, err_destroy_event_channel);
}

rdma_destroy_event_channel(conn->evch);
Expand All @@ -387,7 +399,6 @@ rpma_conn_delete(struct rpma_conn **conn_ptr)
free(conn);
*conn_ptr = NULL;

RPMA_FAULT_INJECTION();
return 0;

err_destroy_qp:
Expand Down Expand Up @@ -420,7 +431,7 @@ rpma_read(struct rpma_conn *conn,
size_t len, int flags, const void *op_context)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});

if (conn == NULL || flags == 0 ||
((src == NULL || dst == NULL) &&
Expand All @@ -444,7 +455,7 @@ rpma_write(struct rpma_conn *conn,
size_t len, int flags, const void *op_context)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});

if (conn == NULL || flags == 0 ||
((src == NULL || dst == NULL) &&
Expand All @@ -470,7 +481,7 @@ rpma_write_with_imm(struct rpma_conn *conn,
size_t len, int flags, uint32_t imm, const void *op_context)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});

if (conn == NULL || flags == 0 ||
((src == NULL || dst == NULL) &&
Expand All @@ -496,7 +507,7 @@ rpma_atomic_write(struct rpma_conn *conn,
int flags, const void *op_context)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});

if (conn == NULL || dst == NULL || src == NULL || flags == 0)
return RPMA_E_INVAL;
Expand All @@ -518,7 +529,7 @@ rpma_flush(struct rpma_conn *conn,
enum rpma_flush_type type, int flags, const void *op_context)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_NOSUPP, {});

if (conn == NULL || dst == NULL || flags == 0)
return RPMA_E_INVAL;
Expand Down Expand Up @@ -562,7 +573,7 @@ rpma_send(struct rpma_conn *conn,
int flags, const void *op_context)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});

if (conn == NULL || flags == 0 ||
(src == NULL && (offset != 0 || len != 0)))
Expand All @@ -583,7 +594,7 @@ rpma_send_with_imm(struct rpma_conn *conn,
int flags, uint32_t imm, const void *op_context)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});

if (conn == NULL || flags == 0 ||
(src == NULL && (offset != 0 || len != 0)))
Expand All @@ -604,7 +615,7 @@ rpma_recv(struct rpma_conn *conn,
const void *op_context)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});

if (conn == NULL || (dst == NULL && (offset != 0 || len != 0)))
return RPMA_E_INVAL;
Expand All @@ -621,7 +632,7 @@ int
rpma_conn_get_qp_num(const struct rpma_conn *conn, uint32_t *qp_num)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});

if (conn == NULL || qp_num == NULL)
return RPMA_E_INVAL;
Expand All @@ -638,7 +649,7 @@ int
rpma_conn_get_cq(const struct rpma_conn *conn, struct rpma_cq **cq_ptr)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});

if (conn == NULL || cq_ptr == NULL)
return RPMA_E_INVAL;
Expand All @@ -655,7 +666,7 @@ int
rpma_conn_get_rcq(const struct rpma_conn *conn, struct rpma_cq **rcq_ptr)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});

if (conn == NULL || rcq_ptr == NULL)
return RPMA_E_INVAL;
Expand All @@ -673,7 +684,7 @@ rpma_conn_apply_remote_peer_cfg(struct rpma_conn *conn,
const struct rpma_peer_cfg *pcfg)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});

if (conn == NULL || pcfg == NULL)
return RPMA_E_INVAL;
Expand Down
28 changes: 14 additions & 14 deletions src/conn_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ int
rpma_conn_cfg_new(struct rpma_conn_cfg **cfg_ptr)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_NOMEM, {});

if (cfg_ptr == NULL)
return RPMA_E_INVAL;
Expand Down Expand Up @@ -139,7 +139,7 @@ rpma_conn_cfg_delete(struct rpma_conn_cfg **cfg_ptr)
free(*cfg_ptr);
*cfg_ptr = NULL;

RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});
return 0;
}

Expand All @@ -150,7 +150,7 @@ int
rpma_conn_cfg_set_timeout(struct rpma_conn_cfg *cfg, int timeout_ms)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});

if (cfg == NULL || timeout_ms < 0)
return RPMA_E_INVAL;
Expand All @@ -167,7 +167,7 @@ int
rpma_conn_cfg_get_timeout(const struct rpma_conn_cfg *cfg, int *timeout_ms)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});

if (cfg == NULL || timeout_ms == NULL)
return RPMA_E_INVAL;
Expand All @@ -184,7 +184,7 @@ int
rpma_conn_cfg_set_cq_size(struct rpma_conn_cfg *cfg, uint32_t cq_size)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});

if (cfg == NULL)
return RPMA_E_INVAL;
Expand Down Expand Up @@ -213,7 +213,7 @@ rpma_conn_cfg_get_cq_size(const struct rpma_conn_cfg *cfg, uint32_t *cq_size)
* and therefore it has to return the correct value of size of CQ,
* if it fails because of fault injection.
*/
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});
return 0;
}

Expand All @@ -224,7 +224,7 @@ int
rpma_conn_cfg_set_rcq_size(struct rpma_conn_cfg *cfg, uint32_t rcq_size)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});

if (cfg == NULL)
return RPMA_E_INVAL;
Expand Down Expand Up @@ -253,7 +253,7 @@ rpma_conn_cfg_get_rcq_size(const struct rpma_conn_cfg *cfg, uint32_t *rcq_size)
* and therefore it has to return the correct value of size of RCQ,
* if it fails because of fault injection.
*/
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});
return 0;
}

Expand All @@ -264,7 +264,7 @@ int
rpma_conn_cfg_set_sq_size(struct rpma_conn_cfg *cfg, uint32_t sq_size)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});

if (cfg == NULL)
return RPMA_E_INVAL;
Expand Down Expand Up @@ -293,7 +293,7 @@ rpma_conn_cfg_get_sq_size(const struct rpma_conn_cfg *cfg, uint32_t *sq_size)
* and therefore it has to return the correct value of size of SQ,
* if it fails because of fault injection.
*/
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});
return 0;
}

Expand All @@ -304,7 +304,7 @@ int
rpma_conn_cfg_set_rq_size(struct rpma_conn_cfg *cfg, uint32_t rq_size)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});

if (cfg == NULL)
return RPMA_E_INVAL;
Expand Down Expand Up @@ -333,7 +333,7 @@ rpma_conn_cfg_get_rq_size(const struct rpma_conn_cfg *cfg, uint32_t *rq_size)
* and therefore it has to return the correct value of size of RQ,
* if it fails because of fault injection.
*/
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});
return 0;
}

Expand All @@ -345,7 +345,7 @@ int
rpma_conn_cfg_set_compl_channel(struct rpma_conn_cfg *cfg, bool shared)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});

if (cfg == NULL)
return RPMA_E_INVAL;
Expand All @@ -363,7 +363,7 @@ int
rpma_conn_cfg_get_compl_channel(const struct rpma_conn_cfg *cfg, bool *shared)
{
RPMA_DEBUG_TRACE;
RPMA_FAULT_INJECTION();
RPMA_FAULT_INJECTION(RPMA_E_INVAL, {});

if (cfg == NULL || shared == NULL)
return RPMA_E_INVAL;
Expand Down
Loading

0 comments on commit 338e099

Please sign in to comment.