From patchwork Tue Jan 26 02:31:10 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shan Wei X-Patchwork-Id: 43674 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 A9D8B1007D1 for ; Tue, 26 Jan 2010 13:32:39 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753087Ab0AZCcc (ORCPT ); Mon, 25 Jan 2010 21:32:32 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753275Ab0AZCcb (ORCPT ); Mon, 25 Jan 2010 21:32:31 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:50328 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1753087Ab0AZCc2 (ORCPT ); Mon, 25 Jan 2010 21:32:28 -0500 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 4136317013A; Tue, 26 Jan 2010 10:32:27 +0800 (CST) Received: from fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id o0Q2Vrqm027975; Tue, 26 Jan 2010 10:31:53 +0800 Received: from [10.167.141.214] (unknown [10.167.141.214]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id 86C13D4744; Tue, 26 Jan 2010 10:33:39 +0800 (CST) Message-ID: <4B5E53EE.9010703@cn.fujitsu.com> Date: Tue, 26 Jan 2010 10:31:10 +0800 From: Shan Wei User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: Patrick McHardy , David Miller , Yasuyuki KOZAKAI CC: netfilter-devel@vger.kernel.org, "netdev@vger.kernel.org" Subject: [PATCH 1/2] IPv6: conntrack: Use protocol-related initialization routine to initial queues of IPv6 connection track Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org IPv6 connection track and IPv6 stack separately use a different queue to manage received fragments. The former uses nf_ct_frag6_queue structure, the latter uses frag_queue structure. When creating new queue for IPv6 connection track, ip6_frag_init() that belongs to IPv6 stack is called to initial nf_ct_frag6_queue structure. This broken the saddr&daddr member in nf_ct_frag6_queue, and then hash value generated by nf_hashfn() is not equal with that generated by fq_find(). So, a new received fragment can't be inserted to right queue. The patch fixes the bug with protocol-related initialization routine. The patch-set have been tested. Signed-off-by: Shan Wei --- include/net/ipv6.h | 1 - net/ipv6/netfilter/nf_conntrack_reasm.c | 13 ++++++++++++- net/ipv6/reassembly.c | 3 +-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/net/ipv6.h b/include/net/ipv6.h index cbd768b..a7112da 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -364,7 +364,6 @@ struct ip6_create_arg { struct in6_addr *dst; }; -void ip6_frag_init(struct inet_frag_queue *q, void *a); static inline int ipv6_addr_any(const struct in6_addr *a) { diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c index 66b6161..4a61d14 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c @@ -146,6 +146,17 @@ static void nf_ct_frag6_evictor(void) local_bh_enable(); } +static void nf_ct_queue_init(struct inet_frag_queue *q, void *a) +{ + struct nf_ct_frag6_queue *fq; + struct ip6_create_arg *arg = a; + + fq = container_of(q, struct nf_ct_frag6_queue, q); + fq->id = arg->id; + ipv6_addr_copy(&fq->saddr, arg->src); + ipv6_addr_copy(&fq->daddr, arg->dst); +} + static int nf_ct_frag_match(struct inet_frag_queue *q, void *a) { struct nf_ct_frag6_queue *fq; @@ -672,7 +683,7 @@ void nf_ct_frag6_output(unsigned int hooknum, struct sk_buff *skb, int nf_ct_frag6_init(void) { nf_frags.hashfn = nf_hashfn; - nf_frags.constructor = ip6_frag_init; + nf_frags.constructor = nf_ct_frag_init; nf_frags.destructor = NULL; nf_frags.skb_free = nf_skb_free; nf_frags.qsize = sizeof(struct nf_ct_frag6_queue); diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index 2fa4355..9f9b6a2 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c @@ -157,7 +157,7 @@ static inline void frag_kfree_skb(struct netns_frags *nf, kfree_skb(skb); } -void ip6_frag_init(struct inet_frag_queue *q, void *a) +static void ip6_frag_init(struct inet_frag_queue *q, void *a) { struct frag_queue *fq = container_of(q, struct frag_queue, q); struct ip6_create_arg *arg = a; @@ -167,7 +167,6 @@ void ip6_frag_init(struct inet_frag_queue *q, void *a) ipv6_addr_copy(&fq->saddr, arg->src); ipv6_addr_copy(&fq->daddr, arg->dst); } -EXPORT_SYMBOL(ip6_frag_init); /* Destruction primitives. */