ipv4: Fix IP timestamp option (IPOPT_TS_PRESPEC) handling in ip_options_echo()
commit8628bd8af7c4c14f40f5183f80f5744c4e682439
authorJan Luebbe <jluebbe@debian.org>
Thu, 24 Mar 2011 07:44:22 +0000 (24 07:44 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Mar 2011 06:35:02 +0000 (27 23:35 -0700)
treed931f03c6ef14ad8df7c6c697e56081f816c2af7
parentdc760b375e50a47847d4942811bd9679beeb5535
ipv4: Fix IP timestamp option (IPOPT_TS_PRESPEC) handling in ip_options_echo()

The current handling of echoed IP timestamp options with prespecified
addresses is rather broken since the 2.2.x kernels. As far as i understand
it, it should behave like when originating packets.

Currently it will only timestamp the next free slot if:
 - there is space for *two* timestamps
 - some random data from the echoed packet taken as an IP is *not* a local IP

This first is caused by an off-by-one error. 'soffset' points to the next
free slot and so we only need to have 'soffset + 7 <= optlen'.

The second bug is using sptr as the start of the option, when it really is
set to 'skb_network_header(skb)'. I just use dptr instead which points to
the timestamp option.

Finally it would only timestamp for non-local IPs, which we shouldn't do.
So instead we exclude all unicast destinations, similar to what we do in
ip_options_compile().

Signed-off-by: Jan Luebbe <jluebbe@debian.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/ip_options.c