From patchwork Wed Dec 18 18:07:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Garzarella X-Patchwork-Id: 1212671 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="OMHtU+Fg"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47dNKP6mBGz9sRW for ; Thu, 19 Dec 2019 05:08:09 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727717AbfLRSIG (ORCPT ); Wed, 18 Dec 2019 13:08:06 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:53190 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727677AbfLRSIE (ORCPT ); Wed, 18 Dec 2019 13:08:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576692484; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Vrd2YMHgYqCL3NryYw02VWg7A0uKKgAHx3jq/JxCp5I=; b=OMHtU+FgW0REp8xJ/ry8/u491+lD5SdHl3ZKnDWwAWGziAkI9KqZPczs+koiXBQ6jtyjkn I73lk9hFf/j8d/dHWyQ3UYP8XJDXwbVRStgF8bsPpI/u4oUnxNlNm92Fn3gBj40FjdVi4P R1U1Dg2KRz2CR6ePYtMN+d51VH3rG8w= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-338-8k2LkPvON3iKCuAAOxJTcQ-1; Wed, 18 Dec 2019 13:08:00 -0500 X-MC-Unique: 8k2LkPvON3iKCuAAOxJTcQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 13DD6800D4E; Wed, 18 Dec 2019 18:07:59 +0000 (UTC) Received: from steredhat.redhat.com (ovpn-117-218.ams2.redhat.com [10.36.117.218]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2FBB5D9E2; Wed, 18 Dec 2019 18:07:56 +0000 (UTC) From: Stefano Garzarella To: davem@davemloft.net Cc: Jorgen Hansen , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Hajnoczi , Dexuan Cui , netdev@vger.kernel.org, virtualization@lists.linux-foundation.org, Stefano Garzarella Subject: [PATCH net-next v3 11/11] vsock_test: add SOCK_STREAM MSG_PEEK test Date: Wed, 18 Dec 2019 19:07:08 +0100 Message-Id: <20191218180708.120337-12-sgarzare@redhat.com> In-Reply-To: <20191218180708.120337-1-sgarzare@redhat.com> References: <20191218180708.120337-1-sgarzare@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Test if the MSG_PEEK flags of recv(2) works as expected. Signed-off-by: Stefano Garzarella --- tools/testing/vsock/vsock_test.c | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c index a63e05d6a0f9..1d8b93f1af31 100644 --- a/tools/testing/vsock/vsock_test.c +++ b/tools/testing/vsock/vsock_test.c @@ -178,6 +178,35 @@ static void test_stream_multiconn_server(const struct test_opts *opts) close(fds[i]); } +static void test_stream_msg_peek_client(const struct test_opts *opts) +{ + int fd; + + fd = vsock_stream_connect(opts->peer_cid, 1234); + if (fd < 0) { + perror("connect"); + exit(EXIT_FAILURE); + } + + send_byte(fd, 1, 0); + close(fd); +} + +static void test_stream_msg_peek_server(const struct test_opts *opts) +{ + int fd; + + fd = vsock_stream_accept(VMADDR_CID_ANY, 1234, NULL); + if (fd < 0) { + perror("accept"); + exit(EXIT_FAILURE); + } + + recv_byte(fd, 1, MSG_PEEK); + recv_byte(fd, 1, 0); + close(fd); +} + static struct test_case test_cases[] = { { .name = "SOCK_STREAM connection reset", @@ -198,6 +227,11 @@ static struct test_case test_cases[] = { .run_client = test_stream_multiconn_client, .run_server = test_stream_multiconn_server, }, + { + .name = "SOCK_STREAM MSG_PEEK", + .run_client = test_stream_msg_peek_client, + .run_server = test_stream_msg_peek_server, + }, {}, };