* [PATCH net-next 1/1] net: tcp: Define the TCP_MAX_WSCALE instead of literal number 14
@ 2017-04-01 4:14 gfree.wind
2017-04-02 18:59 ` Neal Cardwell
0 siblings, 1 reply; 4+ messages in thread
From: gfree.wind @ 2017-04-01 4:14 UTC (permalink / raw)
To: davem, kuznet, jmorris, kaber, netdev; +Cc: Gao Feng
From: Gao Feng <fgao@ikuai8.com>
Define one new macro TCP_MAX_WSCALE instead of literal number '14',
and use U16_MAX instead of 65535 as the max value of TCP window.
There is another minor change, use rounddown(space, mss) instead of
(space / mss) * mss;
Signed-off-by: Gao Feng <fgao@ikuai8.com>
---
include/net/tcp.h | 3 +++
net/ipv4/tcp.c | 2 +-
net/ipv4/tcp_input.c | 4 ++--
net/ipv4/tcp_output.c | 8 ++++----
4 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index e614ad4..2a89881 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -78,6 +78,9 @@
/* Maximal number of ACKs sent quickly to accelerate slow-start. */
#define TCP_MAX_QUICKACKS 16U
+/* Maximal number of window scale according to RFC1323 */
+#define TCP_MAX_WSCALE 14U
+
/* urg_data states */
#define TCP_URG_VALID 0x0100
#define TCP_URG_NOTYET 0x0200
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index cf45555..95be443 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2393,7 +2393,7 @@ static int tcp_repair_options_est(struct tcp_sock *tp,
u16 snd_wscale = opt.opt_val & 0xFFFF;
u16 rcv_wscale = opt.opt_val >> 16;
- if (snd_wscale > 14 || rcv_wscale > 14)
+ if (snd_wscale > TCP_MAX_WSCALE || rcv_wscale > TCP_MAX_WSCALE)
return -EFBIG;
tp->rx_opt.snd_wscale = snd_wscale;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index bb09c70..e277901 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -3759,11 +3759,11 @@ void tcp_parse_options(const struct sk_buff *skb,
!estab && sysctl_tcp_window_scaling) {
__u8 snd_wscale = *(__u8 *)ptr;
opt_rx->wscale_ok = 1;
- if (snd_wscale > 14) {
+ if (snd_wscale > TCP_MAX_WSCALE) {
net_info_ratelimited("%s: Illegal window scaling value %d >14 received\n",
__func__,
snd_wscale);
- snd_wscale = 14;
+ snd_wscale = TCP_MAX_WSCALE;
}
opt_rx->snd_wscale = snd_wscale;
}
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 22548b5..d8f12d7 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -212,12 +212,12 @@ void tcp_select_initial_window(int __space, __u32 mss,
/* If no clamp set the clamp to the max possible scaled window */
if (*window_clamp == 0)
- (*window_clamp) = (65535 << 14);
+ (*window_clamp) = (U16_MAX << TCP_MAX_WSCALE);
space = min(*window_clamp, space);
/* Quantize space offering to a multiple of mss if possible. */
if (space > mss)
- space = (space / mss) * mss;
+ space = rounddown(space, mss);
/* NOTE: offering an initial window larger than 32767
* will break some buggy TCP stacks. If the admin tells us
@@ -240,7 +240,7 @@ void tcp_select_initial_window(int __space, __u32 mss,
space = max_t(u32, space, sysctl_tcp_rmem[2]);
space = max_t(u32, space, sysctl_rmem_max);
space = min_t(u32, space, *window_clamp);
- while (space > 65535 && (*rcv_wscale) < 14) {
+ while (space > U16_MAX && (*rcv_wscale) < TCP_MAX_WSCALE) {
space >>= 1;
(*rcv_wscale)++;
}
@@ -253,7 +253,7 @@ void tcp_select_initial_window(int __space, __u32 mss,
}
/* Set the clamp no higher than max representable value */
- (*window_clamp) = min(65535U << (*rcv_wscale), *window_clamp);
+ (*window_clamp) = min_t(__u32, U16_MAX << (*rcv_wscale), *window_clamp);
}
EXPORT_SYMBOL(tcp_select_initial_window);
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next 1/1] net: tcp: Define the TCP_MAX_WSCALE instead of literal number 14
2017-04-01 4:14 [PATCH net-next 1/1] net: tcp: Define the TCP_MAX_WSCALE instead of literal number 14 gfree.wind
@ 2017-04-02 18:59 ` Neal Cardwell
2017-04-03 13:26 ` Gao Feng
0 siblings, 1 reply; 4+ messages in thread
From: Neal Cardwell @ 2017-04-02 18:59 UTC (permalink / raw)
To: gfree.wind
Cc: David Miller, Alexey Kuznetsov, James Morris, Patrick McHardy,
Netdev, Gao Feng
On Sat, Apr 1, 2017 at 12:14 AM, <gfree.wind@foxmail.com> wrote:
> From: Gao Feng <fgao@ikuai8.com>
>
> Define one new macro TCP_MAX_WSCALE instead of literal number '14',
> and use U16_MAX instead of 65535 as the max value of TCP window.
> There is another minor change, use rounddown(space, mss) instead of
> (space / mss) * mss;
>
> Signed-off-by: Gao Feng <fgao@ikuai8.com>
> ---
Looks OK to me.
IMHO this is a nice direction, since there is a proposal to increase
the maximum shift factor from 14 to 15:
https://tools.ietf.org/html/draft-nishida-tcpm-maxwin-03
Though there are a few spots where a literal 14 appears:
tcp_input.c:3763: net_info_ratelimited("%s: Illegal window scaling
value %d >14 received\n",
tcp_output.c:238: * See RFC1323 for an explanation of
the limit to 14
neal
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH net-next 1/1] net: tcp: Define the TCP_MAX_WSCALE instead of literal number 14
2017-04-02 18:59 ` Neal Cardwell
@ 2017-04-03 13:26 ` Gao Feng
2017-04-03 13:36 ` Neal Cardwell
0 siblings, 1 reply; 4+ messages in thread
From: Gao Feng @ 2017-04-03 13:26 UTC (permalink / raw)
To: 'Neal Cardwell'
Cc: 'David Miller', 'Alexey Kuznetsov',
'James Morris', 'Patrick McHardy',
'Netdev', 'Gao Feng'
> -----Original Message-----
> From: Neal Cardwell [mailto:ncardwell@google.com]
> Sent: Monday, April 3, 2017 2:59 AM
> To: gfree.wind@foxmail.com
> Cc: David Miller <davem@davemloft.net>; Alexey Kuznetsov
> <kuznet@ms2.inr.ac.ru>; James Morris <jmorris@namei.org>; Patrick McHardy
> <kaber@trash.net>; Netdev <netdev@vger.kernel.org>; Gao Feng
> <fgao@ikuai8.com>
> Subject: Re: [PATCH net-next 1/1] net: tcp: Define the TCP_MAX_WSCALE
> instead of literal number 14
>
> On Sat, Apr 1, 2017 at 12:14 AM, <gfree.wind@foxmail.com> wrote:
> > From: Gao Feng <fgao@ikuai8.com>
> >
> > Define one new macro TCP_MAX_WSCALE instead of literal number '14',
> > and use U16_MAX instead of 65535 as the max value of TCP window.
> > There is another minor change, use rounddown(space, mss) instead of
> > (space / mss) * mss;
> >
> > Signed-off-by: Gao Feng <fgao@ikuai8.com>
> > ---
>
> Looks OK to me.
>
> IMHO this is a nice direction, since there is a proposal to increase the maximum
> shift factor from 14 to 15:
> https://tools.ietf.org/html/draft-nishida-tcpm-maxwin-03
Do you mean enlarge the wscale to 15 now ?
>
> Though there are a few spots where a literal 14 appears:
>
> tcp_input.c:3763: net_info_ratelimited("%s: Illegal window scaling
> value %d >14 received\n",
>
> tcp_output.c:238: * See RFC1323 for an explanation of
> the limit to 14
Ok, I will update these two spots.
Regards
Feng
>
>
> neal
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next 1/1] net: tcp: Define the TCP_MAX_WSCALE instead of literal number 14
2017-04-03 13:26 ` Gao Feng
@ 2017-04-03 13:36 ` Neal Cardwell
0 siblings, 0 replies; 4+ messages in thread
From: Neal Cardwell @ 2017-04-03 13:36 UTC (permalink / raw)
To: Gao Feng
Cc: David Miller, Alexey Kuznetsov, James Morris, Patrick McHardy,
Netdev, Gao Feng
On Mon, Apr 3, 2017 at 9:26 AM, Gao Feng <gfree.wind@foxmail.com> wrote:
>>
>> Looks OK to me.
>>
>> IMHO this is a nice direction, since there is a proposal to increase the maximum
>> shift factor from 14 to 15:
>> https://tools.ietf.org/html/draft-nishida-tcpm-maxwin-03
>
> Do you mean enlarge the wscale to 15 now ?
No, I just meant that it will be easier to change if we ever decide to
change this to 15.
>> Though there are a few spots where a literal 14 appears:
>>
>> tcp_input.c:3763: net_info_ratelimited("%s: Illegal window scaling
>> value %d >14 received\n",
>>
>> tcp_output.c:238: * See RFC1323 for an explanation of
>> the limit to 14
>
> Ok, I will update these two spots.
OK, thanks.
neal
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-04-03 13:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-01 4:14 [PATCH net-next 1/1] net: tcp: Define the TCP_MAX_WSCALE instead of literal number 14 gfree.wind
2017-04-02 18:59 ` Neal Cardwell
2017-04-03 13:26 ` Gao Feng
2017-04-03 13:36 ` Neal Cardwell
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.