Skip to content

Commit 7ce1c09

Browse files
Konstantin ShkolnyyPaolo Abeni
authored andcommitted
vsock/test: fix failures due to wrong SO_RCVLOWAT parameter
This happens on 64-bit big-endian machines. SO_RCVLOWAT requires an int parameter. However, instead of int, the test uses unsigned long in one place and size_t in another. Both are 8 bytes long on 64-bit machines. The kernel, having received the 8 bytes, doesn't test for the exact size of the parameter, it only cares that it's >= sizeof(int), and casts the 4 lower-addressed bytes to an int, which, on a big-endian machine, contains 0. 0 doesn't trigger an error, SO_RCVLOWAT returns with success and the socket stays with the default SO_RCVLOWAT = 1, which results in vsock_test failures, while vsock_perf doesn't even notice that it's failed to change it. Fixes: b134633 ("vsock_test: POLLIN + SO_RCVLOWAT test") Fixes: 542e893 ("vsock/test: two tests to check credit update logic") Fixes: 8abbffd ("test/vsock: vsock_perf utility") Signed-off-by: Konstantin Shkolnyy <[email protected]> Reviewed-by: Stefano Garzarella <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 4615855 commit 7ce1c09

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

tools/testing/vsock/vsock_perf.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static float get_gbps(unsigned long bits, time_t ns_delta)
133133
((float)ns_delta / NSEC_PER_SEC);
134134
}
135135

136-
static void run_receiver(unsigned long rcvlowat_bytes)
136+
static void run_receiver(int rcvlowat_bytes)
137137
{
138138
unsigned int read_cnt;
139139
time_t rx_begin_ns;
@@ -163,7 +163,7 @@ static void run_receiver(unsigned long rcvlowat_bytes)
163163
printf("Listen port %u\n", port);
164164
printf("RX buffer %lu bytes\n", buf_size_bytes);
165165
printf("vsock buffer %lu bytes\n", vsock_buf_bytes);
166-
printf("SO_RCVLOWAT %lu bytes\n", rcvlowat_bytes);
166+
printf("SO_RCVLOWAT %d bytes\n", rcvlowat_bytes);
167167

168168
fd = socket(AF_VSOCK, SOCK_STREAM, 0);
169169

@@ -439,7 +439,7 @@ static long strtolx(const char *arg)
439439
int main(int argc, char **argv)
440440
{
441441
unsigned long to_send_bytes = DEFAULT_TO_SEND_BYTES;
442-
unsigned long rcvlowat_bytes = DEFAULT_RCVLOWAT_BYTES;
442+
int rcvlowat_bytes = DEFAULT_RCVLOWAT_BYTES;
443443
int peer_cid = -1;
444444
bool sender = false;
445445

tools/testing/vsock/vsock_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ static void test_stream_poll_rcvlowat_server(const struct test_opts *opts)
835835

836836
static void test_stream_poll_rcvlowat_client(const struct test_opts *opts)
837837
{
838-
unsigned long lowat_val = RCVLOWAT_BUF_SIZE;
838+
int lowat_val = RCVLOWAT_BUF_SIZE;
839839
char buf[RCVLOWAT_BUF_SIZE];
840840
struct pollfd fds;
841841
short poll_flags;
@@ -1357,7 +1357,7 @@ static void test_stream_rcvlowat_def_cred_upd_client(const struct test_opts *opt
13571357
static void test_stream_credit_update_test(const struct test_opts *opts,
13581358
bool low_rx_bytes_test)
13591359
{
1360-
size_t recv_buf_size;
1360+
int recv_buf_size;
13611361
struct pollfd fds;
13621362
size_t buf_size;
13631363
void *buf;

0 commit comments

Comments
 (0)