* [PATCH] [net-next] tcp: avoid sending zero TSval
@ 2009-08-31 17:44 Octavian Purdila
2009-09-02 1:16 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Octavian Purdila @ 2009-08-31 17:44 UTC (permalink / raw)
To: netdev
[-- Attachment #1: Type: text/plain, Size: 552 bytes --]
Per RFC1323, zero TSecr is considered invalid. Thus we must avoid when
possible sending a zero TSval.
Currently, we use the least significant 32 bits of jiffies to fill in
TSval. But that can wrap around to zero (in 5 minutes after reboot,
and every 49 days after that in the worst case).
This patch approximate a wrap-around zero TSval to 1. This is better
then emitting a value which will be ignored.
Signed-off-by: Octavian Purdila <opurdila@ixiacom.com>
---
net/ipv4/tcp_output.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
[-- Attachment #2: 71e6d2ae2ae12cfaf0d7cb8e010fd0c7f520874b.diff --]
[-- Type: text/x-patch, Size: 598 bytes --]
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 4e00442..607d675 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -415,7 +415,10 @@ static void tcp_options_write(__be32 *ptr, struct tcp_sock *tp,
(TCPOPT_TIMESTAMP << 8) |
TCPOLEN_TIMESTAMP);
}
- *ptr++ = htonl(opts->tsval);
+ /* Currently, opts->tsval always comes from tcp_time_stamp.
+ * Thus, if zero, its caused by jiffie wrap-around, and we can
+ * approximate it to one to avoid a later TSecr drop */
+ *ptr++ = htonl(opts->tsval?:1);
*ptr++ = htonl(opts->tsecr);
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] [net-next] tcp: avoid sending zero TSval
2009-08-31 17:44 [PATCH] [net-next] tcp: avoid sending zero TSval Octavian Purdila
@ 2009-09-02 1:16 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2009-09-02 1:16 UTC (permalink / raw)
To: opurdila; +Cc: netdev
From: Octavian Purdila <opurdila@ixiacom.com>
Date: Mon, 31 Aug 2009 20:44:56 +0300
> Per RFC1323, zero TSecr is considered invalid. Thus we must avoid when
> possible sending a zero TSval.
>
> Currently, we use the least significant 32 bits of jiffies to fill in
> TSval. But that can wrap around to zero (in 5 minutes after reboot,
> and every 49 days after that in the worst case).
>
> This patch approximate a wrap-around zero TSval to 1. This is better
> then emitting a value which will be ignored.
>
> Signed-off-by: Octavian Purdila <opurdila@ixiacom.com>
Ok, I've changed my mind again. I think we need to go with
a solution like this.
Even if we could somehow justify allowing zero timestamps,
I just checked some other stacks and all of them ignore zero
tsecr values. So we can't make that kind of change no matter
what.
This patch needs some changes.
We have to adjust the tests we make against tsecr.
If we bump up a zero jiffies to one in an advertised timestamp,
then we get back a tsecr value of one, and jiffies is still
zero, we should use a comparison value of one not zero.
This is not trivial. You might think it's OK to handle all of
this by just adjusting the definition of tcp_time_stamp but that
gets used by a lot of other things in the stack so those side
effects need to be analyzed.
Grepping around also shows that we also have some code that doesn't
handle jiffies wraparound at all, f.e. check out the rcv_tsecr tests
in net/ipv4/tcp_lp.c :-/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-09-02 1:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-31 17:44 [PATCH] [net-next] tcp: avoid sending zero TSval Octavian Purdila
2009-09-02 1:16 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox