Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp5470022rwb; Wed, 9 Aug 2023 04:56:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFlwSRHWuCEBXs4MEAdTDA7M3m5hKWb5sDeGOoG1Rg5Sv7YJJcp4i5L/+/L+VebaLHjFohU X-Received: by 2002:a17:907:86a8:b0:98d:f2c9:a1eb with SMTP id qa40-20020a17090786a800b0098df2c9a1ebmr1558552ejc.24.1691582162399; Wed, 09 Aug 2023 04:56:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691582162; cv=none; d=google.com; s=arc-20160816; b=p1gndWKhbWMM6DgUehpDuh2bSf1alRTo78803w3YxbbqYaDLFmQgjGoE6sCzb9emyl N//Je/jiyjXrZppiIEFKJWZFl5k+KbILrmzS22ugJKw94oqiSE0Aha9/+VgMmc1AXv0T +HayynFT6Aw4JWGAPhS+mRxpgMcxPwuSKQNHJPRXrFHfwSm1mV29la8QZHLDgI3b+2dw 2/nnRU9xYrjdOdCHGwGTK7FdsspUJop1OxaO8/KcZnjM0xQ06NNXISIbHOv6T09FRZiW WVIPq/jLsXyCb3bqVOdz7bV4HZJn+yIGBCWf7hSsut2uuLLqG40RdnjFpUYpv0fFTI6s 1ZsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=POZx1Czjl+EpbVC1OkzexxsQSbMIz0qrEmbKh1sujrs=; fh=slJMR/EE2mKtxtVoeivh1nXJazsz7aw6Mw62yyinNw4=; b=S/ahQWQqNiwLfwBiTO3vKeS1f7mIfmvt+Av1F/R9upDuC3eHcP8OZQugMbgOL9c59f 9ANqwS/frswVSHTO8Xu0GXhJ02kongjG+2CN8HFlx6hNr4Wyb8kC8hQOQiCJISkvWgnm NGCLyG69GRfbh5J0Rfx+T4PbqoBSOe6HBVs/l9Wnpl5rbQsk095iCZhAehdXwOQdzG8S OPaOHWLxPAyEzTqJaVTIxfHoaHVvkSHRlg+rPhMNo5/REiDoL2+RzHw0/kLgE2lalwYi 6atseUlYqsvS3KP6NbzV/phA8P8YVajn0s+k+8TuM9SxacALSP05m4NGWNIkeUQJ9pXM WwvA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x15-20020a170906134f00b00993860a6d3bsi7948623ejb.518.2023.08.09.04.55.37; Wed, 09 Aug 2023 04:56:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231540AbjHIJlI (ORCPT + 99 others); Wed, 9 Aug 2023 05:41:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231284AbjHIJlI (ORCPT ); Wed, 9 Aug 2023 05:41:08 -0400 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B788A1FDF; Wed, 9 Aug 2023 02:41:03 -0700 (PDT) Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-99c10ba30afso149166266b.1; Wed, 09 Aug 2023 02:41:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691574062; x=1692178862; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=POZx1Czjl+EpbVC1OkzexxsQSbMIz0qrEmbKh1sujrs=; b=B4a39S9KTbq8bLxQqLKVJXrN+p/wwuQ66aRgmEm5JgM5w4yyrmKMaUsByr7pdjkmOC M+L4ZWD9Sywag1fHuQanISDLGszoPoq/af39OPswTyG4a+jd233euOJrqK0LRmbqRSH4 UWvuurdobJ901n0WZX8TeRI7eyiQWC+8oFpV4HVUQY41KMivkfwd6WZ+1WFijnK/XDwO L857iEvCGQkfYHfPWBi8Lo3jDEXCGB/1x4pBt5M0RObUOhL7KAlbRZK8T+O/eqc/JGYu 0ggUUexnEXVPAVKLhcBLht4nswiDMln1W18Pt6PoEN3fT3ahaHiezSpKVyztIXYnmyhE 3VLg== X-Gm-Message-State: AOJu0YxZ94hLwN0z8xPQVc/u/rYBDotxoR1W4HU3EZeD0RYQ9oInKNPb UvAmv/g9zhQgIhrbnwv4o5Y= X-Received: by 2002:a17:906:3298:b0:99c:7300:94b8 with SMTP id 24-20020a170906329800b0099c730094b8mr2601281ejw.10.1691574061783; Wed, 09 Aug 2023 02:41:01 -0700 (PDT) Received: from gmail.com (fwdproxy-cln-118.fbsv.net. [2a03:2880:31ff:76::face:b00c]) by smtp.gmail.com with ESMTPSA id a1-20020a1709063a4100b0099275c59bc9sm7788999ejf.33.2023.08.09.02.41.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 02:41:01 -0700 (PDT) Date: Wed, 9 Aug 2023 02:40:59 -0700 From: Breno Leitao To: Stanislav Fomichev Cc: axboe@kernel.dk, asml.silence@gmail.com, willemdebruijn.kernel@gmail.com, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, io-uring@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com Subject: Re: [PATCH v2 0/8] io_uring: Initial support for {s,g}etsockopt commands Message-ID: References: <20230808134049.1407498-1-leitao@debian.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,FSL_HELO_FAKE, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 08, 2023 at 10:35:08AM -0700, Stanislav Fomichev wrote: > On 08/08, Breno Leitao wrote: > > This patchset adds support for getsockopt (SOCKET_URING_OP_GETSOCKOPT) > > and setsockopt (SOCKET_URING_OP_SETSOCKOPT) in io_uring commands. > > SOCKET_URING_OP_SETSOCKOPT implements generic case, covering all levels > > nad optnames. On the other hand, SOCKET_URING_OP_GETSOCKOPT just > > implements level SOL_SOCKET case, which seems to be the > > most common level parameter for get/setsockopt(2). > > > > struct proto_ops->setsockopt() uses sockptr instead of userspace > > pointers, which makes it easy to bind to io_uring. Unfortunately > > proto_ops->getsockopt() callback uses userspace pointers, except for > > SOL_SOCKET, which is handled by sk_getsockopt(). Thus, this patchset > > leverages sk_getsockopt() to imlpement the SOCKET_URING_OP_GETSOCKOPT > > case. > > > > In order to support BPF hooks, I modified the hooks to use sockptr, so, > > it is flexible enough to accept user or kernel pointers for > > optval/optlen. > > > > PS1: For getsockopt command, the optlen field is not a userspace > > pointers, but an absolute value, so this is slightly different from > > getsockopt(2) behaviour. The new optlen value is returned in cqe->res. > > > > PS2: The userspace pointers need to be alive until the operation is > > completed. > > > > These changes were tested with a new test[1] in liburing. On the BPF > > side, I tested that no regression was introduced by running "test_progs" > > self test using "sockopt" test case. > > > > [1] Link: https://github.com/leitao/liburing/blob/getsock/test/socket-getsetsock-cmd.c > > > > RFC -> V1: > > * Copy user memory at io_uring subsystem, and call proto_ops > > callbacks using kernel memory > > * Implement all the cases for SOCKET_URING_OP_SETSOCKOPT > > I did a quick pass, will take a close look later today. So far everything makes > sense to me. > > Should we properly test it as well? > We have tools/testing/selftests/bpf/prog_tests/sockopt.c which does > most of the sanity checks, but it uses regular socket/{g,s}etsockopt > syscalls. Right, that is what I've been using to test the changes. > Seems like it should be pretty easy to extend this with > io_uring path? tools/testing/selftests/net/io_uring_zerocopy_tx.c > already implements minimal wrappers which we can most likely borrow. Sure, I can definitely do it. Do you want to see the new tests in this patchset, or, in a following patches?