Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp4694837rwo; Tue, 25 Jul 2023 09:34:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlHufqnqQ/x0DFqqZ+8Vm1P/WAJ/KTLHfof4W83QB99j5DayqViITEywIG/pC+3mqZa4qcog X-Received: by 2002:a17:906:64d5:b0:993:d7fe:7f1d with SMTP id p21-20020a17090664d500b00993d7fe7f1dmr14854960ejn.28.1690302880326; Tue, 25 Jul 2023 09:34:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690302880; cv=none; d=google.com; s=arc-20160816; b=wNRpOdF9i993Hu+sFP07b74jrGNElvjYlwQ5U99wsHwJ4B1AKq34dt5fQrJlZLU2vy bo40Y+oaKzPLHhkD0YNLiKqMWcLyCmNYtLL6fqlmiYGwhHfGJKHhnCPXL5TzHlF1aZEF Pcj34U31oM9+LyDHPU7vB4PcJyMLhUKKsmuZDZMkpQknpF4RiUHZ+/guxqfwk5x6OJT0 fVC+af/RqCjOR+EfMcPdhljPqyuBDFCHZewCNw7WxuoFg7bxBNc2ufLccaBxsAEb/4Tp km2t0JdjeuW/JpmJY3LmslUw2c80zadccDDpVZFHDXJvLWGEQRF06BNGW2J1CX/rO3oq 0WrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=DtjuQEYBysLf5IPBPQqG0dtkZp2a3tmx6LZMEFCT4Do=; fh=LmSvGF8mKyhe+4SfmYOr3uCnhF0XAFkKvuoevTchCp0=; b=C4ENpXfHaXtvX2D+JGexRT9NHjIl8mk65FjPXWXKj3Wb5AZAGBNIdtExaAZjwGDrl2 DW9UF7Ni0fjGnzMyXTiyveJGvI/+hGZDg+ex0ciQg/XEFozd3lCdjUfn+StYCj+ICF6W 8TSpebmya1qlUadzCiNUe6R8kFcXhOhiOZUbjOxKQi1zWlGve1X6TWQaJAD5px4ovXKj TtNtgFOKWDA+vaKkqJp5n2ZU80D0TsnQTkVOp/mrIV0ycorXWUPW3eqVTUoxNdx7Imue /6iYxJOlOTqJd5ngfVTx/oZHOx9nFldYgqXX8I3gO5GyEJfgMpg5imM9q4znxCIdG/03 GJdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=A1ci2n3N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bn5-20020a170906c0c500b009932d8a227asi8621851ejb.277.2023.07.25.09.34.15; Tue, 25 Jul 2023 09:34:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=A1ci2n3N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231183AbjGYPlR (ORCPT + 99 others); Tue, 25 Jul 2023 11:41:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232281AbjGYPk5 (ORCPT ); Tue, 25 Jul 2023 11:40:57 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2C171FD6 for ; Tue, 25 Jul 2023 08:40:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690299608; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=DtjuQEYBysLf5IPBPQqG0dtkZp2a3tmx6LZMEFCT4Do=; b=A1ci2n3NJ942VeOflzhPUyRN05uN7KPYCbPu/I2/ew62vwZRS3PiyNBQqoGYuXSPW0fGAa az+Cl++nq1HapAXVyYapV7pJ/qL9Y4aHXeE4k3XqJF01SbgTvZO+Ef129HZ2CvLjXrLRHD HRjI2+OEN/5lbffEq9apNRZXbdmu1oQ= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-6-X0O-CB4uOG6FbXMrepft3A-1; Tue, 25 Jul 2023 11:40:06 -0400 X-MC-Unique: X0O-CB4uOG6FbXMrepft3A-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-76839756ba4so801223185a.0 for ; Tue, 25 Jul 2023 08:40:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690299606; x=1690904406; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=DtjuQEYBysLf5IPBPQqG0dtkZp2a3tmx6LZMEFCT4Do=; b=jRgoMCcQAtnkzME3Vs5+SMSj/cqXDArGbHr8cIzJ2TAwPv6pztYN03c/NYoLLxo+62 qCbpLcoEs+aKgYxlZgSRz+dTxdxjXcbC65Q7PMH/0fWVZl0TWogu0wcp0l1ZGq+Gc0Mi x4ap7o0CMCbDemaqq/mQtzHhTIvqbMeW5ib2ttvB3vK9Bupdux7H5qW1auJgFxyujhOA GoJTX4pf+QuIlQzEPMWmMjIoVt0F1FyJXeoTvIes/HOG8DIWLAUr84LGBzsJ26gLZz/J iUdDGpokoHR/3olmO8IzTlMTbVXD/NiYGKs/n9KIhMeHdAPEHmYcMv1vRFu83NbbCcsp IYgw== X-Gm-Message-State: ABy/qLZLHbFc/vL33IUjqb8Ur07LBRvDT5QmWlwxllonkjlyCOH2OubU /xJCkWim+cwpZCAqwbJ6pgklqvNm4X8vZFzcj8Cmf/By9fp7kr0w5934w+hbi4h9qRcOrNDmvSA eaHIbujqBKP1kR9pbGTf27YZC X-Received: by 2002:a05:620a:218b:b0:767:dd72:68a0 with SMTP id g11-20020a05620a218b00b00767dd7268a0mr3217548qka.73.1690299605987; Tue, 25 Jul 2023 08:40:05 -0700 (PDT) X-Received: by 2002:a05:620a:218b:b0:767:dd72:68a0 with SMTP id g11-20020a05620a218b00b00767dd7268a0mr3217536qka.73.1690299605744; Tue, 25 Jul 2023 08:40:05 -0700 (PDT) Received: from sgarzare-redhat ([193.207.153.113]) by smtp.gmail.com with ESMTPSA id 4-20020a05620a06c400b00765a676b75csm3751894qky.21.2023.07.25.08.40.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 08:40:05 -0700 (PDT) Date: Tue, 25 Jul 2023 17:39:59 +0200 From: Stefano Garzarella To: Arseniy Krasnov Cc: Stefan Hajnoczi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Michael S. Tsirkin" , Jason Wang , Bobby Eshleman , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@sberdevices.ru, oxffffaa@gmail.com Subject: Re: [RFC PATCH v2 3/4] vsock/test: rework MSG_PEEK test for SOCK_STREAM Message-ID: References: <20230719192708.1775162-1-AVKrasnov@sberdevices.ru> <20230719192708.1775162-4-AVKrasnov@sberdevices.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20230719192708.1775162-4-AVKrasnov@sberdevices.ru> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 19, 2023 at 10:27:07PM +0300, Arseniy Krasnov wrote: >This new version makes test more complicated by adding empty read, >partial read and data comparisons between MSG_PEEK and normal reads. > >Signed-off-by: Arseniy Krasnov >--- > tools/testing/vsock/vsock_test.c | 78 ++++++++++++++++++++++++++++++-- > 1 file changed, 75 insertions(+), 3 deletions(-) Reviewed-by: Stefano Garzarella > >diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c >index ac1bd3ac1533..444a3ff0681f 100644 >--- a/tools/testing/vsock/vsock_test.c >+++ b/tools/testing/vsock/vsock_test.c >@@ -255,9 +255,14 @@ static void test_stream_multiconn_server(const struct test_opts *opts) > close(fds[i]); > } > >+#define MSG_PEEK_BUF_LEN 64 >+ > static void test_stream_msg_peek_client(const struct test_opts *opts) > { >+ unsigned char buf[MSG_PEEK_BUF_LEN]; >+ ssize_t send_size; > int fd; >+ int i; > > fd = vsock_stream_connect(opts->peer_cid, 1234); > if (fd < 0) { >@@ -265,12 +270,32 @@ static void test_stream_msg_peek_client(const struct test_opts *opts) > exit(EXIT_FAILURE); > } > >- send_byte(fd, 1, 0); >+ for (i = 0; i < sizeof(buf); i++) >+ buf[i] = rand() & 0xFF; >+ >+ control_expectln("SRVREADY"); >+ >+ send_size = send(fd, buf, sizeof(buf), 0); >+ >+ if (send_size < 0) { >+ perror("send"); >+ exit(EXIT_FAILURE); >+ } >+ >+ if (send_size != sizeof(buf)) { >+ fprintf(stderr, "Invalid send size %zi\n", send_size); >+ exit(EXIT_FAILURE); >+ } >+ > close(fd); > } > > static void test_stream_msg_peek_server(const struct test_opts *opts) > { >+ unsigned char buf_half[MSG_PEEK_BUF_LEN / 2]; >+ unsigned char buf_normal[MSG_PEEK_BUF_LEN]; >+ unsigned char buf_peek[MSG_PEEK_BUF_LEN]; >+ ssize_t res; > int fd; > > fd = vsock_stream_accept(VMADDR_CID_ANY, 1234, NULL); >@@ -279,8 +304,55 @@ static void test_stream_msg_peek_server(const struct test_opts *opts) > exit(EXIT_FAILURE); > } > >- recv_byte(fd, 1, MSG_PEEK); >- recv_byte(fd, 1, 0); >+ /* Peek from empty socket. */ >+ res = recv(fd, buf_peek, sizeof(buf_peek), MSG_PEEK | MSG_DONTWAIT); >+ if (res != -1) { >+ fprintf(stderr, "expected recv(2) failure, got %zi\n", res); >+ exit(EXIT_FAILURE); >+ } >+ >+ if (errno != EAGAIN) { >+ perror("EAGAIN expected"); >+ exit(EXIT_FAILURE); >+ } >+ >+ control_writeln("SRVREADY"); >+ >+ /* Peek part of data. */ >+ res = recv(fd, buf_half, sizeof(buf_half), MSG_PEEK); >+ if (res != sizeof(buf_half)) { >+ fprintf(stderr, "recv(2) + MSG_PEEK, expected %zu, got %zi\n", >+ sizeof(buf_half), res); >+ exit(EXIT_FAILURE); >+ } >+ >+ /* Peek whole data. */ >+ res = recv(fd, buf_peek, sizeof(buf_peek), MSG_PEEK); >+ if (res != sizeof(buf_peek)) { >+ fprintf(stderr, "recv(2) + MSG_PEEK, expected %zu, got %zi\n", >+ sizeof(buf_peek), res); >+ exit(EXIT_FAILURE); >+ } >+ >+ /* Compare partial and full peek. */ >+ if (memcmp(buf_half, buf_peek, sizeof(buf_half))) { >+ fprintf(stderr, "Partial peek data mismatch\n"); >+ exit(EXIT_FAILURE); >+ } >+ >+ res = recv(fd, buf_normal, sizeof(buf_normal), 0); >+ if (res != sizeof(buf_normal)) { >+ fprintf(stderr, "recv(2), expected %zu, got %zi\n", >+ sizeof(buf_normal), res); >+ exit(EXIT_FAILURE); >+ } >+ >+ /* Compare full peek and normal read. */ >+ if (memcmp(buf_peek, buf_normal, sizeof(buf_peek))) { >+ fprintf(stderr, "Full peek data mismatch\n"); >+ exit(EXIT_FAILURE); >+ } >+ > close(fd); > } > >-- >2.25.1 >