Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2527222rwd; Wed, 14 Jun 2023 04:17:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5uZ0K9V5IM4Xy6GhzPJdRAMDKdUZZQQRe7XPWDazuPZMHJtystrRqlXl3Swm7TUGsLap7F X-Received: by 2002:aa7:d49a:0:b0:50b:fd52:2f4b with SMTP id b26-20020aa7d49a000000b0050bfd522f4bmr10552610edr.24.1686741435504; Wed, 14 Jun 2023 04:17:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686741435; cv=none; d=google.com; s=arc-20160816; b=tEXUwgvuy8fz/68N5HK+AvHO/voYaE3FDzFp6zvEEuS8XQ5aTHVACb/H1aFYfp1+Pl LDR9N4OabsfuihHwbfHh/mr4PZoHM/Oy/sd55sVPjN4Di9MeghiFUEAOnjfThKtsD8ey yOHIG1Ol5+4lgxKHavBYQV73MqfVUas2Pu0jP7UjHBTKk2VNs+I/YTDTkxa0YZIKLPO+ 0I0jIbCqqqaJWlniFKreWWP/zyFypRNVyZJy1pYFko+u2SNvpafeRpwW8vEinrHFRKex CT3w5AcGogeSM8NeysjrMs+pLWc39mK1UoqwxpBtowu49en787Pjj9jVB/L4ppem7aiq A0Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Yc88muMtZ5aM3IzShu9BL/RZOvuDqFEnp6zrvGSRn1A=; b=aPa0Uo87KdlmcEIgKBEhdrJjqSMh703U1SsBB/k4lyXFK5S21Ju1Vd8/K/xlotVE7X ZgPl9Fwqq6S90edknLgNiyx/eCP4+TuH2mVNT8Axk/5kH/DX+8qsLftMxsTHEIULQ907 QKpKFeHpSoPTRmiZdJJymaj35TnKAaWhvdMkKlHcncqF1jpBN2gv3f9TWaBQoElZotcu Ch8D6QerLcxpNgBZJzVo5/zAA2fNKp3hbQ5kL6ZfZdDUQocoa/CrxE78tygxN3PDkVX+ oB37jkmr00k8fU8evLEuk0vYEqLaF8LS84RBPXiGDjg3tSnoGkiKqU5nE53HidkgWAUI 8GXA== 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 t19-20020a05640203d300b00516a1bfec90si8776648edw.199.2023.06.14.04.16.50; Wed, 14 Jun 2023 04:17:15 -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 S241048AbjFNLLA (ORCPT + 99 others); Wed, 14 Jun 2023 07:11:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243558AbjFNLKa (ORCPT ); Wed, 14 Jun 2023 07:10:30 -0400 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E1F91BF8; Wed, 14 Jun 2023 04:10:29 -0700 (PDT) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-3f7368126a6so4440265e9.0; Wed, 14 Jun 2023 04:10:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686741027; x=1689333027; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Yc88muMtZ5aM3IzShu9BL/RZOvuDqFEnp6zrvGSRn1A=; b=lCGDgBpjVoHWjtVL+jFcdLuj6zQq44H9cEy/NwrKQEew8Okc5Z6Fcod9wDJpHkrlAQ 06SPd67KDa0PirISrBgFnPFCFlZtCrEQ2pKpAN8cl5isSedqJlEtlCFFXUZmFAHSigcr 8uSMIcaxyaAab2XbwmgEnLjOxgvCJ9CkWg9bJ6yd/eOVwM0BDOHDAx00o3GXAEQT+0Ii 1IsMqRtcV8KuSrZ4g4uTzgyDsYwozl0348bg83wsj/HkfhWE19pmfYrx1oPcWhS793T2 N/aWo8WZJGXZtgqHnX1gzCmkgbgTw95m9LsHvKgStRAgq5MisHs0RPm6kp5q36oxumaj 1Faw== X-Gm-Message-State: AC+VfDzIF7HQK1EIitcpL/zadnjCPRHnfu3IjiSrHdSFX96sFgkSYL0i IzKhpz0DZzhWomasRp0qm7BbajfjPt4W8w== X-Received: by 2002:a05:600c:364f:b0:3f6:d09:5d46 with SMTP id y15-20020a05600c364f00b003f60d095d46mr9656122wmq.20.1686741027064; Wed, 14 Jun 2023 04:10:27 -0700 (PDT) Received: from localhost (fwdproxy-cln-020.fbsv.net. [2a03:2880:31ff:14::face:b00c]) by smtp.gmail.com with ESMTPSA id i10-20020a05600c290a00b003f819dfa0ddsm9941676wmd.28.2023.06.14.04.10.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jun 2023 04:10:26 -0700 (PDT) From: Breno Leitao To: io-uring@vger.kernel.org, axboe@kernel.dk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, David Ahern Cc: leit@fb.com, asml.silence@gmail.com, matthieu.baerts@tessares.net, martineau@kernel.org, marcelo.leitner@gmail.com, lucien.xin@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, dccp@vger.kernel.org, mptcp@lists.linux.dev, linux-sctp@vger.kernel.org, ast@kernel.org, kuniyu@amazon.com, martin.lau@kernel.org Subject: [RFC PATCH v2 4/4] net: add uring_cmd callback to raw "protocol" Date: Wed, 14 Jun 2023 04:07:57 -0700 Message-Id: <20230614110757.3689731-5-leitao@debian.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230614110757.3689731-1-leitao@debian.org> References: <20230614110757.3689731-1-leitao@debian.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 This is the implementation of uring_cmd for the raw "protocol". It basically encompasses SOCKET_URING_OP_SIOCOUTQ and SOCKET_URING_OP_SIOCINQ, which call raw_ioctl with SIOCOUTQ and SIOCINQ. These two commands (SIOCOUTQ and SIOCINQ), are the only two commands that are handled by raw_ioctl(). Signed-off-by: Breno Leitao --- include/net/raw.h | 3 +++ net/ipv4/raw.c | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/net/raw.h b/include/net/raw.h index 32a61481a253..5d5ec63274a8 100644 --- a/include/net/raw.h +++ b/include/net/raw.h @@ -96,4 +96,7 @@ static inline bool raw_sk_bound_dev_eq(struct net *net, int bound_dev_if, #endif } +int raw_uring_cmd(struct sock *sk, struct io_uring_cmd *cmd, + unsigned int issue_flags); + #endif /* _RAW_H */ diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index 7782ff5e6539..31c3f9c41354 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c @@ -75,6 +75,7 @@ #include #include #include +#include struct raw_frag_vec { struct msghdr *msg; @@ -885,6 +886,27 @@ static int raw_ioctl(struct sock *sk, int cmd, int *karg) } } +int raw_uring_cmd(struct sock *sk, struct io_uring_cmd *cmd, + unsigned int issue_flags) +{ + int ret; + + switch (cmd->sqe->cmd_op) { + case SOCKET_URING_OP_SIOCINQ: { + if (raw_ioctl(sk, SIOCINQ, &ret)) + return -EFAULT; + return ret; + } + case SOCKET_URING_OP_SIOCOUTQ: + if (raw_ioctl(sk, SIOCOUTQ, &ret)) + return -EFAULT; + return ret; + default: + return -ENOIOCTLCMD; + } +} +EXPORT_SYMBOL_GPL(raw_uring_cmd); + #ifdef CONFIG_COMPAT static int compat_raw_ioctl(struct sock *sk, unsigned int cmd, unsigned long arg) { @@ -924,6 +946,7 @@ struct proto raw_prot = { .connect = ip4_datagram_connect, .disconnect = __udp_disconnect, .ioctl = raw_ioctl, + .uring_cmd = raw_uring_cmd, .init = raw_sk_init, .setsockopt = raw_setsockopt, .getsockopt = raw_getsockopt, -- 2.34.1