From: Jason Wang <jasowang@redhat.com>
To: Lei Chen <lei.chen@smartx.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH] net:tun: limit printing rate when illegal packet received by tun dev
Date: Wed, 10 Apr 2024 12:00:32 +0800 [thread overview]
Message-ID: <CACGkMEuiROr4EydSp+HFgG2GPqsda0zpfge5DvsSDEbsyWDuLg@mail.gmail.com> (raw)
In-Reply-To: <CAKcXpBwE-8p+naDgJnCU41ODxRhWq7CkhEeeOAw+Ode4-J6CLw@mail.gmail.com>
On Wed, Apr 10, 2024 at 10:23 AM Lei Chen <lei.chen@smartx.com> wrote:
>
> On Tue, Apr 9, 2024 at 8:52 PM Andrew Lunn <andrew@lunn.ch> wrote:
> >
> > 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?
>
> Thanks for your suggestion, net_ratelimit is a better way to make it.
+1
Thanks
>
> >
> > 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?
>
> I got it, I'll remake the patch, thanks.
>
next prev parent reply other threads:[~2024-04-10 4:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-09 6:24 Lei Chen
2024-04-09 12:52 ` Andrew Lunn
2024-04-10 2:23 ` Lei Chen
2024-04-10 4:00 ` Jason Wang [this message]
2024-04-10 1:25 ` Jakub Kicinski
2024-04-10 2:24 ` Lei Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CACGkMEuiROr4EydSp+HFgG2GPqsda0zpfge5DvsSDEbsyWDuLg@mail.gmail.com \
--to=jasowang@redhat.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=lei.chen@smartx.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemdebruijn.kernel@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®