Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp134306rwl; Wed, 9 Aug 2023 12:05:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH5w/pW1fQNT3SSgki2TZIrz5DntcXMqR01WA1lWrZkuc2ZMYt8E5KskJwxNiTfJh+aL/3E X-Received: by 2002:aa7:d059:0:b0:523:1053:9b50 with SMTP id n25-20020aa7d059000000b0052310539b50mr104527edo.20.1691607957289; Wed, 09 Aug 2023 12:05:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691607957; cv=none; d=google.com; s=arc-20160816; b=QiKzVNWlgJrbqYx/ExMNZWLMj1FlOR913NuKQNSAT2sz6wQzbOZMSBaSKGCpC+eP8Y d8l1Lw4h2TGUWX5KaJbfCeB1WV/hPxZGKODFbNx9JmjzGe/zmzZylzYg/A4wGvAir2VH FDS/qevWBpFZ6yvYPaojfeZ5PXCGGFUS5PZoXhxlsa43pBTWCRcHhVjcw0b5O6A3sZ+p OsGz9f/lRlInFXU/vTKuEBYXDer/cmZenSDzRzJClME7QFcbPZBofiQuHlIzydAJukHw k7bhEqOoQfC/ht61HNOggT4l2KSfuSwa+RHHXSomclmUz6P1q4NunddqMmU4s+B+ogrZ ByvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=D9slY7L6wCBcCqclWRszu0YEXVQ+ftiI5ObGkzjdqrg=; fh=cJluYVce1/OEWInHaFCSQpMjQEVXA6wpPQnlECUFw+s=; b=0HgDn/B25XbZ1gdrIq/NUlLQJoleonG6jupPnZGvDJc9SW8VyKBW4657KmonXADnZS VY/+9pKaqWRyeW5r4f2kMPMxa+DjW9LlV9xKohAPEVeSwtKKtes+R6ql8DDV9y1og8Ka iLLsIPBQgar0nYbdNhxD4Kr/a+jNIaO453W+aK9PJv5xyrlott0ngnT9NL88F7wKSg7m 6GIqCHft3pvNqMaAJ5pzEe8khNj8jlYNRU1InuXRxw6wgevwOf2cD/DV31fCE2VMrgZ9 mWX+Xn1Mfg4LMRf3H6tA9puKNS8zBeQoGi1Ii5KME9GA721u3u3/EXstf/G1WrkPb2VF vsog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=l34yiPQw; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m12-20020a50ef0c000000b005230e0295d0si9514045eds.126.2023.08.09.12.05.31; Wed, 09 Aug 2023 12:05:57 -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; dkim=pass header.i=@google.com header.s=20221208 header.b=l34yiPQw; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229540AbjHIQ1F (ORCPT + 99 others); Wed, 9 Aug 2023 12:27:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229601AbjHIQ1F (ORCPT ); Wed, 9 Aug 2023 12:27:05 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13EA91724 for ; Wed, 9 Aug 2023 09:27:04 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-267f870e6ffso3946538a91.0 for ; Wed, 09 Aug 2023 09:27:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691598423; x=1692203223; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=D9slY7L6wCBcCqclWRszu0YEXVQ+ftiI5ObGkzjdqrg=; b=l34yiPQwzUm7bzfUSUWpEvPTpUP9ao2GfVObE0lvHLRnMzOppIkqBkNpnJpblmjnGC vjG/7MaN4Yms92toXNu0q7ix+6zAxmfeC3Fg9PUf+OzRfzyOgqqhqOikD/uTsyTD13E2 jf0JX/D38w+dTWvwcaC5PG8f6UbX52AA86oUEB+EDmyk/3Bm+RpahVqSBArYe4Mzv7cW Be7GtLV9XN2CzAdV2wdD1I4ys45KmACwFFqlWyvIEeKuP3RP/m/zKoFOySJ9BRd8gEZF Mt/Lk3MM1cCB8gF65WVk+c5xZh6td/d5FNl+uFoHTHUDmLjaLHTbExP/RwL1RAgpMZRM alBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691598423; x=1692203223; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D9slY7L6wCBcCqclWRszu0YEXVQ+ftiI5ObGkzjdqrg=; b=PEpSnNGOzsD1BC++wohBqwqN/FRJF4nvf8BjT+yg8YmyzWlPVx/2krmxvuix/DnoQR J0LPQirFQrZkhJe9KYB9Z2ljK8B5y4LEUpqM348ZuSZKqBODs8bF46ylft5nHuL+/gFI rx0X6eMzSsnzIuKmftccwTejfDvV2OKalTj6f7QlBBrBqgrwcP35we9Q5TK+WPwyuaKu edz15RxKYL7cdCpDp6ztktmlSQRMKuHwCThIM0hrJiumA9MZkIKGdYs7EmgYOdXvsKeM 9ioBGp2VwD9MC2lMgKRsVMRfCO+sYkqlAh6xd40Fuab2VhcGXAhmqlJjhlwGVHNvCGpt MseA== X-Gm-Message-State: AOJu0YwmI1GXZzKBfv9gH3ENyShpGh9czEuTUPGlWkAKIBYDOZuu5Hh7 5PDBlHiCSNcf9T0jMcFW1AsCYl1/4PJW7myQUAzSig== X-Received: by 2002:a17:90a:1196:b0:267:f8a2:300a with SMTP id e22-20020a17090a119600b00267f8a2300amr2440659pja.7.1691598423307; Wed, 09 Aug 2023 09:27:03 -0700 (PDT) MIME-Version: 1.0 References: <20230808134049.1407498-1-leitao@debian.org> In-Reply-To: From: Stanislav Fomichev Date: Wed, 9 Aug 2023 09:26:52 -0700 Message-ID: Subject: Re: [PATCH v2 0/8] io_uring: Initial support for {s,g}etsockopt commands To: Breno Leitao 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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 Wed, Aug 9, 2023 at 2:41=E2=80=AFAM Breno Leitao wro= te: > > 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 leve= ls > > > 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_pro= gs" > > > 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 everythi= ng 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? Let's keep it in the same series if possible?