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 062A939A0018 for ; Fri, 4 Jun 2021 19:30:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 062A939A0018 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-535-IWqPVhi1P-a1htoeNu7lHg-1; Fri, 04 Jun 2021 15:30:56 -0400 X-MC-Unique: IWqPVhi1P-a1htoeNu7lHg-1 Received: by mail-qv1-f72.google.com with SMTP id v19-20020a0ce1d30000b02902187ed4452eso7394881qvl.6 for ; Fri, 04 Jun 2021 12:30:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=3cz+HsNllayk3JvKDrMV7H/TRUBcxaQ1MaCS+x/r39o=; b=nFVJ63ztyBznwiWdpWZYs6zfmBWuMOpODAji8kFX7C4J0IL0A1EjFuNWSdDJnIIFij u2WZ0QN3hPyVJn4o9g2pBoDzFPgfPzTXB8dzwvP+PLSpCNnicqYkyyhWDnTM0X+MWqBO xqUAMY07qE8DlwD2Co85JRdUId9O0R+EXVMzV/08QtKrF/QsnWBjEjj5tN8hCTrmgcL9 ek/cQWvZkWf3+nTppEAVJfsPHh59ztKecg52W+a9J8KoKBfxGybWP+q6zaOzJx+Ovtwb nJzXB9a8twUG7jk1ZSWisuwBtTEsOadEc8EFeTAWh9pOemae4ZO20x8hklIn1w5BAXmT mNpw== X-Gm-Message-State: AOAM531DKw9udRvmTnTI+fpfs90FxcCxQmgmGSIfCbYQMPgJk4q1mJZs /jbOt+M3EAGG/yLtVwstHGBzP8zDZNjOiFwN6MDYTLmkMNmdR6/UmnDG+B6BztcixjsfrYi7HPA XQFJDppksZWPmiCc5ZFwn X-Received: by 2002:a37:8747:: with SMTP id j68mr2966159qkd.165.1622835055671; Fri, 04 Jun 2021 12:30:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEdXPPAf8RpmpxIl46HRl2YC+cGx7on2itfItpe/vispEFvnMGvFaUeOh/pl4IT6lufqkpaA== X-Received: by 2002:a37:8747:: with SMTP id j68mr2966142qkd.165.1622835055504; Fri, 04 Jun 2021 12:30:55 -0700 (PDT) Received: from [192.168.1.16] (198-84-214-74.cpe.teksavvy.com. [198.84.214.74]) by smtp.gmail.com with ESMTPSA id f5sm2880451qkm.124.2021.06.04.12.30.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jun 2021 12:30:54 -0700 (PDT) From: Carlos O'Donell Subject: Re: [PATCH v2 07/25] linux: Add recvvmsg fallback for 64-bit time_t SO_TIMESTAMP{NS} To: Adhemerval Zanella , libc-alpha@sourceware.org References: <20210518205613.1487824-1-adhemerval.zanella@linaro.org> <20210518205613.1487824-8-adhemerval.zanella@linaro.org> Organization: Red Hat Message-ID: <15eeba3e-834a-99ed-fe7e-d57621236b74@redhat.com> Date: Fri, 4 Jun 2021 15:30:54 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210518205613.1487824-8-adhemerval.zanella@linaro.org> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Fri, 04 Jun 2021 19:31:00 -0000 On 5/18/21 4:55 PM, Adhemerval Zanella wrote: > Handle the SO_TIMESTAMP{NS} similar to recvmsg: for > !__ASSUME_TIME64_SYSCALLS it converts the first 32-bit time SO_TIMESTAMP > or SO_TIMESTAMPNS and appends it to the control buffer if has extra > space or returns MSG_CTRUNC otherwise. The 32-bit time field is kept > as-is. > > Also for !__ASSUME_TIME64_SYSCALLS it limits the maximum number of > 'struct mmsghdr *' to IOV_MAX (and also increases the stack size > requirement to IOV_MAX times sizeof (socklen_t)). The Linux imposes > a similar limit to sendmmsg, so bound the array size on recvmmsg is not > unreasonable. And this will be used only on older when building with > 32-bit time support. > > Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 > kernel). LGTM. No regressions on x86_64, i686, ppc64le, aarch64, s390x. Reviewed-by: Carlos O'Donell Tested-by: Carlos O'Donell > --- > sysdeps/unix/sysv/linux/recvmmsg.c | 17 +++++++++++++++-- > 1 file changed, 15 insertions(+), 2 deletions(-) > > diff --git a/sysdeps/unix/sysv/linux/recvmmsg.c b/sysdeps/unix/sysv/linux/recvmmsg.c > index 672ba20332..5cd107ffa9 100644 > --- a/sysdeps/unix/sysv/linux/recvmmsg.c > +++ b/sysdeps/unix/sysv/linux/recvmmsg.c > @@ -44,13 +44,26 @@ __recvmmsg64 (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags, > ts32 = valid_timespec64_to_timespec (*timeout); > pts32 = &ts32; > } > + > + socklen_t csize[IOV_MAX]; > + if (vlen > IOV_MAX) > + vlen = IOV_MAX; > + for (int i = 0; i < vlen; i++) > + csize[i] = vmessages[i].msg_hdr.msg_controllen; > + > # ifdef __ASSUME_RECVMMSG_SYSCALL > r = SYSCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, pts32); > # else > r = SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, pts32); > # endif > - if (r >= 0 && timeout != NULL) > - *timeout = valid_timespec_to_timespec64 (ts32); > + if (r >= 0) > + { > + if (timeout != NULL) > + *timeout = valid_timespec_to_timespec64 (ts32); > + > + for (int i=0; i < r; i++) > + __convert_scm_timestamps (&vmessages[i].msg_hdr, csize[i]); OK. Use existing __convert_scm_timestamps (908d356af09284fbfedd25da3deb6af8898947e8). > + } > #endif /* __ASSUME_TIME64_SYSCALLS */ > return r; > } > -- Cheers, Carlos.