From patchwork Sun Dec 25 01:57:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pablo Neira Ayuso X-Patchwork-Id: 133182 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 A2438B706E for ; Sun, 25 Dec 2011 12:59:00 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758086Ab1LYB6p (ORCPT ); Sat, 24 Dec 2011 20:58:45 -0500 Received: from mail.us.es ([193.147.175.20]:56024 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758039Ab1LYB6M (ORCPT ); Sat, 24 Dec 2011 20:58:12 -0500 Received: (qmail 26273 invoked from network); 25 Dec 2011 02:58:10 +0100 Received: from unknown (HELO us.es) (192.168.2.11) by us.es with SMTP; 25 Dec 2011 02:58:10 +0100 Received: (qmail 26289 invoked by uid 507); 25 Dec 2011 01:58:09 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on antivirus1 X-Spam-Level: X-Spam-Status: No, score=-96.5 required=7.5 tests=BAYES_50,KHOP_DYNAMIC, RCVD_IN_PBL, RCVD_IN_RP_RNBL, RCVD_IN_SORBS_DUL, RDNS_DYNAMIC, USER_IN_WHITELIST autolearn=disabled version=3.3.1 Received: from 127.0.0.1 by antivirus1 (envelope-from , uid 501) with qmail-scanner-2.08 (clamdscan: 0.97.3/14187. Clear:RC:1(127.0.0.1):. Processed in 0.023265 secs); 25 Dec 2011 01:58:09 -0000 Received: from unknown (HELO antivirus1) (127.0.0.1) by us.es with SMTP; 25 Dec 2011 01:58:09 -0000 Received: from 192.168.1.13 (192.168.1.13) by antivirus1 (F-Secure/fsigk_smtp/406/antivirus1); Sun, 25 Dec 2011 02:58:09 +0100 (CET) X-Virus-Status: clean(F-Secure/fsigk_smtp/406/antivirus1) Received: (qmail 27349 invoked from network); 25 Dec 2011 02:58:09 +0100 Received: from 166.220.222.87.dynamic.jazztel.es (HELO localhost.localdomain) (pneira@us.es@87.222.220.166) by us.es with SMTP; 25 Dec 2011 02:58:09 +0100 From: pablo@netfilter.org To: netfilter-devel@vger.kernel.org Cc: davem@davemloft.net, netdev@vger.kernel.org Subject: [PATCH 14/19] netfilter: nf_nat: remove obsolete code from nf_nat_icmp_reply_translation() Date: Sun, 25 Dec 2011 02:57:30 +0100 Message-Id: <1324778255-2830-15-git-send-email-pablo@netfilter.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1324778255-2830-1-git-send-email-pablo@netfilter.org> References: <1324778255-2830-1-git-send-email-pablo@netfilter.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Patrick McHardy The inner tuple that is extracted from the packet is unused. The code also doesn't have any useful side-effects like verifying the packet does contain enough data to extract the inner tuple since conntrack already does the same, so remove it. Signed-off-by: Patrick McHardy Signed-off-by: Pablo Neira Ayuso --- net/ipv4/netfilter/nf_nat_core.c | 14 +------------- 1 files changed, 1 insertions(+), 13 deletions(-) diff --git a/net/ipv4/netfilter/nf_nat_core.c b/net/ipv4/netfilter/nf_nat_core.c index 5e1bd85..acdd002 100644 --- a/net/ipv4/netfilter/nf_nat_core.c +++ b/net/ipv4/netfilter/nf_nat_core.c @@ -30,7 +30,6 @@ #include #include #include -#include #include static DEFINE_SPINLOCK(nf_nat_lock); @@ -414,8 +413,7 @@ int nf_nat_icmp_reply_translation(struct nf_conn *ct, struct icmphdr icmp; struct iphdr ip; } *inside; - const struct nf_conntrack_l4proto *l4proto; - struct nf_conntrack_tuple inner, target; + struct nf_conntrack_tuple target; int hdrlen = ip_hdrlen(skb); enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo); unsigned long statusbit; @@ -463,16 +461,6 @@ int nf_nat_icmp_reply_translation(struct nf_conn *ct, "dir %s\n", skb, manip, dir == IP_CT_DIR_ORIGINAL ? "ORIG" : "REPLY"); - /* rcu_read_lock()ed by nf_hook_slow */ - l4proto = __nf_ct_l4proto_find(PF_INET, inside->ip.protocol); - - if (!nf_ct_get_tuple(skb, hdrlen + sizeof(struct icmphdr), - (hdrlen + - sizeof(struct icmphdr) + inside->ip.ihl * 4), - (u_int16_t)AF_INET, inside->ip.protocol, - &inner, l3proto, l4proto)) - return 0; - /* Change inner back to look like incoming packet. We do the opposite manip on this hook to normal, because it might not pass all hooks (locally-generated ICMP). Consider incoming