Skip to content

Commit

Permalink
HG: add no_overflow option to prevent use of overflow buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
soumagne committed Jun 11, 2024
1 parent 4130014 commit d585ea1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/mercury.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct hg_private_class {
hg_checksum_level_t checksum_level; /* Checksum level */
bool bulk_eager; /* Eager bulk proc */
bool release_input_early; /* Release input early */
bool no_overflow; /* No overflow buffer */
};

/* Info for function map */
Expand Down Expand Up @@ -716,6 +717,12 @@ hg_set_struct(struct hg_private_handle *hg_handle,
HG_GOTO_SUBSYS_ERROR(rpc, error, ret, HG_OVERFLOW,
"Arguments overflow is not supported with XDR");
#endif
HG_CHECK_SUBSYS_ERROR(rpc,
HG_HANDLE_CLASS(&hg_handle->handle)->no_overflow, error, ret,
HG_OVERFLOW,
"Argument overflow detected and overflow mechanism was disabled, "
"please increase eager message size or reduce payload size");

/* Create a bulk descriptor only of the size that is used */
*extra_buf = hg_proc_get_extra_buf(proc);
*extra_buf_size = hg_proc_get_size_used(proc);
Expand Down Expand Up @@ -1110,6 +1117,9 @@ HG_Init_opt2(const char *na_info_string, uint8_t na_listen,
/* Release input early */
hg_class->release_input_early = hg_init_info.release_input_early;

/* No overflow buffer */
hg_class->no_overflow = hg_init_info.no_overflow;

hg_class->hg_class.core_class =
HG_Core_init_opt2(na_info_string, na_listen, version, hg_init_info_p);
HG_CHECK_SUBSYS_ERROR_NORET(cls, hg_class->hg_class.core_class == NULL,
Expand Down
8 changes: 7 additions & 1 deletion src/mercury_core_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ struct hg_init_info {
* beneficial in cases where the RPC execution time is longer than usual.
* Default is: false */
bool release_input_early;

/* Disable use of overflow buffers when RPC message size is above the eager
* message size threshold.
* Default is: false */
bool no_overflow;
};

/* Error return codes:
Expand Down Expand Up @@ -188,7 +193,8 @@ typedef enum {
.request_post_init = 0, .request_post_incr = 0, .auto_sm = false, \
.sm_info_string = NULL, .checksum_level = HG_CHECKSUM_NONE, \
.no_bulk_eager = false, .no_loopback = false, .stats = false, \
.no_multi_recv = false, .release_input_early = false \
.no_multi_recv = false, .release_input_early = false, \
.no_overflow = false \
}

#endif /* MERCURY_CORE_TYPES_H */
6 changes: 4 additions & 2 deletions src/mercury_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ hg_init_info_dup_2_3(
.no_loopback = old_info->no_loopback,
.stats = old_info->stats,
.no_multi_recv = old_info->no_multi_recv,
.release_input_early = old_info->release_input_early};
.release_input_early = old_info->release_input_early,
.no_overflow = false};
na_init_info_dup_4_0(&new_info->na_init_info, &old_info->na_init_info);
}

Expand All @@ -186,7 +187,8 @@ hg_init_info_dup_2_2(
.no_loopback = old_info->no_loopback,
.stats = old_info->stats,
.no_multi_recv = false,
.release_input_early = false};
.release_input_early = false,
.no_overflow = false};
na_init_info_dup_4_0(&new_info->na_init_info, &old_info->na_init_info);
}

Expand Down

0 comments on commit d585ea1

Please sign in to comment.