From patchwork Wed Oct 26 23:25:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13021461 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78D3EFA373E for ; Wed, 26 Oct 2022 23:28:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234442AbiJZX2b (ORCPT ); Wed, 26 Oct 2022 19:28:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234349AbiJZX16 (ORCPT ); Wed, 26 Oct 2022 19:27:58 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D43559E83; Wed, 26 Oct 2022 16:27:30 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id k8so20401228wrh.1; Wed, 26 Oct 2022 16:27:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mw2s7wAvpFdjBac+RJ5XjlO7wY/8JdIzBylcaNWwwcM=; b=dT6rsR+rKxLWm7s7dtgtCzGkjWHq6Iv7Kp5GwujJK6NHSTNVeX93gkrhuHKTUh5WK0 Mq1ENWnJjiDUPTaPdnqDZV18OPSgk2Fk1gx8MVfA2GZoRmIxWl+OptZ95b9xVsRup2Qm Eg9M6e5EZsHttTxAs7by6HAV2XU9Tum2tf+j59XLIElYMvW7R5TovDUFDDz7mosvLRAC EIiZxB/+YA97nude8oxbWywTJqYvRRH1JyFq5kSdds7W7whIH/OfGWJOjmhdwsLx3Bec UuJro7hm8q6AeCtw0xLr4zo6/7hmqrdbn8Bw/eopeD0Ihqz67ZGBVA/xDHymId6UraTI 58mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=mw2s7wAvpFdjBac+RJ5XjlO7wY/8JdIzBylcaNWwwcM=; b=U7M4Q75KvkmbeOPl2QJi5YpH8kEwiT6KFuUj3NgF/YrEpobsljh1pxgW29lT8NGY1U 3a9OAGLRSc/HzsB0+vf4RiGYdEriejvpBC9R67tYI51QiG48bhlsLkGcrSpRGAqPFE5M UwFepwFhUh+Nwb4sK8qkx3MK35Ywp9kJGFEyGyTcKKs3CHC6SozMYr2vIBZDgR5JyT5R NZVVtkcansLOr+HV7yuew4nwG7H969US10Vsp30hiVzZDaNV57hzXk5AadTSffuL42Ab 1OPb8jYAPRmBPDyQ0ogH5QdKTRoNExw4GMFvRwjKhIJ3EuPccEKpQYKyk76Admu7c3zU EANw== X-Gm-Message-State: ACrzQf17HgreyNh7/3JZtDdCXrE6dH5mo5/kydACfkwzPr0iApIbBp4q 0Duuuz+8oXW97Sutxuqa0dPKPTvvIDdnJw== X-Google-Smtp-Source: AMsMyM5OP6wmEEeqcZkCOaBOcHWs9BmhTaPxWZbPo/EOrtelra8g/+TI2cSSXWKBC5HopOG79v/cHw== X-Received: by 2002:a5d:64a3:0:b0:231:f82e:9a57 with SMTP id m3-20020a5d64a3000000b00231f82e9a57mr30651301wrp.492.1666826848318; Wed, 26 Oct 2022 16:27:28 -0700 (PDT) Received: from 127.0.0.1localhost (213-205-70-130.net.novis.pt. [213.205.70.130]) by smtp.gmail.com with ESMTPSA id y4-20020adfd084000000b002368424f89esm4897526wrh.67.2022.10.26.16.27.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 16:27:27 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Jakub Kicinski , "David S . Miller" , io-uring@vger.kernel.org, John Fastabend , asml.silence@gmail.com Subject: [PATCH net 1/4] udp: advertise ipv6 udp support for msghdr::ubuf_info Date: Thu, 27 Oct 2022 00:25:56 +0100 Message-Id: <63bd51f76b1951ae1ca387eef514e2d90c329230.1666825799.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Mark udp ipv6 as supporting msghdr::ubuf_info. In the original commit SOCK_SUPPORT_ZC was supposed to be set by a udp_init_sock() call from udp6_init_sock(), but d38afeec26ed4 ("tcp/udp: Call inet6_destroy_sock() in IPv6 ...") removed it and so ipv6 udp misses the flag. Cc: # 6.0 Fixes: e993ffe3da4bc ("net: flag sockets supporting msghdr originated zerocopy") Signed-off-by: Pavel Begunkov --- net/ipv6/udp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 129ec5a9b0eb..bc65e5b7195b 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -66,6 +66,7 @@ int udpv6_init_sock(struct sock *sk) { skb_queue_head_init(&udp_sk(sk)->reader_queue); sk->sk_destruct = udpv6_destruct_sock; + set_bit(SOCK_SUPPORT_ZC, &sk->sk_socket->flags); return 0; } From patchwork Wed Oct 26 23:25:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13021463 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 211AAFA373D for ; Wed, 26 Oct 2022 23:28:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233766AbiJZX2e (ORCPT ); Wed, 26 Oct 2022 19:28:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbiJZX16 (ORCPT ); Wed, 26 Oct 2022 19:27:58 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D5925FC25; Wed, 26 Oct 2022 16:27:31 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id b20-20020a05600c4e1400b003cc28585e2fso2885782wmq.1; Wed, 26 Oct 2022 16:27:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5sjP64Qj3I5bM+4YXFPnF6jS8rNRlxRMcMkh4ovNirg=; b=hOW4gFulPjHAP04yJhIeyWaiuhS24jqmREX7c+IgE54LM2NKovz1FWlIqBhp01kQP1 /S5eAyOVFQdE/ldiqdofL/W1Q3amz0NIb9YaZV14guxtSCAwF0DBhMEVEPUITmc7WxOe 5MIpx3clK/qA/3lxYJjNHyM30IL3J2BhRAIewe+Iooe8c86LEXw13JetnFL9gHUbPSCn GCKe2fO4832tjBa+CD9xCK7f3z20IWsmuFvrt/6kq0A2U7WD1zNNag0hKDIFULCvsXYy rQviCY8w3JtRCQBCaIfM6Ikob6bkhiEjIwCq+hTpNoscSYTVJnf/FXCok7OLxVoSBAwZ CB4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=5sjP64Qj3I5bM+4YXFPnF6jS8rNRlxRMcMkh4ovNirg=; b=X4SRcwjulpDWzL1Ywj+e8YcYEI+gvVLnmHtafSgV7nwp9fa9nfZxvuwnhdEtUTzI56 X67MJLtUgyAaKDL1BRVbKinGj3S7R7K4eQOUuzW1a06vgz+LCdD/LIazBKvie7RrXPv0 pwc88kXCh4oXyP0+Rylvp1/uUtKCxPWkctIyTjKnaOu0INpFwCPBfZUKt/NqF/3huf8m 5VudJRzaQB62Pogs3DtVBCE9Ndz74P4SHz7H8lhF0rC/chNMs5EUQgZ2/fOiWAP1+UGP VJr+Yf5J2+1VLwstcYn0scWRY+xFLLzu7+9N7wasRO8V6sWcpKdSAqXjAB0Y+EaYiaFr 3c1A== X-Gm-Message-State: ACrzQf2JfR5bMgmlCKsy75Rf/u2vYqu+sUuQ52MpzN+yYyL9tEughAlo dY7J03qoVPeaAxYs3GF4q/sE+6FFYfIrGA== X-Google-Smtp-Source: AMsMyM7sl2k4Z0mb2kqpOuPapuoryWhoK6WgF3TBhFHomHJnLiD10D/KOZa1konHqlOHkltrX9liyw== X-Received: by 2002:a05:600c:3acd:b0:3ce:3f62:a8d1 with SMTP id d13-20020a05600c3acd00b003ce3f62a8d1mr3896899wms.78.1666826849603; Wed, 26 Oct 2022 16:27:29 -0700 (PDT) Received: from 127.0.0.1localhost (213-205-70-130.net.novis.pt. [213.205.70.130]) by smtp.gmail.com with ESMTPSA id y4-20020adfd084000000b002368424f89esm4897526wrh.67.2022.10.26.16.27.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 16:27:29 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Jakub Kicinski , "David S . Miller" , io-uring@vger.kernel.org, John Fastabend , asml.silence@gmail.com Subject: [PATCH net 2/4] net: remove SOCK_SUPPORT_ZC from sockmap Date: Thu, 27 Oct 2022 00:25:57 +0100 Message-Id: <0d46741e883fd596d6d24a1445177bf0ba842f5f.1666825799.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org sockmap replaces ->sk_prot with its own callbacks, we should remove SOCK_SUPPORT_ZC as the new proto doesn't support msghdr::ubuf_info. Cc: # 6.0 Reported-by: Jakub Kicinski Fixes: e993ffe3da4bc ("net: flag sockets supporting msghdr originated zerocopy") Signed-off-by: Pavel Begunkov --- include/net/sock.h | 7 +++++++ net/ipv4/tcp_bpf.c | 4 ++-- net/ipv4/udp_bpf.c | 4 ++-- net/unix/unix_bpf.c | 8 ++++---- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/include/net/sock.h b/include/net/sock.h index 22f8bab583dd..5db02546941c 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1889,6 +1889,13 @@ void sock_kfree_s(struct sock *sk, void *mem, int size); void sock_kzfree_s(struct sock *sk, void *mem, int size); void sk_send_sigurg(struct sock *sk); +static inline void sock_replace_proto(struct sock *sk, struct proto *proto) +{ + if (sk->sk_socket) + clear_bit(SOCK_SUPPORT_ZC, &sk->sk_socket->flags); + WRITE_ONCE(sk->sk_prot, proto); +} + struct sockcm_cookie { u64 transmit_time; u32 mark; diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c index a1626afe87a1..c501c329b1db 100644 --- a/net/ipv4/tcp_bpf.c +++ b/net/ipv4/tcp_bpf.c @@ -607,7 +607,7 @@ int tcp_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore) } else { sk->sk_write_space = psock->saved_write_space; /* Pairs with lockless read in sk_clone_lock() */ - WRITE_ONCE(sk->sk_prot, psock->sk_proto); + sock_replace_proto(sk, psock->sk_proto); } return 0; } @@ -620,7 +620,7 @@ int tcp_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore) } /* Pairs with lockless read in sk_clone_lock() */ - WRITE_ONCE(sk->sk_prot, &tcp_bpf_prots[family][config]); + sock_replace_proto(sk, &tcp_bpf_prots[family][config]); return 0; } EXPORT_SYMBOL_GPL(tcp_bpf_update_proto); diff --git a/net/ipv4/udp_bpf.c b/net/ipv4/udp_bpf.c index ff15918b7bdc..e5dc91d0e079 100644 --- a/net/ipv4/udp_bpf.c +++ b/net/ipv4/udp_bpf.c @@ -141,14 +141,14 @@ int udp_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore) if (restore) { sk->sk_write_space = psock->saved_write_space; - WRITE_ONCE(sk->sk_prot, psock->sk_proto); + sock_replace_proto(sk, psock->sk_proto); return 0; } if (sk->sk_family == AF_INET6) udp_bpf_check_v6_needs_rebuild(psock->sk_proto); - WRITE_ONCE(sk->sk_prot, &udp_bpf_prots[family]); + sock_replace_proto(sk, &udp_bpf_prots[family]); return 0; } EXPORT_SYMBOL_GPL(udp_bpf_update_proto); diff --git a/net/unix/unix_bpf.c b/net/unix/unix_bpf.c index 7cf14c6b1725..e9bf15513961 100644 --- a/net/unix/unix_bpf.c +++ b/net/unix/unix_bpf.c @@ -145,12 +145,12 @@ int unix_dgram_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool re if (restore) { sk->sk_write_space = psock->saved_write_space; - WRITE_ONCE(sk->sk_prot, psock->sk_proto); + sock_replace_proto(sk, psock->sk_proto); return 0; } unix_dgram_bpf_check_needs_rebuild(psock->sk_proto); - WRITE_ONCE(sk->sk_prot, &unix_dgram_bpf_prot); + sock_replace_proto(sk, &unix_dgram_bpf_prot); return 0; } @@ -158,12 +158,12 @@ int unix_stream_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool r { if (restore) { sk->sk_write_space = psock->saved_write_space; - WRITE_ONCE(sk->sk_prot, psock->sk_proto); + sock_replace_proto(sk, psock->sk_proto); return 0; } unix_stream_bpf_check_needs_rebuild(psock->sk_proto); - WRITE_ONCE(sk->sk_prot, &unix_stream_bpf_prot); + sock_replace_proto(sk, &unix_stream_bpf_prot); return 0; } From patchwork Wed Oct 26 23:25:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13021464 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11D22C38A2D for ; Wed, 26 Oct 2022 23:28:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229670AbiJZX2f (ORCPT ); Wed, 26 Oct 2022 19:28:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234280AbiJZX16 (ORCPT ); Wed, 26 Oct 2022 19:27:58 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A169457567; Wed, 26 Oct 2022 16:27:32 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id l16-20020a05600c4f1000b003c6c0d2a445so2873474wmq.4; Wed, 26 Oct 2022 16:27:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uxR0N06XcTkbcfsZ9QY/sp1sj7zmWgcYGVut7P5rowU=; b=MdBbHT3vFV8LjHhqH7/jJnROkFXKA6sVq2Qj15Yg39e/zHMl0IwhhuI3wT2Shc0afA hs5sUnFUHlyoYluE2gZ2DWPbwuCUMhK6alpKfAa9vZY3OGhXUFbDFpzapAb0QLCAvhmK VZ6Laa+9EnLEMXk5GPQj34+UR/AF4sKZNiGTa0HQuawdIRiSFZxLLBTwEz4o4NgaY+Og 3/pNA6hVEQAoj5Kv502vQqT+NaLEPukOLm4ti+HUaQoLozl3C8qOpUOZQmLaSZw8TRyt in+kGc8n1gfatWzDCg228MGjdqflo8PFPtQywENYzxJIqCEsxFo8H3MbhoIv6ebMdaGv sqTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=uxR0N06XcTkbcfsZ9QY/sp1sj7zmWgcYGVut7P5rowU=; b=q4sLYnk2080qj6MQ7re27noycS3TOe7kWf0qTav+f61WHHH8eAMzGDNmD7p7IvR0Ir QbmHBp8ITttzV/Fk2Ih4Y7uXU34bVIP8LS0uKrL3W1d35FwUQlkW8jlTI4hOfEJkcnv4 MnVPBNcyb0yjdDvFR38bC+eVFpy7o/cUlmc5i8AzNTwJ5RiE8m4/vHx3uIjm08dqqb3D TIF+blcVPcEH9o+qu/7IGv3p6POLPP5LWYL/Hj/OkGNC2562RG1L03CGO7kLKZ4Edf+G CV6vzgzYVhGqKoJuJ0cxlT3Dpd5d8gIBYS0MX4Jnuj3y71P0xoaTAvmhvcJogbTlwqb+ xDpQ== X-Gm-Message-State: ACrzQf1YvKmvQ4+b0dNu0rv1hvXiLcQIVfKe9+Sqb2LM4EoIRiHZzoKB QRevhEMKlTk/XQGyVVQPtgYXUbmqAP4FSA== X-Google-Smtp-Source: AMsMyM6zsvZ8+smBAzBcYkhxQ/XshQ2TAiODQdW3lKjh40VaonuagFLtMucOaa0cOs1HnIkI7Pp9Rw== X-Received: by 2002:a05:600c:3781:b0:3b4:63c8:554b with SMTP id o1-20020a05600c378100b003b463c8554bmr3952382wmr.25.1666826850970; Wed, 26 Oct 2022 16:27:30 -0700 (PDT) Received: from 127.0.0.1localhost (213-205-70-130.net.novis.pt. [213.205.70.130]) by smtp.gmail.com with ESMTPSA id y4-20020adfd084000000b002368424f89esm4897526wrh.67.2022.10.26.16.27.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 16:27:30 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Jakub Kicinski , "David S . Miller" , io-uring@vger.kernel.org, John Fastabend , asml.silence@gmail.com Subject: [PATCH net 3/4] net/ulp: remove SOCK_SUPPORT_ZC from tls sockets Date: Thu, 27 Oct 2022 00:25:58 +0100 Message-Id: <604fa24e63524f9e0f5098df7e1a578debf471bf.1666825799.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Remove SOCK_SUPPORT_ZC when we're setting ulp as it might not support msghdr::ubuf_info, e.g. like TLS replacing ->sk_prot with a new set of handlers. Cc: # 6.0 Reported-by: Jakub Kicinski Fixes: e993ffe3da4bc ("net: flag sockets supporting msghdr originated zerocopy") Signed-off-by: Pavel Begunkov --- net/ipv4/tcp_ulp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv4/tcp_ulp.c b/net/ipv4/tcp_ulp.c index 7c27aa629af1..9ae50b1bd844 100644 --- a/net/ipv4/tcp_ulp.c +++ b/net/ipv4/tcp_ulp.c @@ -136,6 +136,9 @@ static int __tcp_set_ulp(struct sock *sk, const struct tcp_ulp_ops *ulp_ops) if (icsk->icsk_ulp_ops) goto out_err; + if (sk->sk_socket) + clear_bit(SOCK_SUPPORT_ZC, &sk->sk_socket->flags); + err = ulp_ops->init(sk); if (err) goto out_err; From patchwork Wed Oct 26 23:25:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13021462 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A2A2C433FE for ; Wed, 26 Oct 2022 23:28:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231164AbiJZX2c (ORCPT ); Wed, 26 Oct 2022 19:28:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234508AbiJZX16 (ORCPT ); Wed, 26 Oct 2022 19:27:58 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 041C25A3DA; Wed, 26 Oct 2022 16:27:32 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id bp11so28494140wrb.9; Wed, 26 Oct 2022 16:27:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fecvoE3GO3AEiM1jj/RAiMwmH/hP4TRAww18UbwirDs=; b=k6GcJ40EahQegR5VzpYdakh/t3MYmiw5Q0nyoVR3La3kE8hHFfClOYlbJtkuif5+FH N+beJsbpOPO01+Z92fw5EQpfHbajV6BXYlFsejUh8XHGarO8slnsEAXmHRtv+/BI7Mtl 8mYGE3ppdfdobBJ5orRYKH7fKTAi65sJmaGRpdEvj38dPrdKFX+zpFuxO41BLZtafAu/ py1L4GjunQmLB3cLC/q/i7l8SOD+x6MjsPNJQcaOKM++StQk5a3+YIF/6qnyBLGozKEk cLFxLUvG9ab+w5VYVCvLYhJeU8h5CcC25Vs2FFhb1ruNU0Gv7ZEUyf1TXWPxKfGP6oU6 bAYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=fecvoE3GO3AEiM1jj/RAiMwmH/hP4TRAww18UbwirDs=; b=kxKolwb5g5BDgvJq27CbcS8LhOJxv8Zmd4Lp+/rSgmfgm/bLaXeo2KI+OT0NuFjrlt 6m1SfUJeceNyq8D4aWLk+LM0Kc8patuj/NybQKt2TmMlcUiEkg6V5a0SSh9aZOmv/K+A pCX1YU1+TvCQT87+AztNMpdiEVW8ifi1xKP04ex92xfbGoygzsX/wTPXM0/zDTHsL4sF r30c/LGA7+QTkoKC94ytdrXZPKJJR1S9rDJREJIVG9cShB8zR5J3ya8sSd4QBCoIcfSU o5ACCrUOn8If9hOh5Fc2lylo0kBpHw7J/m6GuW4x7rXChgUro6u8Z5YleVNXphjRK3bA Dy1A== X-Gm-Message-State: ACrzQf3lJWqQGJmFpJUYxAospRLIeIbPf+2yiBQzGNoaqm1hbZIIV+l+ N+17kjzu29AyITx4T5kjsiHzjeybJX1qiA== X-Google-Smtp-Source: AMsMyM6uKIqQLJPtQgzCdzQ8X4e6hA0DO3wkqZfAOeXGaBTc2rqEZDJAjGBqGIMwvDkfXo9Xx8KvOg== X-Received: by 2002:adf:d1c4:0:b0:230:7771:f618 with SMTP id b4-20020adfd1c4000000b002307771f618mr28596922wrd.203.1666826852185; Wed, 26 Oct 2022 16:27:32 -0700 (PDT) Received: from 127.0.0.1localhost (213-205-70-130.net.novis.pt. [213.205.70.130]) by smtp.gmail.com with ESMTPSA id y4-20020adfd084000000b002368424f89esm4897526wrh.67.2022.10.26.16.27.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 16:27:31 -0700 (PDT) From: Pavel Begunkov To: netdev@vger.kernel.org Cc: Jakub Kicinski , "David S . Miller" , io-uring@vger.kernel.org, John Fastabend , asml.silence@gmail.com, Stefan Metzmacher Subject: [PATCH net 4/4] net: also flag accepted sockets supporting msghdr originated zerocopy Date: Thu, 27 Oct 2022 00:25:59 +0100 Message-Id: X-Mailer: git-send-email 2.38.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Stefan Metzmacher Without this only the client initiated tcp sockets have SOCK_SUPPORT_ZC. The listening socket on the server also has it, but the accepted connections didn't, which meant IORING_OP_SEND[MSG]_ZC will always fails with -EOPNOTSUPP. Fixes: e993ffe3da4b ("net: flag sockets supporting msghdr originated zerocopy") Cc: # 6.0 CC: Pavel Begunkov Cc: Jakub Kicinski CC: Jens Axboe Link: https://lore.kernel.org/io-uring/20221024141503.22b4e251@kernel.org/T/#m38aa19b0b825758fb97860a38ad13122051f9dda Signed-off-by: Stefan Metzmacher Signed-off-by: Pavel Begunkov --- net/ipv4/af_inet.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 3dd02396517d..4728087c42a5 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -754,6 +754,8 @@ int inet_accept(struct socket *sock, struct socket *newsock, int flags, (TCPF_ESTABLISHED | TCPF_SYN_RECV | TCPF_CLOSE_WAIT | TCPF_CLOSE))); + if (test_bit(SOCK_SUPPORT_ZC, &sock->flags)) + set_bit(SOCK_SUPPORT_ZC, &newsock->flags); sock_graft(sk2, newsock); newsock->state = SS_CONNECTED;