aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Ledford <dledford@redhat.com>2012-10-14 17:03:03 +0000
committerRoland Dreier <roland@purestorage.com>2013-05-06 11:55:24 -0700
commit869a5576e32afc5dd87e53fd899af88c1e4ce928 (patch)
tree69afa467ad92c793c0929c68d3a1f39d870b38cf
parent71b66e91e7952c5132f639786c94848d66eda7e9 (diff)
downloadlibibverbs-869a5576e32afc5dd87e53fd899af88c1e4ce928.tar.gz
ud_pingpong: Don't try to send UD messages larger than MTU
The UD protocol doesn't support message sizes larger than the path MTU. We don't go so far as to check path MTU, but we do check port MTU. This prevents failed runs of the pingpong_ud program with large MTUs. Signed-off-by: Doug Ledford <dledford@redhat.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
-rw-r--r--examples/ud_pingpong.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/examples/ud_pingpong.c b/examples/ud_pingpong.c
index c279ddb..21c551d 100644
--- a/examples/ud_pingpong.c
+++ b/examples/ud_pingpong.c
@@ -324,6 +324,21 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
goto clean_buffer;
}
+ {
+ struct ibv_port_attr port_info = { 0 };
+ int mtu;
+
+ if (ibv_query_port(ctx->context, port, &port_info)) {
+ fprintf(stderr, "Unable to query port info for port %d\n", port);
+ goto clean_device;
+ }
+ mtu = 1 << (port_info.active_mtu + 7);
+ if (size > mtu) {
+ fprintf(stderr, "Requested size larger than port MTU (%d)\n", mtu);
+ goto clean_device;
+ }
+ }
+
if (use_event) {
ctx->channel = ibv_create_comp_channel(ctx->context);
if (!ctx->channel) {