From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 77BE85A026D for ; Thu, 18 Jan 2024 23:22:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705616576; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QvxBCM7tLuOpwx8+wEAIw7J+J049pbv0MA/RJ2ja7ZE=; b=gpZ5RSeKSP2LONzO2IYd7xDsrB++1cmbDvr3fvgLWQC48Rf/nOH8yLzQxIQl8IRl+eruiI IQQ0CcA5J58216tipzDIwJ9NN03F2//8cgtJ/eGgcX+gpEkZr0pIpAKFXCgPjq6McnIQJ6 JZD0dzAhygPhOH1EvvVOKzAjKGaaYh0= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-262-ItJ8iYnKPc61urGZXiALiQ-1; Thu, 18 Jan 2024 17:22:54 -0500 X-MC-Unique: ItJ8iYnKPc61urGZXiALiQ-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-429a1b96ad2so22463341cf.0 for ; Thu, 18 Jan 2024 14:22:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705616574; x=1706221374; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QvxBCM7tLuOpwx8+wEAIw7J+J049pbv0MA/RJ2ja7ZE=; b=G4vnT8tTqWMzfa9ONK/Z8vTFy7mmZjalIHY1jKE6rohk59yqRYukk954sAY5xM2rJP NmMWNbFNDVHVF3yJprpk9Hfs8J7tV3fr1WA9cKuA669wAGlYXVuGH1yJKHy5rp1O5F3s KXolIke/XjS8hTQNV6Lz+ViYUI1Z/LSXG+5eJoAEjijsF0ykMzo1OHSVZrtEmizkOUIi 8naBg7VHk64lNHqnlWjPjxCc0k/4okMBIw72pdyOx39G6mw/lLuxwcxxm6tFF4Jw+cb6 D8moeavgc7IfrulFMtld9uEOpMmwf8AyRXAxKCXLIpORVNmVsb5obFbnXY79SbgOXF0x YTkw== X-Gm-Message-State: AOJu0YynxHrCNojAQ69/EzhBWA4r1pGNrgN1Al0t/Ul6OT2CC9nKqtRN QBMqlNYmTopObS+8+j2fgcIn/XTsDZRFIC/kip51X7UucqB2evu+IXGtnOCbU582/B5GXz7H8+W 59aQHvXeKd38B8fh6cbTHzkIyDc7Rv7+POWUZ/gACynH3UVZ4iQ== X-Received: by 2002:a05:622a:1b8c:b0:429:f36c:c3a8 with SMTP id bp12-20020a05622a1b8c00b00429f36cc3a8mr54384qtb.29.1705616574113; Thu, 18 Jan 2024 14:22:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHIy/Q9lJrPxvZzjxVCIHrv8RLUIKR9E98DHv+c76z2bAYwxPzJ/nj7XOaWTLW+09+1TQQ/UA== X-Received: by 2002:a05:622a:1b8c:b0:429:f36c:c3a8 with SMTP id bp12-20020a05622a1b8c00b00429f36cc3a8mr54369qtb.29.1705616573815; Thu, 18 Jan 2024 14:22:53 -0800 (PST) Received: from [10.0.0.97] ([24.225.234.80]) by smtp.gmail.com with ESMTPSA id cb27-20020a05622a1f9b00b00429bdb1d705sm7163417qtb.1.2024.01.18.14.22.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 Jan 2024 14:22:53 -0800 (PST) Message-ID: <595d89f1-15b1-537d-f876-0ac4627db535@redhat.com> Date: Thu, 18 Jan 2024 17:22:52 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [RFC net-next] tcp: add support for read with offset when using MSG_PEEK To: Paolo Abeni , netdev@vger.kernel.org, davem@davemloft.net References: <20240111230057.305672-1-jmaloy@redhat.com> From: Jon Maloy In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: 6DTVPXI7VMVCJDSXJULG7V53RVKLXIQO X-Message-ID-Hash: 6DTVPXI7VMVCJDSXJULG7V53RVKLXIQO X-MailFrom: jmaloy@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: kuba@kernel.org, passt-dev@passt.top, sbrivio@redhat.com, lvivier@redhat.com, dgibson@redhat.com X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On 2024-01-16 05:49, Paolo Abeni wrote: > On Thu, 2024-01-11 at 18:00 -0500, jmaloy@redhat.com wrote: >> From: Jon Maloy >> >> When reading received messages from a socket with MSG_PEEK, we may want >> to read the contents with an offset, like we can do with pread/preadv() >> when reading files. Currently, it is not possible to do that. [...] >> + err = -EINVAL; >> + goto out; >> + } >> + peek_offset = msg->msg_iter.__iov[0].iov_len; >> + msg->msg_iter.__iov = &msg->msg_iter.__iov[1]; >> + msg->msg_iter.nr_segs -= 1; >> + msg->msg_iter.count -= peek_offset; >> + len -= peek_offset; >> + *seq += peek_offset; >> + } > IMHO this does not look like the correct interface to expose such > functionality. Doing the same with a different protocol should cause a > SIGSEG or the like, right? I would expect doing the same thing with a different protocol to cause an EFAULT, as it should. But I haven't tried it. This is a change to TCP only, at least until somebody decides to implement it elsewhere (why not?) > > What about using/implementing SO_PEEK_OFF support instead? I looked at SO_PEEK_OFF, and it honestly looks both awkward and limited. We would have to make frequent calls to setsockopt(), something that would beat much of the purpose of this feature. I stand by my opinion here. This feature is simple, non-intrusive, totally backwards compatible and implies no changes to the API or BPI. I would love to hear other opinions on this, though. Regards /jon > > Cheers, > > Paolo >