From patchwork Sat Jan 26 18:36:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?WU9TSElGVUpJIEhpZGVha2kgLyDlkInol6Toi7HmmI4=?= X-Patchwork-Id: 215921 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 5BF9F2C0082 for ; Sun, 27 Jan 2013 05:36:41 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753241Ab3AZSgg (ORCPT ); Sat, 26 Jan 2013 13:36:36 -0500 Received: from 94.43.138.210.xn.2iij.net ([210.138.43.94]:57769 "EHLO mail.st-paulia.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752343Ab3AZSgg (ORCPT ); Sat, 26 Jan 2013 13:36:36 -0500 Received: from [192.168.2.183] (unknown [192.168.2.183]) by mail.st-paulia.net (Postfix) with ESMTPSA id BABF61BDBF; Sun, 27 Jan 2013 03:36:34 +0900 (JST) Message-ID: <51042232.5020805@linux-ipv6.org> Date: Sun, 27 Jan 2013 03:36:34 +0900 From: YOSHIFUJI Hideaki Organization: USAGI Project User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: netfilter-devel@vger.kernel.org CC: jm@dilly.me, fw@strlen.de, yoshfuji@linux-ipv6.org Subject: [RFC PATCH 2/4] netfilter: ip6t_NPT: Use csum_partial(). Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org Signed-off-by: YOSHIFUJI Hideaki --- net/ipv6/netfilter/ip6t_NPT.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/net/ipv6/netfilter/ip6t_NPT.c b/net/ipv6/netfilter/ip6t_NPT.c index 3ff281b..b1bf3ed 100644 --- a/net/ipv6/netfilter/ip6t_NPT.c +++ b/net/ipv6/netfilter/ip6t_NPT.c @@ -17,18 +17,13 @@ static int ip6t_npt_checkentry(const struct xt_tgchk_param *par) { struct ip6t_npt_tginfo *npt = par->targinfo; - __wsum src_sum = 0, dst_sum = 0; - unsigned int i; + __wsum src_sum, dst_sum; if (npt->src_pfx_len > 64 || npt->dst_pfx_len > 64) return -EINVAL; - for (i = 0; i < ARRAY_SIZE(npt->src_pfx.in6.s6_addr16); i++) { - src_sum = csum_add(src_sum, - (__force __wsum)npt->src_pfx.in6.s6_addr16[i]); - dst_sum = csum_add(dst_sum, - (__force __wsum)npt->dst_pfx.in6.s6_addr16[i]); - } + src_sum = csum_partial(&npt->src_pfx.in6, sizeof(npt->src_pfx.in6), 0); + dst_sum = csum_partial(&npt->dst_pfx.in6, sizeof(npt->dst_pfx.in6), 0); npt->adjustment = csum_fold(csum_sub(src_sum, dst_sum)); return 0;