Message ID | 2634ad7f-b462-5c69-8aa1-2f200a6beb20@sberdevices.ru (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | vsock: update tools and error handling | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Guessed tree name to be net-next |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/subject_prefix | success | Link |
netdev/cover_letter | success | Series has a cover letter |
netdev/patch_count | success | Link |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/cc_maintainers | success | CCed 3 of 3 maintainers |
netdev/build_clang | success | Errors and warnings before: 0 this patch: 0 |
netdev/module_param | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/check_selftest | success | No net selftest shell script |
netdev/verify_fixes | success | No Fixes tag |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 81 lines checked |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
On Fri, Nov 25, 2022 at 05:13:06PM +0000, Arseniy Krasnov wrote: >This adds test for sending message, bigger than peer's buffer size. >For SOCK_SEQPACKET socket it must fail, as this type of socket has >message size limit. > >Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru> >--- > tools/testing/vsock/vsock_test.c | 69 ++++++++++++++++++++++++++++++++ > 1 file changed, 69 insertions(+) > >diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c >index 12ef0cca6f93..a8e43424fb32 100644 >--- a/tools/testing/vsock/vsock_test.c >+++ b/tools/testing/vsock/vsock_test.c >@@ -569,6 +569,70 @@ static void test_seqpacket_timeout_server(const struct test_opts *opts) > close(fd); > } > >+static void test_seqpacket_bigmsg_client(const struct test_opts *opts) >+{ >+ unsigned long sock_buf_size; >+ ssize_t send_size; >+ socklen_t len; >+ void *data; >+ int fd; >+ >+ len = sizeof(sock_buf_size); >+ >+ fd = vsock_seqpacket_connect(opts->peer_cid, 1234); >+ if (fd < 0) { >+ perror("connect"); >+ exit(EXIT_FAILURE); >+ } >+ >+ if (getsockopt(fd, AF_VSOCK, SO_VM_SOCKETS_BUFFER_SIZE, >+ &sock_buf_size, &len)) { >+ perror("getsockopt"); >+ exit(EXIT_FAILURE); >+ } >+ >+ sock_buf_size++; >+ >+ data = malloc(sock_buf_size); >+ if (!data) { >+ perror("malloc"); >+ exit(EXIT_FAILURE); >+ } >+ >+ send_size = send(fd, data, sock_buf_size, 0); >+ if (send_size != -1) { >+ fprintf(stderr, "expected 'send(2)' failure, got %zi\n", >+ send_size); >+ exit(EXIT_FAILURE); >+ } >+ >+ if (errno != EMSGSIZE) { >+ fprintf(stderr, "expected EMSGSIZE in 'errno', got %i\n", >+ errno); >+ exit(EXIT_FAILURE); >+ } We should make sure that this is true for all transports, but since now only virtio-vsock supports it, we should be okay. >+ >+ control_writeln("CLISENT"); >+ >+ free(data); >+ close(fd); >+} >+ >+static void test_seqpacket_bigmsg_server(const struct test_opts *opts) >+{ >+ int fd; >+ >+ fd = vsock_seqpacket_accept(VMADDR_CID_ANY, 1234, NULL); >+ if (fd < 0) { >+ perror("accept"); >+ exit(EXIT_FAILURE); >+ } >+ >+ control_expectln("CLISENT"); >+ >+ close(fd); >+} >+ > #define BUF_PATTERN_1 'a' > #define BUF_PATTERN_2 'b' > >@@ -851,6 +915,11 @@ static struct test_case test_cases[] = { > .run_client = test_stream_poll_rcvlowat_client, > .run_server = test_stream_poll_rcvlowat_server, > }, >+ { >+ .name = "SOCK_SEQPACKET big message", >+ .run_client = test_seqpacket_bigmsg_client, >+ .run_server = test_seqpacket_bigmsg_server, >+ }, > {}, > }; > >-- >2.25.1 LGTM! Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
On 01.12.2022 12:45, Stefano Garzarella wrote: > On Fri, Nov 25, 2022 at 05:13:06PM +0000, Arseniy Krasnov wrote: >> This adds test for sending message, bigger than peer's buffer size. >> For SOCK_SEQPACKET socket it must fail, as this type of socket has >> message size limit. >> >> Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru> >> --- >> tools/testing/vsock/vsock_test.c | 69 ++++++++++++++++++++++++++++++++ >> 1 file changed, 69 insertions(+) >> >> diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c >> index 12ef0cca6f93..a8e43424fb32 100644 >> --- a/tools/testing/vsock/vsock_test.c >> +++ b/tools/testing/vsock/vsock_test.c >> @@ -569,6 +569,70 @@ static void test_seqpacket_timeout_server(const struct test_opts *opts) >> close(fd); >> } >> >> +static void test_seqpacket_bigmsg_client(const struct test_opts *opts) >> +{ >> + unsigned long sock_buf_size; >> + ssize_t send_size; >> + socklen_t len; >> + void *data; >> + int fd; >> + >> + len = sizeof(sock_buf_size); >> + >> + fd = vsock_seqpacket_connect(opts->peer_cid, 1234); >> + if (fd < 0) { >> + perror("connect"); >> + exit(EXIT_FAILURE); >> + } >> + >> + if (getsockopt(fd, AF_VSOCK, SO_VM_SOCKETS_BUFFER_SIZE, >> + &sock_buf_size, &len)) { >> + perror("getsockopt"); >> + exit(EXIT_FAILURE); >> + } >> + >> + sock_buf_size++; >> + >> + data = malloc(sock_buf_size); >> + if (!data) { >> + perror("malloc"); >> + exit(EXIT_FAILURE); >> + } >> + >> + send_size = send(fd, data, sock_buf_size, 0); >> + if (send_size != -1) { >> + fprintf(stderr, "expected 'send(2)' failure, got %zi\n", >> + send_size); >> + exit(EXIT_FAILURE); >> + } >> + >> + if (errno != EMSGSIZE) { >> + fprintf(stderr, "expected EMSGSIZE in 'errno', got %i\n", >> + errno); >> + exit(EXIT_FAILURE); >> + } > > We should make sure that this is true for all transports, but since now only virtio-vsock supports it, we should be okay. Hm, in general: I've tested this test suite for vmci may be several months ago, and found, that some tests didn't work. I'm thinking about reworking this test suite a little bit: each transport must have own set of tests for features that it supports. I had feeling, that all these tests are run only with virtio transport :) Because for example SEQPACKET mode is suported only for virtio. Thanks > >> + >> + control_writeln("CLISENT"); >> + >> + free(data); >> + close(fd); >> +} >> + >> +static void test_seqpacket_bigmsg_server(const struct test_opts *opts) >> +{ >> + int fd; >> + >> + fd = vsock_seqpacket_accept(VMADDR_CID_ANY, 1234, NULL); >> + if (fd < 0) { >> + perror("accept"); >> + exit(EXIT_FAILURE); >> + } >> + >> + control_expectln("CLISENT"); >> + >> + close(fd); >> +} >> + >> #define BUF_PATTERN_1 'a' >> #define BUF_PATTERN_2 'b' >> >> @@ -851,6 +915,11 @@ static struct test_case test_cases[] = { >> .run_client = test_stream_poll_rcvlowat_client, >> .run_server = test_stream_poll_rcvlowat_server, >> }, >> + { >> + .name = "SOCK_SEQPACKET big message", >> + .run_client = test_seqpacket_bigmsg_client, >> + .run_server = test_seqpacket_bigmsg_server, >> + }, >> {}, >> }; >> >> -- >> 2.25.1 > > LGTM! > > Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> >
On Thu, Dec 01, 2022 at 11:44:39AM +0000, Arseniy Krasnov wrote: >On 01.12.2022 12:45, Stefano Garzarella wrote: >> On Fri, Nov 25, 2022 at 05:13:06PM +0000, Arseniy Krasnov wrote: >>> This adds test for sending message, bigger than peer's buffer size. >>> For SOCK_SEQPACKET socket it must fail, as this type of socket has >>> message size limit. >>> >>> Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru> >>> --- >>> tools/testing/vsock/vsock_test.c | 69 ++++++++++++++++++++++++++++++++ >>> 1 file changed, 69 insertions(+) >>> >>> diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c >>> index 12ef0cca6f93..a8e43424fb32 100644 >>> --- a/tools/testing/vsock/vsock_test.c >>> +++ b/tools/testing/vsock/vsock_test.c >>> @@ -569,6 +569,70 @@ static void test_seqpacket_timeout_server(const struct test_opts *opts) >>> close(fd); >>> } >>> >>> +static void test_seqpacket_bigmsg_client(const struct test_opts *opts) >>> +{ >>> + unsigned long sock_buf_size; >>> + ssize_t send_size; >>> + socklen_t len; >>> + void *data; >>> + int fd; >>> + >>> + len = sizeof(sock_buf_size); >>> + >>> + fd = vsock_seqpacket_connect(opts->peer_cid, 1234); >>> + if (fd < 0) { >>> + perror("connect"); >>> + exit(EXIT_FAILURE); >>> + } >>> + >>> + if (getsockopt(fd, AF_VSOCK, SO_VM_SOCKETS_BUFFER_SIZE, >>> + &sock_buf_size, &len)) { >>> + perror("getsockopt"); >>> + exit(EXIT_FAILURE); >>> + } >>> + >>> + sock_buf_size++; >>> + >>> + data = malloc(sock_buf_size); >>> + if (!data) { >>> + perror("malloc"); >>> + exit(EXIT_FAILURE); >>> + } >>> + >>> + send_size = send(fd, data, sock_buf_size, 0); >>> + if (send_size != -1) { >>> + fprintf(stderr, "expected 'send(2)' failure, got %zi\n", >>> + send_size); >>> + exit(EXIT_FAILURE); >>> + } >>> + >>> + if (errno != EMSGSIZE) { >>> + fprintf(stderr, "expected EMSGSIZE in 'errno', got %i\n", >>> + errno); >>> + exit(EXIT_FAILURE); >>> + } >> >> We should make sure that this is true for all transports, but since now only virtio-vsock supports it, we should be okay. >Hm, in general: I've tested this test suite for vmci may be several months ago, and found, that some tests >didn't work. I'm thinking about reworking this test suite a little bit: each transport must have own set of >tests for features that it supports. I had feeling, that all these tests are run only with virtio transport :) >Because for example SEQPACKET mode is suported only for virtio. Yep, when we developed it, we added the "--skip" param for that. Ideally there should be no difference, but I remember VMCI had a different behavior and we couldn't change it for backward compatibility, so we added "--skip". Thanks, Steano
diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c index 12ef0cca6f93..a8e43424fb32 100644 --- a/tools/testing/vsock/vsock_test.c +++ b/tools/testing/vsock/vsock_test.c @@ -569,6 +569,70 @@ static void test_seqpacket_timeout_server(const struct test_opts *opts) close(fd); } +static void test_seqpacket_bigmsg_client(const struct test_opts *opts) +{ + unsigned long sock_buf_size; + ssize_t send_size; + socklen_t len; + void *data; + int fd; + + len = sizeof(sock_buf_size); + + fd = vsock_seqpacket_connect(opts->peer_cid, 1234); + if (fd < 0) { + perror("connect"); + exit(EXIT_FAILURE); + } + + if (getsockopt(fd, AF_VSOCK, SO_VM_SOCKETS_BUFFER_SIZE, + &sock_buf_size, &len)) { + perror("getsockopt"); + exit(EXIT_FAILURE); + } + + sock_buf_size++; + + data = malloc(sock_buf_size); + if (!data) { + perror("malloc"); + exit(EXIT_FAILURE); + } + + send_size = send(fd, data, sock_buf_size, 0); + if (send_size != -1) { + fprintf(stderr, "expected 'send(2)' failure, got %zi\n", + send_size); + exit(EXIT_FAILURE); + } + + if (errno != EMSGSIZE) { + fprintf(stderr, "expected EMSGSIZE in 'errno', got %i\n", + errno); + exit(EXIT_FAILURE); + } + + control_writeln("CLISENT"); + + free(data); + close(fd); +} + +static void test_seqpacket_bigmsg_server(const struct test_opts *opts) +{ + int fd; + + fd = vsock_seqpacket_accept(VMADDR_CID_ANY, 1234, NULL); + if (fd < 0) { + perror("accept"); + exit(EXIT_FAILURE); + } + + control_expectln("CLISENT"); + + close(fd); +} + #define BUF_PATTERN_1 'a' #define BUF_PATTERN_2 'b' @@ -851,6 +915,11 @@ static struct test_case test_cases[] = { .run_client = test_stream_poll_rcvlowat_client, .run_server = test_stream_poll_rcvlowat_server, }, + { + .name = "SOCK_SEQPACKET big message", + .run_client = test_seqpacket_bigmsg_client, + .run_server = test_seqpacket_bigmsg_server, + }, {}, };
This adds test for sending message, bigger than peer's buffer size. For SOCK_SEQPACKET socket it must fail, as this type of socket has message size limit. Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru> --- tools/testing/vsock/vsock_test.c | 69 ++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+)