From patchwork Thu Jul 1 03:58:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changli Gao X-Patchwork-Id: 57467 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 67214B6EEB for ; Thu, 1 Jul 2010 13:59:54 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753352Ab0GAD7s (ORCPT ); Wed, 30 Jun 2010 23:59:48 -0400 Received: from mail-px0-f174.google.com ([209.85.212.174]:52585 "EHLO mail-px0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753192Ab0GAD7r (ORCPT ); Wed, 30 Jun 2010 23:59:47 -0400 Received: by pxi14 with SMTP id 14so174157pxi.19 for ; Wed, 30 Jun 2010 20:59:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=K9CTTK0J1bLyXJg5zvlEo/sH0RhrNM3zzq5SfhmAOS0=; b=qTHXy7NBxVlHRm/up9HzSrI3ck+xIH82g/gBNtyZQmR5NhlELp6VzEI6agdySN9/B0 ck2B5DtZGyalcTd1Opc335k98Ab55JGGivgcpXWdcW0tn2ROGY5Z7Mt07I+7X+94DQ9h ouQwnpTHkDnzM1j3mSj3siwJsB+DDbwupDJUg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=OsKfOJtWTAs2k7DJ0bRObIgySC+Bf9pjRYpwNYrES7DqAi4SJ/SuYQXaoYUEwABHcv En3nhrjvvQLKoU2Ds4mPcKvBT9Nc6t3JDxEwqVrXBd4KLkx9cIpT34dw8csTsTt7Wbf0 xJ02gucuPOzDWg4ZCxWjVWI4r84savUsBAyxM= Received: by 10.142.125.21 with SMTP id x21mr129743wfc.330.1277956785979; Wed, 30 Jun 2010 20:59:45 -0700 (PDT) Received: from localhost.localdomain ([60.29.39.134]) by mx.google.com with ESMTPS id g30sm3301356rvb.12.2010.06.30.20.59.39 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 30 Jun 2010 20:59:45 -0700 (PDT) From: Changli Gao To: Patrick McHardy Cc: "David S. Miller" , Alexey Kuznetsov , "Pekka Savola (ipv6)" , James Morris , Hideaki YOSHIFUJI , Patrick McHardy , Eric Dumazet , netfilter-devel@vger.kernel.org, netdev@vger.kernel.org, Mitchell Erblich , Changli Gao Subject: [PATCH] nf_conntrack_reasm: add fast path for in-order fragments Date: Thu, 1 Jul 2010 11:58:30 +0800 Message-Id: <1277956710-22313-1-git-send-email-xiaosuo@gmail.com> X-Mailer: git-send-email 1.7.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org nf_conntrack_reasm: add fast path for in-order fragments As the fragments are sent in order in most of OSes, such as Windows, Darwin and FreeBSD, it is likely the new fragments are at the end of the inet_frag_queue. In the fast path, we check if the skb at the end of the inet_frag_queue is the prev we expect. Signed-off-by: Changli Gao ---- net/ipv6/netfilter/nf_conntrack_reasm.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- 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/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c index 9254008..098a050 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c @@ -269,6 +269,11 @@ static int nf_ct_frag6_queue(struct nf_ct_frag6_queue *fq, struct sk_buff *skb, * in the chain of fragments so far. We must know where to put * this fragment, right? */ + prev = fq->q.fragments_tail; + if (!prev || NFCT_FRAG6_CB(prev)->offset < offset) { + next = NULL; + goto found; + } prev = NULL; for (next = fq->q.fragments; next != NULL; next = next->next) { if (NFCT_FRAG6_CB(next)->offset >= offset) @@ -276,6 +281,7 @@ static int nf_ct_frag6_queue(struct nf_ct_frag6_queue *fq, struct sk_buff *skb, prev = next; } +found: /* We found where to put this one. Check for overlap with * preceding fragment, and, if needed, align things so that * any overlaps are eliminated. @@ -341,6 +347,8 @@ static int nf_ct_frag6_queue(struct nf_ct_frag6_queue *fq, struct sk_buff *skb, /* Insert this fragment in the chain of fragments. */ skb->next = next; + if (!next) + fq->q.fragments_tail = skb; if (prev) prev->next = skb; else @@ -464,6 +472,7 @@ nf_ct_frag6_reasm(struct nf_ct_frag6_queue *fq, struct net_device *dev) head->csum); fq->q.fragments = NULL; + fq->q.fragments_tail = NULL; /* all original skbs are linked into the NFCT_FRAG6_CB(head).orig */ fp = skb_shinfo(head)->frag_list;