From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 7F6123855000 for ; Mon, 5 Jul 2021 19:32:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7F6123855000 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-207-kHPapBTwPo-YzxYahb6JAg-1; Mon, 05 Jul 2021 15:32:21 -0400 X-MC-Unique: kHPapBTwPo-YzxYahb6JAg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 10FC08042DE; Mon, 5 Jul 2021 19:32:20 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-115-5.ams2.redhat.com [10.36.115.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 14AFA60C81; Mon, 5 Jul 2021 19:32:18 +0000 (UTC) From: Florian Weimer To: Adhemerval Zanella via Libc-alpha Subject: Re: [PATCH 6/7] socket: Add recvmsg timestamp test References: <20210705183027.3804093-1-adhemerval.zanella@linaro.org> <20210705183027.3804093-7-adhemerval.zanella@linaro.org> Date: Mon, 05 Jul 2021 21:32:17 +0200 In-Reply-To: <20210705183027.3804093-7-adhemerval.zanella@linaro.org> (Adhemerval Zanella via Libc-alpha's message of "Mon, 5 Jul 2021 15:30:26 -0300") Message-ID: <87a6n0k14u.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jul 2021 19:32:23 -0000 * Adhemerval Zanella via Libc-alpha: > The test check if SO_TIMESTAMP and SO_TIMESTAMPNS is correctly > generated. The recvmsg() is called with different ancilliary data > buffers, to check if the conversion for 64-bit time on 32-bit > legacy ABIs are handled correctly. > > For such archicutures, depending of the remmaning ancially data =E2=80=9Carchitectures=E2=80=9D, =E2=80=9Cremaining=E2=80=9D > space the timestamp can not be appended and MSG_TRUNC is returned > instead. =E2=80=9Ccannot=E2=80=9D > +static void > +do_recvmsg (int s, bool support_64_timestamp, void *cmsg, size_t slack, > +=09 size_t tsize, int exp_msg) > +{ > + /* A timestamp is expected if 32-bit timestamp are used (support in ev= ery > + configuration) or if underlying kernel support 64-bit timestamps. =E2=80=9Cif [the] underlying kernel support[s]=E2=80=9D > + Otherwise recvmsg will need extra space do add the 64-bit timestamp= . */ =E2=80=9Cspace [t]o add=E2=80=9D > + /* If there is not timestamp in the ancilliary data, recvmsg should se= t =E2=80=9Cno[] timestamp=E2=80=9D > + the flag inidcating it. */ =E2=80=9Cindicating=E2=80=9D > + /* Setup the ancillary data buffer with an extra page with PROT_NONE t= o > + check the possible timestamp conversion on some systems. */ > + pagesize =3D sysconf (_SC_PAGESIZE); > + if (pagesize =3D=3D -1) > + FAIL_EXIT1 ("sysconf (_SC_PAGESIZE): %m\n"); > + void *msgbuf =3D xmmap (0, 2 * pagesize, PROT_NONE, > +=09=09 =09MAP_ANONYMOUS | MAP_PRIVATE, -1); > + xmprotect (msgbuf, pagesize, PROT_READ | PROT_WRITE); Isn't this support_next_to_fault_allocate? > + > + do_test_send (&srv_addr, 1); > + do_recvmsg (srv, false, NULL, 0, 0, 0); > + > + /* If underlying kernel does not support */ > + bool support_64_timestamp =3D support_socket_time64_timestamp (srv); > + > + /* Enable the timestamp using struct timeval precision. */ > + xsetsockopt (srv, SOL_SOCKET, SO_TIMESTAMP, &(int){1}, sizeof (int)); Please use setsockopt here, nt the x wrapper, so that the ABI switches with time64 support. > + do_test_send (&srv_addr, array_length (slack)); > + for (int s =3D 0; s < array_length (slack); s++) > + do_recvmsg (srv, support_64_timestamp, msgbuf, slack[s], > +=09=09sizeof (struct timeval), s); > + > + /* Now enable timestamp using a higher precision, it overwrites the pr= evious > + precision. */ > + xsetsockopt (srv, SOL_SOCKET, SO_TIMESTAMPNS, &(int){1}, sizeof (int))= ; Likewise here. Thanks, Florian