From patchwork Sat Jan 18 02:16:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "fan.du" X-Patchwork-Id: 312245 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 6F7062C0098 for ; Sat, 18 Jan 2014 13:16:31 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752885AbaARCQ1 (ORCPT ); Fri, 17 Jan 2014 21:16:27 -0500 Received: from mail1.windriver.com ([147.11.146.13]:33902 "EHLO mail1.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752066AbaARCQY (ORCPT ); Fri, 17 Jan 2014 21:16:24 -0500 Received: from ALA-HCB.corp.ad.wrs.com (ala-hcb.corp.ad.wrs.com [147.11.189.41]) by mail1.windriver.com (8.14.5/8.14.5) with ESMTP id s0I2GHoA028999 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Fri, 17 Jan 2014 18:16:17 -0800 (PST) Received: from iamroot-OptiPlex-780.corp.ad.wrs.com (128.224.162.236) by ALA-HCB.corp.ad.wrs.com (147.11.189.41) with Microsoft SMTP Server id 14.2.347.0; Fri, 17 Jan 2014 18:16:16 -0800 From: Fan Du To: CC: , , , Subject: [PATCH net-next] ipcomp: Convert struct xt_ipcomp spis into 16bits Date: Sat, 18 Jan 2014 10:16:14 +0800 Message-ID: <1390011374-21760-1-git-send-email-fan.du@windriver.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org sparse warnings: (new ones prefixed by >>) >> >> net/netfilter/xt_ipcomp.c:63:26: sparse: restricted __be16 degrades to integer >> >> net/netfilter/xt_ipcomp.c:63:26: sparse: cast to restricted __be32 Fix this by using 16bits long spi, as IPcomp CPI is only valid for 16bits. Signed-off-by: Fan Du --- include/uapi/linux/netfilter/xt_ipcomp.h | 2 +- net/netfilter/xt_ipcomp.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/uapi/linux/netfilter/xt_ipcomp.h b/include/uapi/linux/netfilter/xt_ipcomp.h index 45c7e40..ca82ebb 100644 --- a/include/uapi/linux/netfilter/xt_ipcomp.h +++ b/include/uapi/linux/netfilter/xt_ipcomp.h @@ -4,7 +4,7 @@ #include struct xt_ipcomp { - __u32 spis[2]; /* Security Parameter Index */ + __u16 spis[2]; /* Security Parameter Index */ __u8 invflags; /* Inverse flags */ __u8 hdrres; /* Test of the Reserved Filed */ }; diff --git a/net/netfilter/xt_ipcomp.c b/net/netfilter/xt_ipcomp.c index a4c7561..5542cb2 100644 --- a/net/netfilter/xt_ipcomp.c +++ b/net/netfilter/xt_ipcomp.c @@ -29,7 +29,7 @@ MODULE_DESCRIPTION("Xtables: IPv4/6 IPsec-IPComp SPI match"); /* Returns 1 if the spi is matched by the range, 0 otherwise */ static inline bool -spi_match(u_int32_t min, u_int32_t max, u_int32_t spi, bool invert) +spi_match(u_int16_t min, u_int16_t max, u_int16_t spi, bool invert) { bool r; pr_debug("spi_match:%c 0x%x <= 0x%x <= 0x%x\n", @@ -60,7 +60,7 @@ static bool comp_mt(const struct sk_buff *skb, struct xt_action_param *par) } return spi_match(compinfo->spis[0], compinfo->spis[1], - ntohl(chdr->cpi << 16), + ntohl(chdr->cpi), !!(compinfo->invflags & XT_IPCOMP_INV_SPI)); }