From patchwork Fri Oct 18 09:00:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Bursztyka X-Patchwork-Id: 284464 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 1101F2C00B8 for ; Fri, 18 Oct 2013 20:01:05 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751801Ab3JRJBC (ORCPT ); Fri, 18 Oct 2013 05:01:02 -0400 Received: from mga14.intel.com ([143.182.124.37]:19393 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751765Ab3JRJBB (ORCPT ); Fri, 18 Oct 2013 05:01:01 -0400 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 18 Oct 2013 02:01:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.93,521,1378882800"; d="scan'208";a="376541046" Received: from rd-180.fi.intel.com ([10.237.68.32]) by azsmga001.ch.intel.com with ESMTP; 18 Oct 2013 02:00:55 -0700 From: Tomasz Bursztyka To: netfilter-devel@vger.kernel.org Cc: Tomasz Bursztyka Subject: [nftables-kernel PATCH] netfilter: nftables: Fix sparse endianness issue on nft_nat.c Date: Fri, 18 Oct 2013 12:00:53 +0300 Message-Id: <1382086853-14251-1-git-send-email-tomasz.bursztyka@linux.intel.com> X-Mailer: git-send-email 1.8.3.2 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org Fixes this: CHECK net/netfilter/nft_nat.c net/netfilter/nft_nat.c:50:43: warning: incorrect type in assignment (different base types) net/netfilter/nft_nat.c:50:43: expected restricted __be32 [addressable] [usertype] ip net/netfilter/nft_nat.c:50:43: got unsigned int [unsigned] [usertype] net/netfilter/nft_nat.c:51:43: warning: incorrect type in assignment (different base types) net/netfilter/nft_nat.c:51:43: expected restricted __be32 [addressable] [usertype] ip net/netfilter/nft_nat.c:51:43: got unsigned int [unsigned] [usertype] net/netfilter/nft_nat.c:65:37: warning: incorrect type in assignment (different base types) net/netfilter/nft_nat.c:65:37: expected restricted __be16 [addressable] [assigned] [usertype] all net/netfilter/nft_nat.c:65:37: got unsigned int [unsigned] net/netfilter/nft_nat.c:66:37: warning: incorrect type in assignment (different base types) net/netfilter/nft_nat.c:66:37: expected restricted __be16 [addressable] [assigned] [usertype] all net/netfilter/nft_nat.c:66:37: got unsigned int [unsigned] Signed-off-by: Tomasz Bursztyka --- Hi, looks a bit ugly, would there be another way to fix this? Tomasz net/netfilter/nft_nat.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/net/netfilter/nft_nat.c b/net/netfilter/nft_nat.c index b0b87b2..f9d488f 100644 --- a/net/netfilter/nft_nat.c +++ b/net/netfilter/nft_nat.c @@ -47,8 +47,12 @@ static void nft_nat_eval(const struct nft_expr *expr, memset(&range, 0, sizeof(range)); if (priv->sreg_addr_min) { if (priv->family == AF_INET) { - range.min_addr.ip = data[priv->sreg_addr_min].data[0]; - range.max_addr.ip = data[priv->sreg_addr_max].data[0]; + range.min_addr.ip = + be32_to_cpup((__be32 *) + data[priv->sreg_addr_min].data); + range.max_addr.ip = + be32_to_cpup((__be32 *) + data[priv->sreg_addr_max].data); } else { memcpy(range.min_addr.ip6, @@ -62,8 +66,12 @@ static void nft_nat_eval(const struct nft_expr *expr, } if (priv->sreg_proto_min) { - range.min_proto.all = data[priv->sreg_proto_min].data[0]; - range.max_proto.all = data[priv->sreg_proto_max].data[0]; + range.min_proto.all = + be16_to_cpup((__be16 *) + data[priv->sreg_proto_min].data); + range.max_proto.all = + be16_to_cpup((__be16 *) + data[priv->sreg_proto_max].data); range.flags |= NF_NAT_RANGE_PROTO_SPECIFIED; }