From patchwork Sun Nov 17 21:20:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 13877958 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A45C1DDA32 for ; Sun, 17 Nov 2024 21:21:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731878471; cv=none; b=nCwd0cY1mreP8L4QpmqZDfSm1kMfuC3jsVd71Uwm5w7icVem6BLDKqlIHKJm+w1pVSgtXdI+TBqvISAw8NuiQS/6DO94O260TIJ2BeUUjHAo27apj8CjDrmAb9L33MoUhsO8lF1U6C5T8Z0TEahLKssoP3JWn5o9KRh/uz5fUVo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731878471; c=relaxed/simple; bh=myTrKPrEiCbr0l9ZVuL3vediqNX7OzsDWHXbBZFQFNg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b1YcX89SbJeb7xdEXXYwV7STdBhnUWWzmxxzp8ArW7rOazAShc03OhojwOyXMcGqJEy1DXoQGIA84QdNd9x/7NG3ep75OUMYLC0vrWWDHopZpB5pBUqwrZU4gFfR18Hs7JFTT3G83bAI1oskIkgeHsR5NgHvDXa7Cd+CSCNp97o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b=ib3Ej8zj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="ib3Ej8zj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C53CC4CED8; Sun, 17 Nov 2024 21:21:10 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="ib3Ej8zj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1731878469; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jAI3YYMq+wK8me9bfzDl3I3A7dq0Arq0Ow/Bnq4ULG8=; b=ib3Ej8zjyCaQ0SW8yLmZpXg/Ttw1XbfsWmf7onVXqPMFhO3a1AwjQQYX94LOXccbaYzb1l Zj0df8KocUmmDD0PaywHZO8Gy+KxxBhQ25aVCWqlC73AEHoVtilh9GItRrEWiU8f/FgpEm 5ispf5wNiuA9paPoEkZQ+c3WP4yYCLs= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 52a546eb (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sun, 17 Nov 2024 21:21:09 +0000 (UTC) From: "Jason A. Donenfeld" To: netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com Cc: Tobias Klauser , Simon Horman , "Jason A. Donenfeld" Subject: [PATCH net-next 1/4] wireguard: device: omit unnecessary memset of netdev private data Date: Sun, 17 Nov 2024 22:20:27 +0100 Message-ID: <20241117212030.629159-2-Jason@zx2c4.com> In-Reply-To: <20241117212030.629159-1-Jason@zx2c4.com> References: <20241117212030.629159-1-Jason@zx2c4.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Tobias Klauser The memory for netdev_priv is allocated using kvzalloc in alloc_netdev_mqs before rtnl_link_ops->setup is called so there is no need to zero it again in wg_setup. Signed-off-by: Tobias Klauser Reviewed-by: Simon Horman Signed-off-by: Jason A. Donenfeld --- drivers/net/wireguard/device.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/wireguard/device.c b/drivers/net/wireguard/device.c index 45e9b908dbfb..a2ba71fbbed4 100644 --- a/drivers/net/wireguard/device.c +++ b/drivers/net/wireguard/device.c @@ -302,7 +302,6 @@ static void wg_setup(struct net_device *dev) /* We need to keep the dst around in case of icmp replies. */ netif_keep_dst(dev); - memset(wg, 0, sizeof(*wg)); wg->dev = dev; } From patchwork Sun Nov 17 21:20:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 13877959 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CEE4A1DDA32 for ; Sun, 17 Nov 2024 21:21:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731878473; cv=none; b=b8T/doGIv7wJ9bS1QGRO7HZlYsfK8iAyTjqmNqb6q7ZkNAIxgBSR6mqdtR6s4icy1lqPoYJ+YORKNhj3gF1cC+puM3ieA+Js37VyN9NHbJTNDs832EmE7oo8rbtFi1zTvvlvRLdrjAY3R/XweDrUDbRxc9o5BNBC1jGy2NjAVsI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731878473; c=relaxed/simple; bh=TWpXHz18BmTz1HqGLrwkKlxAc3zXBYyPHZZ+Xr51kFc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ATcdtAaL9jJtEqy3Dsfg/rLTuwAfSgBpTf730YTaPbu7w+G8XRMKaNpiJNvPcdRZQT6GSLxM6veS+vB8e5mbfZNxgyqs35mZB08X3MHl8gvxK57Dl6FgKOBQrioiwPoBaRZHWZk8JzFNtphZ+X9JXHlweMYuIJjNWxSCjBGqHFQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b=p2JsW7sE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="p2JsW7sE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C9C3C4CECD; Sun, 17 Nov 2024 21:21:13 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="p2JsW7sE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1731878471; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DOXBQOJcaUccVx9FJFub+6t78xbHQ8Uulb/NRgyVCN0=; b=p2JsW7sEFkbMJCrf2ankl7uauBJMMLx6eMujKCJ+bd9H0I7qrcXTupGMUwcGdRXvT5Dxk/ NhOhNzLn1GZnQrrYH8dHIQ85rN8A/DghlaLo/7wQUZBbWtNtH6WRm7tWezIHmH0Ljtf8ol lBgXnRUVw5VptgV9YhK1MuWe5hoZ4Ls= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 7d9dc98f (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sun, 17 Nov 2024 21:21:11 +0000 (UTC) From: "Jason A. Donenfeld" To: netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com Cc: Dheeraj Reddy Jonnalagadda , "Jason A. Donenfeld" Subject: [PATCH net-next 2/4] wireguard: allowedips: remove redundant selftest call Date: Sun, 17 Nov 2024 22:20:28 +0100 Message-ID: <20241117212030.629159-3-Jason@zx2c4.com> In-Reply-To: <20241117212030.629159-1-Jason@zx2c4.com> References: <20241117212030.629159-1-Jason@zx2c4.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Dheeraj Reddy Jonnalagadda This commit fixes a useless call issue detected by Coverity (CID 1508092). The call to horrible_allowedips_lookup_v4 is unnecessary as its return value is never checked. Signed-off-by: Dheeraj Reddy Jonnalagadda Fixes: e7096c131e51 ("net: WireGuard secure network tunnel") Signed-off-by: Jason A. Donenfeld --- drivers/net/wireguard/selftest/allowedips.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/wireguard/selftest/allowedips.c b/drivers/net/wireguard/selftest/allowedips.c index 3d1f64ff2e12..25de7058701a 100644 --- a/drivers/net/wireguard/selftest/allowedips.c +++ b/drivers/net/wireguard/selftest/allowedips.c @@ -383,7 +383,6 @@ static __init bool randomized_test(void) for (i = 0; i < NUM_QUERIES; ++i) { get_random_bytes(ip, 4); if (lookup(t.root4, 32, ip) != horrible_allowedips_lookup_v4(&h, (struct in_addr *)ip)) { - horrible_allowedips_lookup_v4(&h, (struct in_addr *)ip); pr_err("allowedips random v4 self-test: FAIL\n"); goto free; } From patchwork Sun Nov 17 21:20:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 13877960 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0FB01DDA10 for ; Sun, 17 Nov 2024 21:21:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731878476; cv=none; b=KNYsq+PWv3aVVfhqbQebx7wWLjnBgwQfRb/pQ5DnDVw0ke3CLGSwpWrM54TbHddF/nc6YmRQnmMBIwyhSak6BuC42Ey8mBifHG5IZnX65uslO6et6seW4HlGkED0h4cWFI/M0RruhcRNTEF3axCVxVDVzavncZOnTJvek8JZ3N8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731878476; c=relaxed/simple; bh=w9cEU43BbFKQvcCN8rFZFMN5Swgxvg9k+7SWoqeZY0M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Sh2RWO/mntaiE2msSJEMojT9CThnRQSFisRJXQypQsAjouLR0N30J0WTPBuMLP0BYMC/dC82a1bcIg4IxqiRGXD0ARYlvrtcNZddnG/crbD+OKOaFVqKuxISdf5tLaEP+cPeln0VoEyBq8eJNCd2rtsVXvnpW15h0abTqT2n5hw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b=VO8TvOK8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="VO8TvOK8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFD84C4CED7; Sun, 17 Nov 2024 21:21:15 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="VO8TvOK8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1731878474; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fr+ue3lV00IafQ5IpqPjEfPR3OZp5mhckuDRMRSDja8=; b=VO8TvOK8npD90mA9HbTEYFCOKsOFclOYwl0gFcEWChNC/D9cuVgxhbJXgZ5k0gOcFKJ2ip 33UNz8+ViMmeed3Feh1Pc/b/twQz53xFsX2EXuqKsnVHNmZOWKDgeIFfZWJcVxdE5ntnDU OdUC3kqI05VsApK9W0JnjUVa9Z3HPNA= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 438d19b8 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sun, 17 Nov 2024 21:21:14 +0000 (UTC) From: "Jason A. Donenfeld" To: netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com Cc: Hangbin Liu , Simon Horman , "Jason A. Donenfeld" Subject: [PATCH net-next 3/4] wireguard: selftests: load nf_conntrack if not present Date: Sun, 17 Nov 2024 22:20:29 +0100 Message-ID: <20241117212030.629159-4-Jason@zx2c4.com> In-Reply-To: <20241117212030.629159-1-Jason@zx2c4.com> References: <20241117212030.629159-1-Jason@zx2c4.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Hangbin Liu Some distros may not load nf_conntrack by default, which will cause subsequent nf_conntrack sets to fail. Load this module if it is not already loaded. Fixes: e7096c131e51 ("net: WireGuard secure network tunnel") Signed-off-by: Hangbin Liu Reviewed-by: Simon Horman [ Jason: add [[ -e ... ]] check so this works in the qemu harness. ] Signed-off-by: Jason A. Donenfeld --- tools/testing/selftests/wireguard/netns.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/wireguard/netns.sh b/tools/testing/selftests/wireguard/netns.sh index 405ff262ca93..55500f901fbc 100755 --- a/tools/testing/selftests/wireguard/netns.sh +++ b/tools/testing/selftests/wireguard/netns.sh @@ -332,6 +332,7 @@ waitiface $netns1 vethc waitiface $netns2 veths n0 bash -c 'printf 1 > /proc/sys/net/ipv4/ip_forward' +[[ -e /proc/sys/net/netfilter/nf_conntrack_udp_timeout ]] || modprobe nf_conntrack n0 bash -c 'printf 2 > /proc/sys/net/netfilter/nf_conntrack_udp_timeout' n0 bash -c 'printf 2 > /proc/sys/net/netfilter/nf_conntrack_udp_timeout_stream' n0 iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -d 10.0.0.0/24 -j SNAT --to 10.0.0.1 From patchwork Sun Nov 17 21:20:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 13877961 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 504E51DDA10 for ; Sun, 17 Nov 2024 21:21:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731878478; cv=none; b=JIvBuc8HaopNtXJSaJYj0BDVd7MT4W4F4OV0mlqAsgVZbk9MFKcmHuzGBmOo58sEwGwQ1XIVCECeb7iWggy4PQ1yFL6j8VdR/J9fKu55WixQnB5NXpUuKWxqxHCUedVFpkoMCSg2Hq2MCJDOl0oajqM5ffdILvaunfO4AItjd/w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731878478; c=relaxed/simple; bh=aZ8mv1H8hAV5CmggfZBcJ/BBuPJho73gMOmFXaDj438=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s4DMd1D32iekgz1Nsn4tJjXEUJ8+yqJb8AJZMSJ83WumVnjeWp0QRHwrppo5YQGwntw65GZUbmSr2TZg3Nv7ejkO14SWUzTUcQw7XLX1UWZ6iuAu8CemtCr54UlZ5DW/Ro5DBqX1qcR7GoMSYEqXwdFA8iUynNAgV+SSPauKl80= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b=UaBUHwo7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="UaBUHwo7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2C6FC4CECD; Sun, 17 Nov 2024 21:21:17 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="UaBUHwo7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1731878476; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M3coEH8+ObZEE1tdbLgyTn35HDYTQZNWur0xxCUN62s=; b=UaBUHwo7cvA4cJwXW4mTBMrJ4+O+yCzTLvGtzetAjb7ghxzUBLtWdJG7F2VlagBpU26amW Cr+ogj2/02KRwAIUN6EASLsq0WnyepLhOk9n6Af7YH1qxddXAt6Pc9w3b1+wZN096sdsOs RJiy/qSvqxT8RlQq0Kf5okVIzNeEFy8= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 7d50f56b (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sun, 17 Nov 2024 21:21:16 +0000 (UTC) From: "Jason A. Donenfeld" To: netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com Cc: Daniel Borkmann , "Jason A. Donenfeld" Subject: [PATCH net-next 4/4] wireguard: device: support big tcp GSO Date: Sun, 17 Nov 2024 22:20:30 +0100 Message-ID: <20241117212030.629159-5-Jason@zx2c4.com> In-Reply-To: <20241117212030.629159-1-Jason@zx2c4.com> References: <20241117212030.629159-1-Jason@zx2c4.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Daniel Borkmann Advertise GSO_MAX_SIZE as TSO max size in order support BIG TCP for wireguard. This helps to improve wireguard performance a bit when enabled as it allows wireguard to aggregate larger skbs in wg_packet_consume_data_done() via napi_gro_receive(), but also allows the stack to build larger skbs on xmit where the driver then segments them before encryption inside wg_xmit(). We've seen a 15% improvement in TCP stream performance. Signed-off-by: Daniel Borkmann Signed-off-by: Jason A. Donenfeld --- drivers/net/wireguard/device.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireguard/device.c b/drivers/net/wireguard/device.c index a2ba71fbbed4..6cf173a008e7 100644 --- a/drivers/net/wireguard/device.c +++ b/drivers/net/wireguard/device.c @@ -302,6 +302,8 @@ static void wg_setup(struct net_device *dev) /* We need to keep the dst around in case of icmp replies. */ netif_keep_dst(dev); + netif_set_tso_max_size(dev, GSO_MAX_SIZE); + wg->dev = dev; }