From: David Miller <davem@davemloft.net>
To: marcelo.leitner@gmail.com
Cc: netdev@vger.kernel.org, jmaxwell37@gmail.com,
alexandre.sidorenko@hpe.com, kuznet@ms2.inr.ac.ru,
jmorris@namei.org, yoshfuji@linux-ipv6.org, kaber@trash.net,
tlfalcon@linux.vnet.ibm.com, brking@linux.vnet.ibm.com,
eric.dumazet@gmail.com
Subject: Re: [PATCH net v3] tcp: warn on bogus MSS and try to amend it
Date: Sat, 03 Dec 2016 23:37:03 -0500 (EST) [thread overview]
Message-ID: <20161203.233703.784557738334949173.davem@davemloft.net> (raw)
In-Reply-To: <83a3345f2fae904fa59794d59703d86851cda7d5.1480718620.git.marcelo.leitner@gmail.com>
From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Date: Fri, 2 Dec 2016 20:51:51 -0200
> @@ -144,7 +144,21 @@ static void tcp_measure_rcv_mss(struct sock *sk, const struct sk_buff *skb)
> */
> len = skb_shinfo(skb)->gso_size ? : skb->len;
> if (len >= icsk->icsk_ack.rcv_mss) {
> - icsk->icsk_ack.rcv_mss = len;
> + static bool __once __read_mostly;
> +
> + icsk->icsk_ack.rcv_mss = min_t(unsigned int, len,
> + tcp_sk(sk)->advmss);
> + if (icsk->icsk_ack.rcv_mss != len && !__once) {
> + struct net_device *dev;
> +
> + __once = true;
> +
> + rcu_read_lock();
> + dev = dev_get_by_index_rcu(sock_net(sk), skb->skb_iif);
> + pr_warn_once("%s: Driver has suspect GRO implementation, TCP performance may be compromised.\n",
> + dev ? dev->name : "Unknown driver");
> + rcu_read_unlock();
> + }
This is almost ready to go.
Since you are doing the 'once' logic by hand, using pr_warn_once() is
redundant. And while you're at it, why not split this into a helper
function:
static void tcp_gro_dev_warn(struct sock *sk, const struct sk_buff *skb)
{
static bool __once __read_mostly;
if (!__once) {
__once = true;
rcu_read_lock();
dev = dev_get_by_index_rcu(sock_net(sk), skb->skb_iif);
pr_warn("%s: Driver has suspect GRO implementation, TCP performance may be compromised.\n",
dev ? dev->name : "Unknown driver");
rcu_read_unlock();
}
}
And then call that when icsk->icsk_ack.rcv_mss != len, you can even
put an unlikely() around the condition as well.
prev parent reply other threads:[~2016-12-04 4:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-02 22:51 [PATCH net v3] tcp: warn on bogus MSS and try to amend it Marcelo Ricardo Leitner
2016-12-04 4:37 ` David Miller [this message]
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=20161203.233703.784557738334949173.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=alexandre.sidorenko@hpe.com \
--cc=brking@linux.vnet.ibm.com \
--cc=eric.dumazet@gmail.com \
--cc=jmaxwell37@gmail.com \
--cc=jmorris@namei.org \
--cc=kaber@trash.net \
--cc=kuznet@ms2.inr.ac.ru \
--cc=marcelo.leitner@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=tlfalcon@linux.vnet.ibm.com \
--cc=yoshfuji@linux-ipv6.org \
/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;
as well as URLs for NNTP newsgroup(s).