From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0D4FC433EF for ; Wed, 23 Mar 2022 21:24:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241096AbiCWV0T (ORCPT ); Wed, 23 Mar 2022 17:26:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241085AbiCWV0S (ORCPT ); Wed, 23 Mar 2022 17:26:18 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCC30140A0 for ; Wed, 23 Mar 2022 14:24:47 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id mr5-20020a17090b238500b001c67366ae93so7615557pjb.4 for ; Wed, 23 Mar 2022 14:24:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=of3lS3C4xyqKKbsU+moSs1ikc61qhvqtQqy+wDAMLrQ=; b=uWtOwvftzxEvWzoBR1YkI6UbP8cyEw9daRerFL1t3O1UJ054Z8VWIZ4DH/7so5ciEo OoSmA2EVdDoX3joCf5B0+Sf/qg3ijZmLrSvSkHNodw5d/cq6n4EQ8EByH+LzljzaKsWP d1P2FBidP3lr4zGPtYoIT1rtdzOsi7YWwsulRVvnSb8kT01xtmX4xpvuHNNf4nt6E62V zib91ALn4/lOMfsciR1QtcafKJpXNiD4Eec2+XftShRxvfx5XevJ3smDMhSa3jDWBnlv oBVJ+JIhlO1APgPrtOMl7ijKrPOIvM/RNYTN4mNC8oK6vwD1VB7LjFL1HYtnhOSfzwUW +FxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=of3lS3C4xyqKKbsU+moSs1ikc61qhvqtQqy+wDAMLrQ=; b=IJ4CVvmAwGM4AMNCaNvvdtXKUcMAUzAu+1KeR5TGtUxSGFEtr9lVf4TIfp1DXKb7KL UdCmjuu47Aod+Js5HzWrd6O4uEaBUuRBH3sI8nUObax8PJ296NAcG7trrRJwESaJ1nGr mYewO5GOCUBysmsF2jtN2RzggCOv+waHN01L7s2LcyehFR6bUBPYSKoBTYUdxaXSnrsm ooECRv8A2xk9ftuVKTyQXdguDgtilU4M80OTiwV1z4/o0BwDEnm1MPzen/kZ7IwYBJZa B9A2sC5U6mhuh+I0kltYEA5e8WKp4AoaekuKmQ2L+BWZ5JbgJIkEOBxQkXMuKkrqhYLS qOqQ== X-Gm-Message-State: AOAM533ZZKZXeCzhr36aB+k2nmslXRUReUyYgtp1t5Zr4mGiJkf0NXl9 FCfmkaiu0pZA+OXO3xf/Pw6DUg== X-Google-Smtp-Source: ABdhPJxMoT3Z5lzX6OXWoclx16yN+dNVohLYbuDtj12rl00xmU/H1qEDtkkDt5s6wgOLfGGS7YA0MQ== X-Received: by 2002:a17:902:ea0c:b0:154:16a6:7025 with SMTP id s12-20020a170902ea0c00b0015416a67025mr2234091plg.104.1648070687213; Wed, 23 Mar 2022 14:24:47 -0700 (PDT) Received: from ?IPV6:2600:380:6c2b:64bd:fe73:9dda:6321:7703? ([2600:380:6c2b:64bd:fe73:9dda:6321:7703]) by smtp.gmail.com with ESMTPSA id h10-20020a056a001a4a00b004f7c76f29c3sm818008pfv.24.2022.03.23.14.24.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 23 Mar 2022 14:24:46 -0700 (PDT) Message-ID: <77fe836c-ee0e-1465-7469-46f202ad53e6@kernel.dk> Date: Wed, 23 Mar 2022 15:24:44 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH 1/2] io_uring: ensure recv and recvmsg handle MSG_WAITALL correctly Content-Language: en-US To: Pavel Begunkov , Constantine Gavrilov Cc: io-uring@vger.kernel.org, stable@vger.kernel.org References: <20220323153947.142692-1-axboe@kernel.dk> <20220323153947.142692-2-axboe@kernel.dk> <64197456-87f2-e780-186d-272e06ae223b@gmail.com> From: Jens Axboe In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org On 3/23/22 2:52 PM, Pavel Begunkov wrote: > On 3/23/22 20:45, Constantine Gavrilov wrote: >> On Wed, Mar 23, 2022 at 10:14 PM Pavel Begunkov wrote: >>> >>> On 3/23/22 15:39, Jens Axboe wrote: >>>> We currently don't attempt to get the full asked for length even if >>>> MSG_WAITALL is set, if we get a partial receive. If we do see a partial >>>> receive, then just note how many bytes we did and return -EAGAIN to >>>> get it retried. >>>> >>>> The iov is advanced appropriately for the vector based case, and we >>>> manually bump the buffer and remainder for the non-vector case. >>> >>> How datagrams work with MSG_WAITALL? I highly doubt it coalesces 2+ >>> packets to satisfy the length requirement (e.g. because it may move >>> the address back into the userspace). I'm mainly afraid about >>> breaking io_uring users who are using the flag just to fail links >>> when there is not enough data in a packet. >>> >>> -- >>> Pavel Begunkov >> >> Pavel: >> >> Datagrams have message boundaries and the MSG_WAITALL flag does not >> make sense there. I believe it is ignored by receive code on daragram >> sockets. MSG_WAITALL makes sends only on stream sockets, like TCP. The >> manual page says "This flag has no effect for datagram sockets.". > > Missed the line this in mans, thanks, and it's exactly as expected. > The problem is on the io_uring side where with the patch it might > blindly do a second call into the network stack consuming 2+ packets. Right, it should not be applied for datagrams. -- Jens Axboe