Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1155610iob; Wed, 4 May 2022 16:08:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygACyui69UDqPvbYi4zcq5v5q7SyjRfueZ2rSwmwvoH+GHRQ6saj3qdvAt0HGU9dpjNzHp X-Received: by 2002:a17:907:1c8e:b0:6f4:e24f:20e0 with SMTP id nb14-20020a1709071c8e00b006f4e24f20e0mr1977878ejc.227.1651705683834; Wed, 04 May 2022 16:08:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651705683; cv=none; d=google.com; s=arc-20160816; b=lVvsRFhoqKTMj7XPIPByjDdmhHKYC3PNolfUMiqR4PeMH6cHII9wR8kebYtVPwa9kF gp2BL9AcfWpTfJVl/ib+Ca8VS9OacwTK8Fjl54tJnI1Qx8HQgA5Bnr4zgOiAvnJoQjge c6kmR/+v0okmSXTUJtbegscocLiT8ITqDqXyCM637rqMbb53RxDfQ0G5/ITDR08qxHIi 3YpraeTT9Vrt2NHtk0pdJK3OYv6qSWdpOnr/jMt6vNtEZyiXsSKRBEYof+Il41cT00Et 68TssWG3OJW485/uSNiH7X5YFkmWf/zgrQPHO059Oc286C33birxRpUQtEh86keIp3yQ 2mfA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bMqK/ZMEdsG5f/G7jVQOF9KkSEN/SU8tt1y+3msh+2o=; b=x/aaIyodeRR0UxAE1c5fNDAPyffV8vWLJQP7nYwOSSNve9WmSbf1Bt3HVbA2lyQ1DW Qt7J14edHCxfUvrPqj5hEQ7GAiZsTSNwNBjXXqmKl/sKdJ+UbbDNqXRIOrNS5TIyyTuB nUpg8sUcHQoAklzGljACEwW8YebMh7f3Aj4Jk5vaQ7N4uGQGzH3HfY8zGgr0V7rNos3+ y9wpJ/SGYWh4kwkrF1SAAImYVPAjM3LqTGb225xr5nii3A0LSKXEalAyswjbWtmI3C/4 Ai87uL1nlVLGcqhha7O304nBAAABczYgsig/cWFLfNGN36ZQgLTxEbDlxlIOI/VHIefL z5Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=h8BBGiN0; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x5-20020a170906148500b006df76385b7asi332172ejc.26.2022.05.04.16.07.40; Wed, 04 May 2022 16:08:03 -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=@linuxfoundation.org header.s=korg header.b=h8BBGiN0; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358218AbiEDRPq (ORCPT + 99 others); Wed, 4 May 2022 13:15:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355589AbiEDREb (ORCPT ); Wed, 4 May 2022 13:04:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC4054EDFE; Wed, 4 May 2022 09:53:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7873861852; Wed, 4 May 2022 16:53:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3652C385B1; Wed, 4 May 2022 16:53:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683187; bh=5GWk5saE8ROutlKatYR8WyVxS3TvtOnNOKqy6FRw5l8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h8BBGiN06BFMaoRbFE2hOK4IaU/RvgkeNFnD5VFHd0VFhtlmZ6N5iFKge2BTAX3RC dSnKQB0M2Dg6a0DTI4PGulYHIrDk6/qXPaY1YCt6vVURaAeNGb5DANyzsf0Cfpe6bx cAdklCP2VpNC8341v1xcYii9CnSwiwS/3HExMB7s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maciej Fijalkowski , Daniel Borkmann , Sasha Levin Subject: [PATCH 5.15 052/177] xsk: Fix l2fwd for copy mode + busy poll combo Date: Wed, 4 May 2022 18:44:05 +0200 Message-Id: <20220504153057.659319163@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153053.873100034@linuxfoundation.org> References: <20220504153053.873100034@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 From: Maciej Fijalkowski [ Upstream commit 8de8b71b787f38983d414d2dba169a3bfefa668a ] While checking AF_XDP copy mode combined with busy poll, strange results were observed. rxdrop and txonly scenarios worked fine, but l2fwd broke immediately. After a deeper look, it turned out that for l2fwd, Tx side was exiting early due to xsk_no_wakeup() returning true and in the end xsk_generic_xmit() was never called. Note that AF_XDP Tx in copy mode is syscall steered, so the current behavior is broken. Txonly scenario only worked due to the fact that sk_mark_napi_id_once_xdp() was never called - since Rx side is not in the picture for this case and mentioned function is called in xsk_rcv_check(), sk::sk_napi_id was never set, which in turn meant that xsk_no_wakeup() was returning false (see the sk->sk_napi_id >= MIN_NAPI_ID check in there). To fix this, prefer busy poll in xsk_sendmsg() only when zero copy is enabled on a given AF_XDP socket. By doing so, busy poll in copy mode would not exit early on Tx side and eventually xsk_generic_xmit() will be called. Fixes: a0731952d9cd ("xsk: Add busy-poll support for {recv,send}msg()") Signed-off-by: Maciej Fijalkowski Signed-off-by: Daniel Borkmann Link: https://lore.kernel.org/bpf/20220406155804.434493-1-maciej.fijalkowski@intel.com Signed-off-by: Sasha Levin --- net/xdp/xsk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c index 426e287431d2..444ad0bc0908 100644 --- a/net/xdp/xsk.c +++ b/net/xdp/xsk.c @@ -655,7 +655,7 @@ static int __xsk_sendmsg(struct socket *sock, struct msghdr *m, size_t total_len if (sk_can_busy_loop(sk)) sk_busy_loop(sk, 1); /* only support non-blocking sockets */ - if (xsk_no_wakeup(sk)) + if (xs->zc && xsk_no_wakeup(sk)) return 0; pool = xs->pool; -- 2.35.1