From patchwork Tue Jul 24 10:42:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 172821 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 BD28D2C0079 for ; Tue, 24 Jul 2012 20:42:46 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753044Ab2GXKml (ORCPT ); Tue, 24 Jul 2012 06:42:41 -0400 Received: from mail-bk0-f46.google.com ([209.85.214.46]:33033 "EHLO mail-bk0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752989Ab2GXKmk (ORCPT ); Tue, 24 Jul 2012 06:42:40 -0400 Received: by bkwj10 with SMTP id j10so6159193bkw.19 for ; Tue, 24 Jul 2012 03:42:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:from:to:cc:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; bh=4UM2ieC+bhBWo0Cw/0t/blMKl6Mnh3hvKVec9PrULgc=; b=NWpxNc+6rAB1GKyEuFhGcqBgF87Rx7wmKcn+iLzYZT0uN71n5mWAvUCa9/mJKtdrSK VRXiFKBBu7/ZsQSr2QwavXau3CHgENmV65GGSkOgzD2EB6kavK88Ox9o2B1bgptkwu80 EdWClBTFo0QcA9j452yyDUeweXN0dwi5uDuWksHTHmBerR4zEfiFTE9EccQphF4qfm/r iotPQYZusj3cl0fvyfOUzwF5m7caNy3q3hLzW74DTH951k26UxIi9t9GHnnHRqkMhoVp ctzzHjqNBouNRBWMo2BOKRD5cjyoZgGHqGAcsCmMVlNZZrLri+Y4/zfUTyzNxrkU1Yos N3Gg== Received: by 10.205.125.4 with SMTP id gq4mr9628525bkc.109.1343126559179; Tue, 24 Jul 2012 03:42:39 -0700 (PDT) Received: from [172.30.42.18] (171.237.66.86.rev.sfr.net. [86.66.237.171]) by mx.google.com with ESMTPS id fu8sm10247955bkc.5.2012.07.24.03.42.37 (version=SSLv3 cipher=OTHER); Tue, 24 Jul 2012 03:42:38 -0700 (PDT) Subject: [PATCH net-next] tcp: tcp_v4_early_demux() fixes From: Eric Dumazet To: David Miller Cc: netdev Date: Tue, 24 Jul 2012 12:42:35 +0200 Message-ID: <1343126555.2626.11053.camel@edumazet-glaptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Eric Dumazet 1) Remove a non needed pskb_may_pull() and fix a potential bug if skb->head was reallocated (iph & th pointers were not reloaded) TCP stack will pull/check headers anyway. 2) skb->dev->ifindex can be now replaced by skb->skb_iif Signed-off-by: Eric Dumazet --- net/ipv4/tcp_ipv4.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 3e30548..b6b07c9 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1686,7 +1686,6 @@ void tcp_v4_early_demux(struct sk_buff *skb) struct net *net = dev_net(skb->dev); const struct iphdr *iph; const struct tcphdr *th; - struct net_device *dev; struct sock *sk; if (skb->pkt_type != PACKET_HOST) @@ -1701,14 +1700,10 @@ void tcp_v4_early_demux(struct sk_buff *skb) if (th->doff < sizeof(struct tcphdr) / 4) return; - if (!pskb_may_pull(skb, ip_hdrlen(skb) + th->doff * 4)) - return; - - dev = skb->dev; sk = __inet_lookup_established(net, &tcp_hashinfo, iph->saddr, th->source, iph->daddr, ntohs(th->dest), - dev->ifindex); + skb->skb_iif); if (sk) { skb->sk = sk; skb->destructor = sock_edemux; @@ -1718,7 +1713,7 @@ void tcp_v4_early_demux(struct sk_buff *skb) if (dst) dst = dst_check(dst, 0); if (dst && - icsk->rx_dst_ifindex == dev->ifindex) + icsk->rx_dst_ifindex == skb->skb_iif) skb_dst_set_noref(skb, dst); } }