Skip to content

Commit b810027

Browse files
gal-pressmannmorey
authored andcommitted
verbs: Fix pingpong buffer validation
[ Upstream commit 257470c ] The buffer allocated in the UD test has extra 40 bytes reserved for GRH for both the client and the server, while the actual payload starts at offset 40. Since the buffer validation applies to the payload only, we should take this offset into account: As the sender, make sure to fill the payload starting at offset 40 as all data before that will not be sent on ibv_post_send. As the receiver, make sure to validate the payload starting at offset 40 as all data before that is not part of the actual payload (GRH/not valid). Also, The buffer validation option doesn't require an extra parameter, remove the extra ':' from all ibv_*_pingpong examples. Fixes: 099c5aa ("libibverb/examples: Add command line option to enable buffer validation") Cc: Yuval Shaia <yuval.shaia@oracle.com> Signed-off-by: Gal Pressman <galpress@amazon.com> Reviewed-by: Yishai Hadas <yishaih@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
1 parent c0f34ae commit b810027

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

libibverbs/examples/srq_pingpong.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ int main(int argc, char *argv[])
669669
{}
670670
};
671671

672-
c = getopt_long(argc, argv, "p:d:i:s:m:q:r:n:l:eg:c:",
672+
c = getopt_long(argc, argv, "p:d:i:s:m:q:r:n:l:eg:c",
673673
long_options, NULL);
674674
if (c == -1)
675675
break;

libibverbs/examples/uc_pingpong.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ int main(int argc, char *argv[])
572572
{}
573573
};
574574

575-
c = getopt_long(argc, argv, "p:d:i:s:m:r:n:l:eg:c:",
575+
c = getopt_long(argc, argv, "p:d:i:s:m:r:n:l:eg:c",
576576
long_options, NULL);
577577
if (c == -1)
578578
break;

libibverbs/examples/ud_pingpong.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ int main(int argc, char *argv[])
593593
{}
594594
};
595595

596-
c = getopt_long(argc, argv, "p:d:i:s:r:n:l:eg:c:", long_options,
596+
c = getopt_long(argc, argv, "p:d:i:s:r:n:l:eg:c", long_options,
597597
NULL);
598598
if (c == -1)
599599
break;
@@ -747,7 +747,7 @@ int main(int argc, char *argv[])
747747
if (servername) {
748748
if (validate_buf)
749749
for (int i = 0; i < size; i += page_size)
750-
ctx->buf[i] = i / page_size % sizeof(char);
750+
ctx->buf[i + 40] = i / page_size % sizeof(char);
751751

752752
if (pp_post_send(ctx, rem_dest->qpn)) {
753753
fprintf(stderr, "Couldn't post send\n");
@@ -860,7 +860,8 @@ int main(int argc, char *argv[])
860860

861861
if ((!servername) && (validate_buf)) {
862862
for (int i = 0; i < size; i += page_size)
863-
if (ctx->buf[i] != i / page_size % sizeof(char))
863+
if (ctx->buf[i + 40] !=
864+
i / page_size % sizeof(char))
864865
printf("invalid data in page %d\n",
865866
i / page_size);
866867
}

libibverbs/examples/xsrq_pingpong.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ int main(int argc, char *argv[])
876876
{}
877877
};
878878

879-
c = getopt_long(argc, argv, "p:d:i:s:m:c:n:l:eg:", long_options,
879+
c = getopt_long(argc, argv, "p:d:i:s:m:n:l:eg:c", long_options,
880880
NULL);
881881
if (c == -1)
882882
break;

0 commit comments

Comments
 (0)