Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1963310lqe; Tue, 9 Apr 2024 06:06:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUEWqwSjH8J2bFagCdWmtwueotYD4rB5A/XZe0hX8Tj2o78Gs4bQVpMCXJ4pGrPVOsTLjewuDdtTwd6sIIT341APa7dTc30ElwEevqUbQ== X-Google-Smtp-Source: AGHT+IGQYvnLTKIxUhkPtd2VrRP5P5oD7tPC415WXOkjOvcz6Ory4lIEuC9cQ+kTFo8Fnm6bBgp+ X-Received: by 2002:a17:902:ce8e:b0:1e4:7cc5:2292 with SMTP id f14-20020a170902ce8e00b001e47cc52292mr4066942plg.49.1712667969379; Tue, 09 Apr 2024 06:06:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712667969; cv=pass; d=google.com; s=arc-20160816; b=bGTQyDZWjFm69BDJMfT4oF2FrHDQycIYnkVV7/9UOy+3IGSSxboFti9Pms4GjkEIET Qg4EpjQCQpsCoRiSxAzIyT57dOkkKkyKEUlmRFYtvbs9YdOrEbelcYVceOOxZ+2pyTXb YU3oi1CngaVNx5S2Dka0rC27Iw449jSmG9sEOhyhRkBc1tB0Vpbm+Ik35RKEwaOlwKXs GPjogRKz+xvfyEyZcG0HnZTZLEt3euFG81hCqv8d3QN+VXCszbz4p/18rc5zw7yrZP3u SQmY9R9lx1B9Y5C4/MzE01FEz46dLAC7a6rM8jTTkz6WIDWrk2g2ERs90qhS2zkLXlg/ 4Cgg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=SOiDJKippIgWMoxQU2kFtESoBNJpC+0fpTgJoPzBWVA=; fh=SDT4nS1/ymhIvsAzHCpH5uVl7YApeKHZVVNrT4rNY1Q=; b=KKQtFJ2vbh+SpxV8RgO5zFkw5oJyEOCh/Ghl8qRihj2z+wERoPRPGeDHCiFiR0moSM 5PIRYFhPuTm4/eNL5bIgYAxt2t4/rZ0SrJaz6irKumeautCXj1BCAuAgAZ8AZVWaKMRK bZ0T97MtwYoQarRbIROpk5SWbEIRPgSbM0TQch7X+KgKQ4Sh8ssqyNEHTc7kKV3VT03k YFZtb6p8lrYZL3Atl/yOPCb8szGLRTXAE2/jaYak+Si/4nIzlOFjj7wgNANr20w74nIi S4C6b14IMLpyG7ZC3n/FEBdBIJsFe49MuVjqf9Ik0B8iacr3TZYD0IURVX6WV8h/RQlb aAhA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=31px0dfs; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-136891-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136891-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id o9-20020a170902d4c900b001e3e49e8a3csi5830888plg.154.2024.04.09.06.06.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 06:06:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136891-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=31px0dfs; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-136891-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136891-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 791BCB20A8D for ; Tue, 9 Apr 2024 12:52:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D123412E1C4; Tue, 9 Apr 2024 12:52:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="31px0dfs" Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) (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 053EA12DDA2; Tue, 9 Apr 2024 12:52:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.67.10.101 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712667142; cv=none; b=j4Ex/GTpCChB+fo69gfsyVPtTP60OOaDdAonQqzyoh7GvfPdDJvH1Yh2fFfMwdczsTAQJAFmn1+usiNXO80WPfAwNrXd3aGqqHvCbidEj7FCC43ijDskh6UJNUYVhWIwRrAprJaQMPduiPPydKitLp9tUhIseesB6YJPskUv42Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712667142; c=relaxed/simple; bh=41b/xhD3dPWFH2Cgl+OJc2iALYdSLEci2U9fZ4hnz+k=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JMBd7JliLNXZ3w0OXcrHogihyVtEdzgwqNAuAVEKnhihGEhpmIOBIxufD+fHkYW//8G+l1TUuUzbDPhjuP2ZTr0H+WYHvHGeZZ8AsJDFdDEkCQHdObOyl23a80L1w+mcvOMFtf5GET+04+upoy3ugJgc3wr2r5kW6rzQKwpst2M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b=31px0dfs; arc=none smtp.client-ip=156.67.10.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=SOiDJKippIgWMoxQU2kFtESoBNJpC+0fpTgJoPzBWVA=; b=31px0dfsxvJWYgtK2EYN81+mgX FTvXnHwQnouuYlmxONhKXJKIQIBzamX6wdArIX+b3JEX8ijjRho9B5rP7UVqN/q8ULMDHzJjfWEJm DCvhyl78W0cnUJgq7EyfQcMdPO6JdcC70LY4vVKwJ8gaEnwPY0PrA94+2W/Ln2ZqjEvI=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1ruAxM-00CZcj-IP; Tue, 09 Apr 2024 14:52:08 +0200 Date: Tue, 9 Apr 2024 14:52:08 +0200 From: Andrew Lunn To: Lei Chen Cc: Willem de Bruijn , Jason Wang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH] net:tun: limit printing rate when illegal packet received by tun dev Message-ID: <0e5a96b6-0862-4c00-b07f-7485af232475@lunn.ch> References: <20240409062407.1952728-1-lei.chen@smartx.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240409062407.1952728-1-lei.chen@smartx.com> On Tue, Apr 09, 2024 at 02:24:05AM -0400, Lei Chen wrote: > vhost_worker will call tun call backs to receive packets. If too many > illegal packets arrives, tun_do_read will keep dumping packet contents. > When console is enabled, it will costs much more cpu time to dump > packet and soft lockup will be detected. > > Rate limit mechanism can be used to limit the dumping rate. > @@ -2125,14 +2126,16 @@ static ssize_t tun_put_user(struct tun_struct *tun, > tun_is_little_endian(tun), true, > vlan_hlen)) { > struct skb_shared_info *sinfo = skb_shinfo(skb); > - pr_err("unexpected GSO type: " > - "0x%x, gso_size %d, hdr_len %d\n", > - sinfo->gso_type, tun16_to_cpu(tun, gso.gso_size), > - tun16_to_cpu(tun, gso.hdr_len)); > - print_hex_dump(KERN_ERR, "tun: ", > - DUMP_PREFIX_NONE, > - 16, 1, skb->head, > - min((int)tun16_to_cpu(tun, gso.hdr_len), 64), true); > + > + if (__ratelimit(&ratelimit)) { Maybe just use net_ratelimit() rather than add a new ratelimit variable? A separate issue, i wounder if rather than pr_err(), netdev_err(tun->dev, ...) should be used to indicate which TUN device has been given bad GSO packets? Andrew