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.129.124]) by passt.top (Postfix) with ESMTP id BF1F75A0279 for ; Tue, 13 Feb 2024 19:39:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707849564; 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:autocrypt:autocrypt; bh=eoO1V7FWr+k1nQCinb2ZPypMb6YF8JQMSH/jyBSiLcI=; b=S5DrSjfxQdoL5oz5SiSi0KQ/GM8gARtx0JXGcRatlNFx42W9luglNiIL895ctT29OkGG1/ dtrCEOBaboFpWD18o4pjFMnQsGatOF8BnXQdcRjxTaq635i9aA5sz5HNXHepkmra2AV+HN pTRDdzeykmBbvq334PBkWyN1w5g3XVc= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-625-IdgOeDXLPMe-uOI2OvQHqg-1; Tue, 13 Feb 2024 13:39:23 -0500 X-MC-Unique: IdgOeDXLPMe-uOI2OvQHqg-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-33b226e710dso831289f8f.1 for ; Tue, 13 Feb 2024 10:39:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707849562; x=1708454362; h=mime-version:user-agent:content-transfer-encoding:autocrypt :references:in-reply-to:date:cc:to:from:subject:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Pc6zq8ipr/1RWW2wO3n3l4IMAdT1AegFnZYIl0+Lw/U=; b=kqp6njKa1EWnuZHmG7PyCTIxzULvs24knezthBNPus5BNO2SQdIE2ZVl2HVdPw0u0i JqTl7qZBHjicFgeZWtiD03L5PK01Y78FoHNRxwNRjW+/ShoXad65Oojv6HmfmVrCTgqP OKvMx7ExmdvkrYgA8rCx/9XQOaPLOCki8oW40LdU5o3sydC2qhK+lBV/kamfH27vEmi7 gDXObWzunB60g7RPYYPXhyCGt0q9v6o8J7dWMSvlLQihZYH+oyWKF+0QHukWUHrEZOC9 l4CIOGoA35TYthPYSSs1yOBVIc48ly/HbFpvMXJiBOAuKAH9ykgfBFacfbG1GV2SY3iQ Ks7A== X-Forwarded-Encrypted: i=1; AJvYcCX0oOg7LXFm3hCt7XDMpVEm4QN9DArWKQ49dwYzB6qKgfGeJapK4E8vtyTtJ0JhrTs5Kr0nTTfiF1Lio8/znhjRVNRP X-Gm-Message-State: AOJu0YwA7zbPg31c/YXcGMEzWKF3yOacdS+Bir5LjAxU7NvbHC0FSLue wxybpJubQ3SX2eC4KmNfWYwOtqx0nhg4rHlkkL/+OxQxEC9f6GxOdoDrpMbvJuOwl+0BCG/4j0J Aej/Cfu6hO7fZSywycwJ8zbAmUkjs810zvQu9zueVAmCQyShwAQ== X-Received: by 2002:a05:600c:5127:b0:40f:c34a:b69 with SMTP id o39-20020a05600c512700b0040fc34a0b69mr363967wms.2.1707849561888; Tue, 13 Feb 2024 10:39:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGPp2rSeOwCEAum0FsiP3dr4kFDpRL7nrpDnTLLbayjDluiqxfGjnOLfN3vAdgUdOGV18xFlQ== X-Received: by 2002:a05:600c:5127:b0:40f:c34a:b69 with SMTP id o39-20020a05600c512700b0040fc34a0b69mr363956wms.2.1707849561576; Tue, 13 Feb 2024 10:39:21 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUaSDfJFM62i0FJ6mC6gzWo+nr5iUTLcSjCeH7cU/Crx3PwRWDd1s09Qr7U2nNUBbv242iRmlNcJMWnzj/qC/YmAlKwIdVCREID6prl62aSgKvZ+NzbtYAFkRMij2TNOxR55QtnVqH0iMAvEr/P1fz53x3cRqtzTkre6P2s//Ie76Mi9ZcK5jfkmEK0WYwATlZU9SEBOtISrMakJWj+dcTNXi3WwsoOnMP0c5IV/pf7FGiblDu69VsAt59Ps+YJ2g== Received: from gerbillo.redhat.com (146-241-230-54.dyn.eolo.it. [146.241.230.54]) by smtp.gmail.com with ESMTPSA id h16-20020a05600c351000b00410e6a6403esm5836378wmq.34.2024.02.13.10.39.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 10:39:21 -0800 (PST) Message-ID: <725a92b4813242549f2316e6682d3312b5e658d8.camel@redhat.com> Subject: Re: [PATCH v3] tcp: add support for SO_PEEK_OFF From: Paolo Abeni To: Eric Dumazet Date: Tue, 13 Feb 2024 19:39:19 +0100 In-Reply-To: References: <20240209221233.3150253-1-jmaloy@redhat.com> <8d77d8a4e6a37e80aa46cd8df98de84714c384a5.camel@redhat.com> <20072ba530b34729589a3d527c420a766b49e205.camel@redhat.com> Autocrypt: addr=pabeni@redhat.com; prefer-encrypt=mutual; keydata=mQINBGISiDUBEAC5uMdJicjm3ZlWQJG4u2EU1EhWUSx8IZLUTmEE8zmjPJFSYDcjtfGcbzLPb63BvX7FADmTOkO7gwtDgm501XnQaZgBUnCOUT8qv5MkKsFH20h1XJyqjPeGM55YFAXc+a4WD0YyO5M0+KhDeRLoildeRna1ey944VlZ6Inf67zMYw9vfE5XozBtytFIrRyGEWkQwkjaYhr1cGM8ia24QQVQid3P7SPkR78kJmrT32sGk+TdR4YnZzBvVaojX4AroZrrAQVdOLQWR+w4w1mONfJvahNdjq73tKv51nIpu4SAC1Zmnm3x4u9r22mbMDr0uWqDqwhsvkanYmn4umDKc1ZkBnDIbbumd40x9CKgG6ogVlLYeJa9WyfVMOHDF6f0wRjFjxVoPO6p/ZDkuEa67KCpJnXNYipLJ3MYhdKWBZw0xc3LKiKc+nMfQlo76T/qHMDfRMaMhk+L8gWc3ZlRQFG0/Pd1pdQEiRuvfM5DU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iVlUQhRgemQSkhfNaP9LqR1XKujlTuUTpoyT3xwAzkmSxN1nABoutHEO/N87fpIbpbZaIdinF7b9srwUvDOKsywfs5HMiUZhLKoZzCcU/AEFjQsPTATACGsWf3JYPnWxL9 User-Agent: Evolution 3.50.3 (3.50.3-1.fc39) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-MailFrom: pabeni@redhat.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation Message-ID-Hash: RDBU6CAL3PIK2FPZZMIF66CD4LT6X42J X-Message-ID-Hash: RDBU6CAL3PIK2FPZZMIF66CD4LT6X42J X-Mailman-Approved-At: Wed, 14 Feb 2024 00:18:46 +0100 CC: kuba@kernel.org, passt-dev@passt.top, sbrivio@redhat.com, lvivier@redhat.com, dgibson@redhat.com, jmaloy@redhat.com, netdev@vger.kernel.org, davem@davemloft.net 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 Tue, 2024-02-13 at 16:49 +0100, Eric Dumazet wrote: > On Tue, Feb 13, 2024 at 4:28=E2=80=AFPM Paolo Abeni w= rote: > > On Tue, 2024-02-13 at 14:34 +0100, Eric Dumazet wrote: > > > This sk_peek_offset protocol, needing sk_peek_offset_bwd() in the no= n > > > MSG_PEEK case is very strange IMO. > > >=20 > > > Ideally, we should read/write over sk_peek_offset only when MSG_PEEK > > > is used by the caller. > > >=20 > > > That would only touch non fast paths. > > >=20 > > > Since the API is mono-threaded anyway, the caller should not rely on > > > the fact that normal recvmsg() call > > > would 'consume' sk_peek_offset. > >=20 > > Storing in sk_peek_seq the tcp next sequence number to be peeked should > > avoid changes in the non MSG_PEEK cases. > >=20 > > AFAICS that would need a new get_peek_off() sock_op and a bit somewhere > > (in sk_flags?) to discriminate when sk_peek_seq is actually set. Would > > that be acceptable? >=20 > We could have a parallel SO_PEEK_OFFSET option, reusing the same socket f= ield. >=20 > The new semantic would be : Supported by TCP (so far), and tcp > recvmsg() only reads/writes this field when MSG_PEEK is used. > Applications would have to clear the values themselves. I feel like there is some misunderstanding, or at least I can't follow. Let me be more verbose, to try to clarify my reasoning. Two consecutive recvmsg(MSG_PEEK) calls for TCP after SO_PEEK_OFF will return adjacent data. AFAICS this is the same semantic currently implemented by UDP and unix sockets. Currently 'sk_peek_off' maintains the next offset to be peeked into the current receive queue. To implement the above behaviour, tcp_recvmsg() has to update 'sk_peek_off' after MSG_PEEK, to move the offset to the next data, and after a plain read, to account for the data removed from the receive queue. I proposed to let introduce a tcp-specific set_peek_off doing something alike: =09WRTIE_ONCE(sk->sk_peek_off, tcp_sk(sk)->copied_seq + val); so that the recvmsg will need to update sk_peek_off only for MSG_PEEK, while retaining the semantic described above. To keep the userspace interface unchanged that will need a paired tcp_get_peek_off(), so that getsockopt(SO_PEEK_OFF) could return to the user a plain offset. An additional bit flag will be needed to store the information "the user-space enabled peek with offset". I don't understand how a setsockopt(PEEK_OFFSET) variant would help avoiding touching sk->sk_peek_offset? Thanks! Paolo