Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp248562pxj; Tue, 18 May 2021 02:24:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeWsovF5XOh92B4hnHdpyLAX7y34cGrPSF2z8MYGrZh6AZS4qJkttCWVMVwtirH+618w7D X-Received: by 2002:a02:5d44:: with SMTP id w65mr4466774jaa.15.1621329885449; Tue, 18 May 2021 02:24:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621329885; cv=none; d=google.com; s=arc-20160816; b=MLk3gvDP2X2ssAw0WLJX+pnGiW8J+nSURBYJOsl3Hnva/hgLk1Y9CQUcJPhUUyhkJ3 Hw9nR8R0ityEVDCPoo/RwMbs5+UjwU8YmDGmcjIkonI8PoppWiIg3aB6nt+3U7xPrfpx dM4KE2klQMRlA1PMdMgOGv3OiggWjK3WsU4AUX68rK4sSYj4UzLE0/SUiDUN+w7u/AOt h25eaxqDWoMMBrz7gsUn4dSQEBEt7oxZG9qpTCnLmpPr/HFq6SSnWMipQg4t3S9vU/KR XQbPJww61FjuHmiruMPH4vxquuJ/vLLVptfoQkd/4zm0vFVRoArVJsfbD+sQT8UekIzP Alxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WD6ywNvSPwVNFg4o8EVGl7CWrKchPi3LKh+SJHLpF2Q=; b=h9NjEEkFtOqsDfKIijzZcDLvsPfShgT0FYlRZrhkiUOOXmPa5uflYr2y1Mmv2bIYU/ 0JkICEyJwOAGKJQt2lGRfavMkAPP90hOjJuHgIpJklw7D7xhw3V5evJpfSPnIQ++UPuj fc+T3PukH8IoGre/5dszX7xxm/X/rxLIwBoFQ/zEpUqJS38uO7Y+wKKPG+4WvcerV1E/ iuJ60Y9CjPY025TOR5hVea17NdkNcV+LNNDr+TR0PJZ7zLasNM7Sz1htu4S+ZS5/7n8G g89WWd2Z4lpFl66IdwJa4ZLvfrWYu2xq/J/Tb5J+aTGNx5id2lL/EfFsbYtyeNG1Zfhz K3DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IqHwGXhU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b5si7763444jav.78.2021.05.18.02.24.32; Tue, 18 May 2021 02:24:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IqHwGXhU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241810AbhEQPFn (ORCPT + 99 others); Mon, 17 May 2021 11:05:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:48862 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241466AbhEQO4d (ORCPT ); Mon, 17 May 2021 10:56:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C0A20619A1; Mon, 17 May 2021 14:25:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261521; bh=wgvQslNOr1F/8lLug8UhFOeUi0yjiLj3rjoFMoLJVtg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IqHwGXhUftkNrg1iMrYG2Yhk9rbJ7dr9vqTbx9B1uTu08gXaloK+5lO87sRfQUWzD l9Cuqs6LlYY9/KwGsdn7TxNT9tceP3AMRSqWbrPyn1cZ1sFGNAUrNfddgzmxsGOkJ4 LzAriG+44I8F2RP2CapEWN905sV5ewVPP5J3OyuM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 029/289] net/sched: cls_flower: use ntohs for struct flow_dissector_key_ports Date: Mon, 17 May 2021 15:59:14 +0200 Message-Id: <20210517140306.168184953@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladimir Oltean [ Upstream commit 6215afcb9a7e35cef334dc0ae7f998cc72c8465f ] A make W=1 build complains that: net/sched/cls_flower.c:214:20: warning: cast from restricted __be16 net/sched/cls_flower.c:214:20: warning: incorrect type in argument 1 (different base types) net/sched/cls_flower.c:214:20: expected unsigned short [usertype] val net/sched/cls_flower.c:214:20: got restricted __be16 [usertype] dst This is because we use htons on struct flow_dissector_key_ports members src and dst, which are defined as __be16, so they are already in network byte order, not host. The byte swap function for the other direction should have been used. Because htons and ntohs do the same thing (either both swap, or none does), this change has no functional effect except to silence the warnings. Signed-off-by: Vladimir Oltean Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/sched/cls_flower.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index 14316ba9b3b3..a5212a3f86e2 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -209,16 +209,16 @@ static bool fl_range_port_dst_cmp(struct cls_fl_filter *filter, struct fl_flow_key *key, struct fl_flow_key *mkey) { - __be16 min_mask, max_mask, min_val, max_val; + u16 min_mask, max_mask, min_val, max_val; - min_mask = htons(filter->mask->key.tp_range.tp_min.dst); - max_mask = htons(filter->mask->key.tp_range.tp_max.dst); - min_val = htons(filter->key.tp_range.tp_min.dst); - max_val = htons(filter->key.tp_range.tp_max.dst); + min_mask = ntohs(filter->mask->key.tp_range.tp_min.dst); + max_mask = ntohs(filter->mask->key.tp_range.tp_max.dst); + min_val = ntohs(filter->key.tp_range.tp_min.dst); + max_val = ntohs(filter->key.tp_range.tp_max.dst); if (min_mask && max_mask) { - if (htons(key->tp_range.tp.dst) < min_val || - htons(key->tp_range.tp.dst) > max_val) + if (ntohs(key->tp_range.tp.dst) < min_val || + ntohs(key->tp_range.tp.dst) > max_val) return false; /* skb does not have min and max values */ @@ -232,16 +232,16 @@ static bool fl_range_port_src_cmp(struct cls_fl_filter *filter, struct fl_flow_key *key, struct fl_flow_key *mkey) { - __be16 min_mask, max_mask, min_val, max_val; + u16 min_mask, max_mask, min_val, max_val; - min_mask = htons(filter->mask->key.tp_range.tp_min.src); - max_mask = htons(filter->mask->key.tp_range.tp_max.src); - min_val = htons(filter->key.tp_range.tp_min.src); - max_val = htons(filter->key.tp_range.tp_max.src); + min_mask = ntohs(filter->mask->key.tp_range.tp_min.src); + max_mask = ntohs(filter->mask->key.tp_range.tp_max.src); + min_val = ntohs(filter->key.tp_range.tp_min.src); + max_val = ntohs(filter->key.tp_range.tp_max.src); if (min_mask && max_mask) { - if (htons(key->tp_range.tp.src) < min_val || - htons(key->tp_range.tp.src) > max_val) + if (ntohs(key->tp_range.tp.src) < min_val || + ntohs(key->tp_range.tp.src) > max_val) return false; /* skb does not have min and max values */ @@ -779,16 +779,16 @@ static int fl_set_key_port_range(struct nlattr **tb, struct fl_flow_key *key, TCA_FLOWER_UNSPEC, sizeof(key->tp_range.tp_max.src)); if (mask->tp_range.tp_min.dst && mask->tp_range.tp_max.dst && - htons(key->tp_range.tp_max.dst) <= - htons(key->tp_range.tp_min.dst)) { + ntohs(key->tp_range.tp_max.dst) <= + ntohs(key->tp_range.tp_min.dst)) { NL_SET_ERR_MSG_ATTR(extack, tb[TCA_FLOWER_KEY_PORT_DST_MIN], "Invalid destination port range (min must be strictly smaller than max)"); return -EINVAL; } if (mask->tp_range.tp_min.src && mask->tp_range.tp_max.src && - htons(key->tp_range.tp_max.src) <= - htons(key->tp_range.tp_min.src)) { + ntohs(key->tp_range.tp_max.src) <= + ntohs(key->tp_range.tp_min.src)) { NL_SET_ERR_MSG_ATTR(extack, tb[TCA_FLOWER_KEY_PORT_SRC_MIN], "Invalid source port range (min must be strictly smaller than max)"); -- 2.30.2