Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp4718632rwb; Tue, 8 Aug 2023 12:40:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG2S9EN5nbBpVaUl5pYGLAZ1gUGWldhiQP95YTQ/Gj2LQ3wQ2EoMbR79fsE4Ao7fmbaQER6 X-Received: by 2002:a05:6a20:1054:b0:140:94b8:3b67 with SMTP id gt20-20020a056a20105400b0014094b83b67mr464765pzc.21.1691523658033; Tue, 08 Aug 2023 12:40:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691523658; cv=none; d=google.com; s=arc-20160816; b=rrDaTewHLym4jRTad6FT3ADCsGnX62ibE3ZEApbFR4A4MTjXXS3mRLCICLAWV1tt39 AMaHpqBn5AQtgG9+dNLQmr1rA/VGYvnMG46+qecEu4pZOO9GLnrg7Li53ASUIAz6JQd2 bK+fUCfH7jXwbMj4I09ok5WG3vZHnFfCmOE7u8xOXG5xzdpHhlC8OQnnnrihrImk3DOi N7C39qBN+BiTpI7XHGGGjV4mXetvrLvJNUDuoeMFcPiHe9Q85iDT3jYkjuwRAQW18FM5 ZNVa5bp53BUMwCAb39XyVtm7OZY9xpMSZ5aSDsYkg14fotZAZYIz+syvFc98RqMDZ/YL uY1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=CbNixERlHqS43p9WnetIfE1bwp3ZFaI202y6cxjDISk=; fh=cJluYVce1/OEWInHaFCSQpMjQEVXA6wpPQnlECUFw+s=; b=p4sZHtX57YHxfNBUW9To9jIEClr50mMVMCMSePtVxhIVLPgFaaV+NFJgTSpzz8nvrt qyCCgQWKbda+VrqmFoqaCuvHjIDnHB8nziHIm7Jg7cglK8BiGcR29Y2xBM8Lqaxy7qXw I/IUuWT2fnZS/OLr9IuK4zqkG38J+eCLSJx/M1eCeJ9qtdx0/nziKDNvUhUSj3OYSRih PHCn2R+NAgHkPbLIbzJiq5XzpMugAH0e5y3paWO1NdrOqntM6zKL7WN9hrxVLRuCwX6a JcNAQ+yy27fguraU3UtV7puGj2oNjiJfPm9fmGL/rnh2r4yoS+V872ZofVCrKkcwzejn GKOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=BtYnibgA; 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 l14-20020a654c4e000000b00564acb691e0si7378013pgr.643.2023.08.08.12.40.45; Tue, 08 Aug 2023 12:40:58 -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=BtYnibgA; 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 S235437AbjHHSYF (ORCPT + 99 others); Tue, 8 Aug 2023 14:24:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235348AbjHHSXk (ORCPT ); Tue, 8 Aug 2023 14:23:40 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 548347EF3 for ; Tue, 8 Aug 2023 10:35:11 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id 41be03b00d2f7-563fbc76454so6002857a12.2 for ; Tue, 08 Aug 2023 10:35:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691516111; x=1692120911; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=CbNixERlHqS43p9WnetIfE1bwp3ZFaI202y6cxjDISk=; b=BtYnibgAq7g0L/okVpcz1sm6OulXBZOLXW68YAi0kE94x5HCN7bWDWiYRWfi91svGo Xc79qQ233j8gXgGltAV/J8/uXgNtnFjybeQZD1f/61BdCanNXGvF03sIBuo0PLfw2n8V M74JpyhSFxtW15aRUBl8P3VcNB0wjFg/9n39VGQsWXzGFLdytSDGhhjl7u1Z6CtvJuZN /eAqJk8ulH9QCYWJViD5t8z1c0a8y4LlJj9wtw/p4CWVORUdKTqp/wxHXBJvv2h+a/vL 8rWrgpPqCe+14Q5CE8cj3cirPO2rMueXgtfqCD0+VzHSYfmiNnwNXQhCV4TlIpQyV+Ie Hl0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691516111; x=1692120911; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CbNixERlHqS43p9WnetIfE1bwp3ZFaI202y6cxjDISk=; b=CfUIPfBKiOq5ei0nd4eYfv9LNGteUNTA51We+W5OMprmEmlGK5BnXgHhzLe2gvkgwy GzyxmdD2CS4q3nULwjHxLjqYKJ2ZTi1CdJMrlLTeT34JjqUZUKXUOHJU0VEtwiN4ybCA 99RylgtCXyF+Ub1EFVZYLjp9/CxidC0i19eZkVioYC3jntWEgCgejAuOAku4CqyTzLIz /5/U4DFl1wzyoa19mct7m0gfqXyzgAoPDqJYkTVQKmZiylBMtIPan3GMiFABela92LS3 K0O5S+CphefJ0ZInsfTb0Ok40iN6F8MewW/q+KlNz+3mLJiSiVcHGLv7Xjc6IALCO5dk bUmw== X-Gm-Message-State: AOJu0YwHW+8lGMSu0QzTBzK3H3AQgO8Ur/gAFUJ5r4wlKRq1IBtyEbe+ aUdVsP4o09FgHU69JQgFzuuNw5I= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a63:3443:0:b0:564:41a2:8d5a with SMTP id b64-20020a633443000000b0056441a28d5amr732pga.11.1691516110738; Tue, 08 Aug 2023 10:35:10 -0700 (PDT) Date: Tue, 8 Aug 2023 10:35:08 -0700 In-Reply-To: <20230808134049.1407498-1-leitao@debian.org> Mime-Version: 1.0 References: <20230808134049.1407498-1-leitao@debian.org> Message-ID: Subject: Re: [PATCH v2 0/8] io_uring: Initial support for {s,g}etsockopt commands From: Stanislav Fomichev 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" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_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 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. 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.