Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp824370rdb; Thu, 30 Nov 2023 22:11:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IEREdyIdq84BlkYC4gSw4rRxVq6u3pSjDOmrgWaVrF4mzoFdCGKKHNgRDjaY288lUYtxGXC X-Received: by 2002:a17:902:b216:b0:1d0:5114:306a with SMTP id t22-20020a170902b21600b001d05114306amr1348728plr.9.1701411074005; Thu, 30 Nov 2023 22:11:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701411073; cv=none; d=google.com; s=arc-20160816; b=qVYdNw2dlvSshmhq5SbYtTEgP90Y3fQ2BGLyEkd52cSuDuQDek10LXhhMhJBp9Xx9T alfR6dA/xT+LVExVx2gO9VaN0MhOLI8J04RzKHrdvR+YBf3gptxfU4dM6YmtOR8LvfC9 dUr3P6dwboGIh9EGsBzkTRfS0Yfab8Jk0+Z1x8dS19ewLozax8n9iSicwYn33SONrtGb FVX8cpDyP+W13I7U+larBUBrZnkRLKnqJNRMRUfA8qyGNkVEDRR3d2SUygzrLFmZrTQ2 VhjtinQabq8gpPVF5LOGAFQ4+QYtaie+QwR3zeGCj9j0VsGG6LqmDgFekkFlznWnhQeh 7bfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=EcGW2snvrekVzF3EzV8UgTK2J7ldfnV3vnpkmjMkLSI=; fh=ztV6HPkXIckfGKDXeZyl/BpK6086iCWVavLA06/EHL4=; b=pNUNDmJOlausH6cY+Vu1MpRzzbbZQlJAy5YuyjUuM5oYD3UtHjoqSTKrLLNVuAANtU PZiN5SHw4pGw3j5c/oVGGhg0si8G+jy2YaoAFlZ0pKJX/ErsJoKiXNeHllQjw+Oqwxaj Vgs6pH5YQyejt3m2Vu+c4SBwD+kk6foaH2FX8hioxmSAjxkTW1pgpyhAfBU/MBrGyd/f ULV4bZa7shY908P2OCKqS0tFSTr2R/l6LxymagU6HBJN3l8T0u57Cf5+Ypn1yIkg+oZe UoyfqFOg42rygry3et538sdd/uMMj4G00mvXSxLJYNMBXxllemY3+0y3Kfv46dcWuqcd k0ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=j3IpWRwc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id p6-20020a170902b08600b001cfa9d9f585si2566992plr.369.2023.11.30.22.11.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 22:11:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=j3IpWRwc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id B8CAA8317573; Thu, 30 Nov 2023 22:11:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377597AbjLAGKz (ORCPT + 99 others); Fri, 1 Dec 2023 01:10:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377595AbjLAGKx (ORCPT ); Fri, 1 Dec 2023 01:10:53 -0500 Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93220D7D; Thu, 30 Nov 2023 22:10:59 -0800 (PST) Received: by mail-ot1-x32b.google.com with SMTP id 46e09a7af769-6d7eca548ccso106415a34.3; Thu, 30 Nov 2023 22:10:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701411059; x=1702015859; darn=vger.kernel.org; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=EcGW2snvrekVzF3EzV8UgTK2J7ldfnV3vnpkmjMkLSI=; b=j3IpWRwc8oT0M15H09FL4blCP6vakj8aa2HAKixTsvGUj3DwOXe4cLShYoTfhEuQ10 ymaIlA36RC8DSEAtGT/Yd2x6OPxAfr8th1Dzfq6wmb2UkXW4s2vKOR//Qz9h1Po8e4vz kLJJe4RuIKmzLNWCCn95Cof8cZvt8QE4pIlwYLDr/HoFZ25jzum7fTefSNG3p3dKVJ0L roBdBxHT3Ef1ZCUYMtWzOE+6yXTLbdARGeN161Ik8SoG/pwSe0p0NYcA0cugtkpPt748 D5bc832ki2cgKd2s+hKdV0s/2xXtkXE68tVp7DD6g5jlKuFMLd+3OqBCmxJ4HArhoeEd QE5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701411059; x=1702015859; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EcGW2snvrekVzF3EzV8UgTK2J7ldfnV3vnpkmjMkLSI=; b=mFwkocqehMn2lBf0IAyZcdofrTDIbVDPi7MeqWI0OzPUjMLIvOqam7mJwN8gVOCeoc ENSFttcDEW1i3ZgAtrBvBz06b/5p8SIr6P3iWgzja/v60IBwN8wFVY1Q6kcKYnlCYv7o pJq9ge+1FWNJsmd6JeHn3BfF1uPuEuXsLrcDmSB2qb/2EaxAw18UBFhWSJ7X3rWjzlxx HNFhQOkTEOEKLeF5pXwswzjvqtEBkj+BtKhnyphD/0oUZ18FGt5cZA+5DI5L41C37Hfs kbeSYWjQHb9IcfTvq37L/4X9sgeaIy4osv+KaFJdOar0qqDr4J0w+4t+33psaCURIJ6W PViA== X-Gm-Message-State: AOJu0YxQ1qSYK1sMUWjeaMCGerO0RWlaNvVQMGKgITPDMuwCuXtIggac jf1bGv2b4Q3zDJKxxLHvRG9lUtfRWXFtJQ== X-Received: by 2002:a05:6870:2189:b0:1fa:1719:dce2 with SMTP id l9-20020a056870218900b001fa1719dce2mr27978230oae.28.1701411058743; Thu, 30 Nov 2023 22:10:58 -0800 (PST) Received: from libra05 ([143.248.188.128]) by smtp.gmail.com with ESMTPSA id i31-20020a63221f000000b005bd2b3a03eesm2259837pgi.6.2023.11.30.22.10.54 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Nov 2023 22:10:58 -0800 (PST) Date: Fri, 1 Dec 2023 15:10:52 +0900 From: Yewon Choi To: =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Cc: threeearcat@gmail.com Subject: [PATCH bpf] xsk: skip polling event check for unbound socket Message-ID: <20231201061048.GA1510@libra05> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 30 Nov 2023 22:11:10 -0800 (PST) In xsk_poll(), checking available events and setting mask bits should be executed only when a socket has been bound. Setting mask bits for unbound socket is meaningless. Currently, it checks events even when xsk_check_common() failed. To prevent this, we move goto location (skip_tx) after that checking. Fixes: 1596dae2f17e ("xsk: check IFF_UP earlier in Tx path") Signed-off-by: Yewon Choi --- net/xdp/xsk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c index ae9f8cb611f6..1e5a65326d1d 100644 --- a/net/xdp/xsk.c +++ b/net/xdp/xsk.c @@ -947,7 +947,7 @@ static __poll_t xsk_poll(struct file *file, struct socket *sock, rcu_read_lock(); if (xsk_check_common(xs)) - goto skip_tx; + goto out; pool = xs->pool; @@ -959,12 +959,12 @@ static __poll_t xsk_poll(struct file *file, struct socket *sock, xsk_generic_xmit(sk); } -skip_tx: if (xs->rx && !xskq_prod_is_empty(xs->rx)) mask |= EPOLLIN | EPOLLRDNORM; if (xs->tx && xsk_tx_writeable(xs)) mask |= EPOLLOUT | EPOLLWRNORM; +out: rcu_read_unlock(); return mask; } -- 2.37.3