From patchwork Thu Mar 24 17:44:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Luebbe X-Patchwork-Id: 88260 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id EDA651007D2 for ; Fri, 25 Mar 2011 04:44:36 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932975Ab1CXRob (ORCPT ); Thu, 24 Mar 2011 13:44:31 -0400 Received: from sirius.lasnet.de ([78.47.116.19]:33832 "EHLO sirius.lasnet.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932109Ab1CXRo3 (ORCPT ); Thu, 24 Mar 2011 13:44:29 -0400 X-Greylist: delayed 360 seconds by postgrey-1.27 at vger.kernel.org; Thu, 24 Mar 2011 13:44:29 EDT Received: from [2001:638:602:1183:5eff:35ff:fe08:e241] (helo=polaris.local) by sirius.lasnet.de with esmtpsa (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69 #1) id 1Q2oaA-00048J-0W by authid with cram_md5; Thu, 24 Mar 2011 18:44:28 +0100 Received: from jluebbe by polaris.local with local (Exim 4.74) (envelope-from ) id 1Q2oa8-0003Ra-Rn; Thu, 24 Mar 2011 18:44:24 +0100 From: Jan Luebbe To: netdev@vger.kernel.org Cc: Jan Luebbe Date: Thu, 24 Mar 2011 18:44:22 +0100 Message-Id: <1300988662-13204-1-git-send-email-jluebbe@debian.org> X-Mailer: git-send-email 1.7.4.1 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on sirius.lasnet.de X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00,NO_RELAYS autolearn=ham version=3.2.5 Subject: [PATCH] Fix IP timestamp option (IPOPT_TS_PRESPEC) handling in ip_options_echo() Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- net/ipv4/ip_options.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c index 1906fa3..28a736f 100644 --- a/net/ipv4/ip_options.c +++ b/net/ipv4/ip_options.c @@ -140,11 +140,11 @@ int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb) } else { dopt->ts_needtime = 0; - if (soffset + 8 <= optlen) { + if (soffset + 7 <= optlen) { __be32 addr; - memcpy(&addr, sptr+soffset-1, 4); - if (inet_addr_type(dev_net(skb_dst(skb)->dev), addr) != RTN_LOCAL) { + memcpy(&addr, dptr+soffset-1, 4); + if (inet_addr_type(dev_net(skb_dst(skb)->dev), addr) != RTN_UNICAST) { dopt->ts_needtime = 1; soffset += 8; }