From patchwork Mon Jan 20 01:55:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "fan.du" X-Patchwork-Id: 312430 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 BFDA12C009F for ; Mon, 20 Jan 2014 12:56:17 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752411AbaATBzs (ORCPT ); Sun, 19 Jan 2014 20:55:48 -0500 Received: from mail1.windriver.com ([147.11.146.13]:45984 "EHLO mail1.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752264AbaATBzq (ORCPT ); Sun, 19 Jan 2014 20:55:46 -0500 Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail1.windriver.com (8.14.5/8.14.5) with ESMTP id s0K1tbrj021847 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Sun, 19 Jan 2014 17:55:37 -0800 (PST) Received: from [128.224.162.161] (128.224.162.161) by ALA-HCA.corp.ad.wrs.com (147.11.189.50) with Microsoft SMTP Server (TLS) id 14.2.347.0; Sun, 19 Jan 2014 17:55:36 -0800 Message-ID: <52DC821E.3000309@windriver.com> Date: Mon, 20 Jan 2014 09:55:42 +0800 From: Fan Du User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 MIME-Version: 1.0 To: Pablo Neira Ayuso CC: , , netdev , Subject: Re: [PATCH net-next] ipcomp: Convert struct xt_ipcomp spis into 16bits References: <1390011374-21760-1-git-send-email-fan.du@windriver.com> <20140118122437.GA4309@localhost> In-Reply-To: <20140118122437.GA4309@localhost> X-Originating-IP: [128.224.162.161] Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 2014年01月18日 20:24, Pablo Neira Ayuso wrote: > On Sat, Jan 18, 2014 at 10:16:14AM +0800, Fan Du wrote: >> > 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 */ > This changes the binary interface so it break userspace (iptables > needs to be recompiled), we're still in time to make such change as > this is net-next stuff, but what I understand from the patch > description is that this aims to fix a sparse warning, which is a bit > of intrusive change. > > Didn't you find any way to fix this without change the layout of > xt_ipcomp? > My bad for not catching this in the initial ipcomp version. It would be easier to just use ntohs here to ease sparse checking. From dbf796e63d600256fd40000669b83227ddccebc4 Mon Sep 17 00:00:00 2001 From: Fan Du Date: Mon, 20 Jan 2014 09:42:12 +0800 Subject: [PATCHv2 net-next] ipcomp: Use ntohs to ease sparse warning 0-DAY kernel build testing backend reported: 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 ntohs without shifting. Tested with: make C=1 CF=-D__CHECK_ENDIAN__ Signed-off-by: Fan Du --- net/netfilter/xt_ipcomp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netfilter/xt_ipcomp.c b/net/netfilter/xt_ipcomp.c index a4c7561..89d5310 100644 --- a/net/netfilter/xt_ipcomp.c +++ b/net/netfilter/xt_ipcomp.c @@ -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), + ntohs(chdr->cpi), !!(compinfo->invflags & XT_IPCOMP_INV_SPI)); }