From: gfree.wind@foxmail.com
To: davem@davemloft.net, kuznet@ms2.inr.ac.ru, jmorris@namei.org,
netdev@vger.kernel.org
Cc: Gao Feng <fgao@ikuai8.com>
Subject: [PATCH net-next 1/1] net: ipv4: Refine the ipv4_default_advmss
Date: Wed, 12 Apr 2017 09:36:39 +0800 [thread overview]
Message-ID: <1491960999-42794-1-git-send-email-gfree.wind@foxmail.com> (raw)
From: Gao Feng <fgao@ikuai8.com>
1. Don't get the metric RTAX_ADVMSS of dst.
There are two reasons.
1) Its caller dst_metric_advmss has already invoke dst_metric_advmss
before invoke default_advmss.
2) The ipv4_default_advmss is used to get the default mss, it should
not try to get the metric like ip6_default_advmss.
2. Use sizeof(tcphdr)+sizeof(iphdr) instead of literal 40.
3. Define one new macro IPV4_MAX_PMTU instead of 65535 according to
RFC 2675, section 5.1.
Signed-off-by: Gao Feng <fgao@ikuai8.com>
---
include/net/ip.h | 2 ++
net/ipv4/route.c | 11 ++++-------
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/include/net/ip.h b/include/net/ip.h
index bf264a8..821cedc 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -33,6 +33,8 @@
#include <net/flow.h>
#include <net/flow_dissector.h>
+#define IPV4_MAX_PMTU 65535U /* RFC 2675, Section 5.1 */
+
struct sock;
struct inet_skb_parm {
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 5e1e605..b4fca1e 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1250,14 +1250,11 @@ static void set_class_tag(struct rtable *rt, u32 tag)
static unsigned int ipv4_default_advmss(const struct dst_entry *dst)
{
- unsigned int advmss = dst_metric_raw(dst, RTAX_ADVMSS);
+ unsigned int header_size = sizeof(struct tcphdr) + sizeof(struct iphdr);
+ unsigned int advmss = max_t(unsigned int, dst->dev->mtu - header_size,
+ ip_rt_min_advmss);
- if (advmss == 0) {
- advmss = max_t(unsigned int, dst->dev->mtu - 40,
- ip_rt_min_advmss);
- if (advmss > 65535 - 40)
- advmss = 65535 - 40;
- }
+ advmss = min_t(unsigned int, advmss, IPV4_MAX_PMTU - header_size);
return advmss;
}
--
1.9.1
next reply other threads:[~2017-04-12 1:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-12 1:36 gfree.wind [this message]
2017-04-12 2:03 ` [PATCH net-next 1/1] net: ipv4: Refine the ipv4_default_advmss Joe Perches
2017-04-12 2:33 ` Gao Feng
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=1491960999-42794-1-git-send-email-gfree.wind@foxmail.com \
--to=gfree.wind@foxmail.com \
--cc=davem@davemloft.net \
--cc=fgao@ikuai8.com \
--cc=jmorris@namei.org \
--cc=kuznet@ms2.inr.ac.ru \
--cc=netdev@vger.kernel.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).