From patchwork Mon Apr 8 13:09:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= X-Patchwork-Id: 13621136 X-Patchwork-Delegate: kuba@kernel.org Received: from mail1.fiberby.net (mail1.fiberby.net [193.104.135.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1451A8287E; Mon, 8 Apr 2024 13:10:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.104.135.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712581852; cv=none; b=vAmqs946y4r8VWXDVWZLPXLjZ4Wr9NrvCkgfiK8YOA2QpL8HIU67en+B2/5qF9XmaBKsHcLhbO15bR1QpFbgNj+ACyYTFOY0t7XvSilGaR5/zoOYYRFGj08hKgoFqUHQvaVdBxZyAaK+X/2aEy0cWxquOlIZiUgDfV5hCtI6mAY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712581852; c=relaxed/simple; bh=zFYXy7e8s/QlamSDHv94nVwNKIb1xplVZBX1CbE7gOE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GoJ1cb94IZxwd0fae24zs2CPkj7E9Wt2ZSliUxFQvV8GEPyrjhgQ6kvasx6BxDyp3G4YuGRljh6hpjCQSp96hwwk51fvjFa4yAIWgDk82SkYxHELGt2mJ5ExxMOiL027aTBYoYQ12yeDRzXrmE1wbk7ssaGDLsiA8J3FDAzaOZk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net; spf=pass smtp.mailfrom=fiberby.net; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b=XKiMNFGu; arc=none smtp.client-ip=193.104.135.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fiberby.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="XKiMNFGu" Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id 0D759600E4; Mon, 8 Apr 2024 13:10:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1712581839; bh=zFYXy7e8s/QlamSDHv94nVwNKIb1xplVZBX1CbE7gOE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XKiMNFGueMuNqCMKTV63pCJxCZxxleMEpb1sOBtrfvbu3RkHkd98yAcSXevzhlBE6 IwtgYvpdrl6EApvlHatUy6iE5IM61P3ezoctXTNGDpIBwTtUqP+/N/sW2iz4onZU1y ROVOrBqugZHnGdcjK3WsLQRZz+KOOv5qm9Bw/6zBQq4CUcfquMC50ExcoUqWvN3FVk ikbMqEwrBzr0z0UhtQytv5Nku9hJmcf4QJQnomL3Ua3arT36iR28JcHL8UdYsnk93j ths7grC8D8oS2ewQ9Z6aMN57c9RSt4zP60fGT6gyNOnXGbszENd21WPz6R/UMyZJ+L /S3nftHH4Hq4A== Received: by x201s (Postfix, from userid 1000) id 38AFC202005; Mon, 08 Apr 2024 13:09:38 +0000 (UTC) From: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Louis Peens , Taras Chornyi , Woojung Huh , UNGLinuxDriver@microchip.com Cc: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yanguo Li , oss-drivers@corigine.com, Andrew Lunn , Florian Fainelli , Vladimir Oltean , Edward Cree , Jamal Hadi Salim , Cong Wang , Jiri Pirko Subject: [PATCH net-next 1/6] flow_offload: add flow_rule_no_unsupp_control_flags() Date: Mon, 8 Apr 2024 13:09:19 +0000 Message-ID: <20240408130927.78594-2-ast@fiberby.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240408130927.78594-1-ast@fiberby.net> References: <20240408130927.78594-1-ast@fiberby.net> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org This helper can be used by drivers to check for the presence of unsupported control flags. It mirrors the existing check done in sfc: drivers/net/ethernet/sfc/tc.c +276 This is aimed at drivers, which implements some control flags. This should also be used by drivers that implement all current flags, so that future flags will be unsupported by default. Only compile-tested. Signed-off-by: Asbjørn Sloth Tønnesen --- include/net/flow_offload.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h index 314087a5e1818..c1317b14da08c 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -449,6 +449,28 @@ static inline bool flow_rule_match_key(const struct flow_rule *rule, return dissector_uses_key(rule->match.dissector, key); } +/** + * flow_rule_no_unsupp_control_flags() - check for unsupported control flags + * @supp_flags: flags supported by driver + * @flags: flags present in rule + * @extack: The netlink extended ACK for reporting errors. + * + * Returns true if only supported control flags are set, false otherwise. + */ +static inline bool flow_rule_no_unsupp_control_flags(const u32 supp_flags, + const u32 flags, + struct netlink_ext_ack *extack) +{ + if (likely((flags & ~supp_flags) == 0)) + return true; + + NL_SET_ERR_MSG_FMT_MOD(extack, + "Unsupported match on control.flags %#x", + flags); + + return false; +} + struct flow_stats { u64 pkts; u64 bytes; From patchwork Mon Apr 8 13:09:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= X-Patchwork-Id: 13621135 X-Patchwork-Delegate: kuba@kernel.org Received: from mail1.fiberby.net (mail1.fiberby.net [193.104.135.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1455C8287F; Mon, 8 Apr 2024 13:10:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.104.135.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712581851; cv=none; b=MtooxkWxZE9nMYd60FtkVa/X7asiazVFhJiXtdUxnbdrIRRKfWEfjI99KAwx3eHXG1WNaB5DVU173vgU09/KaBbK2NEmUsldzpcTARa41qnWPYjviHqnoVDz5TQjTtvTbXJOhYFv74HDJuWtylk9CckvTKhcsN+KHKDT+0p0SKU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712581851; c=relaxed/simple; bh=JhvINSSfLvE52ybLOuVuFxGqHxUcIIr9GHOMoeqR5HE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NLKF/atzBxakNeTAd2YCihYAprBEWt2/nLg91CJ0Kn1r2eD2UUoXvG4knhfs6Ya37sr10xbfTgXNSB6OImHtH3lIqT6YIhNd08If1lKTR6r84k+OdELMZsc5Uh4QoICWXlDWPPaGUUuB+9dcCoXTh8qhENcEQ1j7FNs8YYzC5+o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net; spf=pass smtp.mailfrom=fiberby.net; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b=qteOSczA; arc=none smtp.client-ip=193.104.135.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fiberby.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="qteOSczA" Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id 0D636600DC; Mon, 8 Apr 2024 13:10:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1712581839; bh=JhvINSSfLvE52ybLOuVuFxGqHxUcIIr9GHOMoeqR5HE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qteOSczAIRp0V/v8WSLj6CEOq5SgEreq1kGNOFJntvW4CKBugjgEoTbmq1BX41Nn/ Xaf96Zb6YaMmb/tyGAnXmaLp7SBnoBic75LpSqLSpvD7LQIww0ckQYLE3m6r3pbuaa fJPgSORUvEosFWgNJNE2mJIKC1Fif20T36t/L5HMdV8bB7UUZONLPpzsY2IcYiUkap ZIANjIueZ4utUx4ZpAya0WsTxnF9mfl7blxTnGOqOSaiesr3e6I7Jxixii2T8Tq0/x hhgc4S1KyhVje2+1ZAWrIY9kYw4CmcwoEQmkitMgY5Kcvt30YJKM27rANXsFcRruFO jIlJ7FFto5x5A== Received: by x201s (Postfix, from userid 1000) id 33287204CF2; Mon, 08 Apr 2024 13:09:39 +0000 (UTC) From: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Louis Peens , Taras Chornyi , Woojung Huh , UNGLinuxDriver@microchip.com Cc: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yanguo Li , oss-drivers@corigine.com, Andrew Lunn , Florian Fainelli , Vladimir Oltean , Edward Cree , Jamal Hadi Salim , Cong Wang , Jiri Pirko Subject: [PATCH net-next 2/6] nfp: flower: fix check for unsupported control flags Date: Mon, 8 Apr 2024 13:09:20 +0000 Message-ID: <20240408130927.78594-3-ast@fiberby.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240408130927.78594-1-ast@fiberby.net> References: <20240408130927.78594-1-ast@fiberby.net> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Use flow_rule_no_unsupp_control_flags() Check the mask, not the key, for unsupported control flags. Only compile-tested, no access to HW Signed-off-by: Asbjørn Sloth Tønnesen --- drivers/net/ethernet/netronome/nfp/flower/offload.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c index 0aceef9fe5826..bc7d7c7e68efb 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/offload.c +++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c @@ -527,10 +527,10 @@ nfp_flower_calculate_key_layers(struct nfp_app *app, struct flow_match_control ctl; flow_rule_match_control(rule, &ctl); - if (ctl.key->flags & ~NFP_FLOWER_SUPPORTED_CTLFLAGS) { - NL_SET_ERR_MSG_MOD(extack, "unsupported offload: match on unknown control flag"); + + if (!flow_rule_no_unsupp_control_flags(NFP_FLOWER_SUPPORTED_CTLFLAGS, + ctl.mask->flags, extack)) return -EOPNOTSUPP; - } } ret_key_ls->key_layer = key_layer; From patchwork Mon Apr 8 13:09:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= X-Patchwork-Id: 13621145 X-Patchwork-Delegate: kuba@kernel.org Received: from mail1.fiberby.net (mail1.fiberby.net [193.104.135.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1135862148; Mon, 8 Apr 2024 13:20:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.104.135.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712582416; cv=none; b=BNXvUscJdEzUTPwk+dnyV0BoR6CLODkKllcD4AVFruV9EhPId+vfQ3RPfgASMWboLHnIIduYjEmw36iFKQeGh5kxoS4a7XligT2u8o682tFWTYAnsyWpVUSxoy2m9zeydAreFrz3yAU0j4MBLvQ5N9P1h1uidZd06+/rfHkbH1w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712582416; c=relaxed/simple; bh=Lg7MpZIv/xYXPJQLm776tfjlApa0oKTGhqiiIowID+0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PbD0TLboJpL0GLu77qyOSojNH53xGPEkU2D830PCAwUUCHeU8rg2CuoLrYsQ8O2+X8Hcr+0fmGXWnJNSki+mhpfEckX6PtLXKdqQWTSJvpjiLpZdSfjadyVkuzFu7K0ZW01ExVTQqvhX7E2tilRNpMYfyK6bjd04G4lIBGUjWCA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net; spf=pass smtp.mailfrom=fiberby.net; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b=ukQgap4V; arc=none smtp.client-ip=193.104.135.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fiberby.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="ukQgap4V" Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id 7791E600A2; Mon, 8 Apr 2024 13:10:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1712581838; bh=Lg7MpZIv/xYXPJQLm776tfjlApa0oKTGhqiiIowID+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ukQgap4VNE/vEA18w+LsctfzZJVVbH5993hCpyEXFwbO5RsxzLSdiYuvYQdSZSSBr 0Zwu+kMItoPPBwuiVadpvYwGoAyGRfMwC62RwOIMI6Vr14reFCwrdT4iqYeo3z31ek lrpFvy8acFixr7vXWudQheEMb4t3ZaIzkKLTevsFUgej9H/l6x6ZqrRlG+eMmBgm8L X3d5xObHrLSUacMgbYs3fYwQ87bCWJsYjIgPvQJUJ/xpv7kd+5IQOBvppvgq7rB3OL 44KJjW1ifhYrLrm2/uX4n7kdckW1L/D2o9p34JkeUKkyVGd7BEJRMDS0IH28O7WadB kPdBkZjsvE+Ww== Received: by x201s (Postfix, from userid 1000) id F02F5205049; Mon, 08 Apr 2024 13:09:39 +0000 (UTC) From: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Louis Peens , Taras Chornyi , Woojung Huh , UNGLinuxDriver@microchip.com Cc: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yanguo Li , oss-drivers@corigine.com, Andrew Lunn , Florian Fainelli , Vladimir Oltean , Edward Cree , Jamal Hadi Salim , Cong Wang , Jiri Pirko Subject: [PATCH net-next 3/6] flow_offload: add flow_rule_no_control_flags() Date: Mon, 8 Apr 2024 13:09:21 +0000 Message-ID: <20240408130927.78594-4-ast@fiberby.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240408130927.78594-1-ast@fiberby.net> References: <20240408130927.78594-1-ast@fiberby.net> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org This helper can be used by drivers, that doesn't support any control flags, to reject any attempt to install rules with control flags. This is aimed at drivers, which uses flow_rule_match_control(), but doesn't implement any control flags. Only compile-tested. Signed-off-by: Asbjørn Sloth Tønnesen --- include/net/flow_offload.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h index c1317b14da08c..415d225204a1f 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -471,6 +471,19 @@ static inline bool flow_rule_no_unsupp_control_flags(const u32 supp_flags, return false; } +/** + * flow_rule_no_control_flags() - check for presence of any control flags + * @flags: flags present in rule + * @extack: The netlink extended ACK for reporting errors. + * + * Returns true if no control flags are set, false otherwise. + */ +static inline bool flow_rule_no_control_flags(const u32 flags, + struct netlink_ext_ack *extack) +{ + return flow_rule_no_unsupp_control_flags(0, flags, extack); +} + struct flow_stats { u64 pkts; u64 bytes; From patchwork Mon Apr 8 13:09:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= X-Patchwork-Id: 13621141 X-Patchwork-Delegate: kuba@kernel.org Received: from mail1.fiberby.net (mail1.fiberby.net [193.104.135.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1144E81754; Mon, 8 Apr 2024 13:20:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.104.135.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712582415; cv=none; b=uydI1X2bS4ds1Al7uDVqLIGffnlRR2TIQA9emJ8J0i+Oq8UjzrINHHCr3hOSyhIAJns+HTJNyM9XY+lNCSTPvagpbZ2jCFOUye3BMOF/YMza6RBIUY6ojbK9615L+OpNCzqZ2ZeHHZYC7K4oLLNHN9gwSnPm+rM0yMstXT/MhlY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712582415; c=relaxed/simple; bh=NQlO1jgsVllyqjrKVAx0V+IBXpfLP2/7zeKLGvcmncY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ygur8/1PQR+bpnyrp/gSgO8EJpFQm1cSE5neAHWbrswD9lVpobLHjvtrWke3VM6+IoYQtxrBcjcO6QmE5RmfKgzGYiqLt0GOuwOsObdOgJ3XTRBOXgiMw8OgF3IEwzZMGES4IHf0rj1QNtyyBJ5EMXvQnLv0+cpZreXKRkfxzCo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net; spf=pass smtp.mailfrom=fiberby.net; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b=Gkp+lPA1; arc=none smtp.client-ip=193.104.135.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fiberby.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="Gkp+lPA1" Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id 8E9C0600AF; Mon, 8 Apr 2024 13:10:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1712581838; bh=NQlO1jgsVllyqjrKVAx0V+IBXpfLP2/7zeKLGvcmncY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gkp+lPA16aDUfsw0EDjURxoxWbcqt1X/Sf1wfddELRWDfzqvTQ5/WhCiOJHS/SLXI YsANT4PVAnjTBzu20h/0Ex/RX2HHVSrguydZepBs9gbh+j1sJxOuHArPzeFmE+wYO/ kaR2fA2kGH/CouPssyceK5eumXTQb/zzgQGl7NyvE5Wd+PC4s56NGxxPlHLqc10T1i UPfRYL06BJaXTHeJRuoNMlwJCsdwa9jflF/NuJuuZtKguh27H31Z6dhM8VXiLuTHyh KzKTCtoeJkgoBmhcDxqIYLnfH36wlc53dcMcOCLzm6h/CH5cgSfySCjFQyJeuBsO+m FOVEwS3cX/L7Q== Received: by x201s (Postfix, from userid 1000) id EC22120B99F; Mon, 08 Apr 2024 13:09:40 +0000 (UTC) From: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Louis Peens , Taras Chornyi , Woojung Huh , UNGLinuxDriver@microchip.com Cc: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yanguo Li , oss-drivers@corigine.com, Andrew Lunn , Florian Fainelli , Vladimir Oltean , Edward Cree , Jamal Hadi Salim , Cong Wang , Jiri Pirko Subject: [PATCH net-next 4/6] net: prestera: flower: validate control flags Date: Mon, 8 Apr 2024 13:09:22 +0000 Message-ID: <20240408130927.78594-5-ast@fiberby.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240408130927.78594-1-ast@fiberby.net> References: <20240408130927.78594-1-ast@fiberby.net> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Add check for unsupported control flags. Only compile-tested, no access to HW. Signed-off-by: Asbjørn Sloth Tønnesen --- drivers/net/ethernet/marvell/prestera/prestera_flower.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/marvell/prestera/prestera_flower.c b/drivers/net/ethernet/marvell/prestera/prestera_flower.c index 8b9455d8a4f7a..075aed847913d 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_flower.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_flower.c @@ -229,6 +229,10 @@ static int prestera_flower_parse(struct prestera_flow_block *block, flow_rule_match_control(f_rule, &match); addr_type = match.key->addr_type; + + if (!flow_rule_no_control_flags(match.mask->flags, + f->common.extack)) + return -EOPNOTSUPP; } if (flow_rule_match_key(f_rule, FLOW_DISSECTOR_KEY_BASIC)) { From patchwork Mon Apr 8 13:09:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= X-Patchwork-Id: 13621143 X-Patchwork-Delegate: kuba@kernel.org Received: from mail1.fiberby.net (mail1.fiberby.net [193.104.135.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1139A7B3E5; Mon, 8 Apr 2024 13:20:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.104.135.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712582416; cv=none; b=rejIWid7BTrpRO9z2mGUck9wTmpdKpx/ihE5js8I/oUWdwGjwaOLJp9iRgHLNb4PcQS5tEdwekIzHRq1EOMQ9cFm+5W8jW/2RIKaJexuHiJy9iI7NPtf0lFnnyWl/StzXOydXz8y5266werlkStvCUGpfmnyj9o7iU5tO+Ndk/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712582416; c=relaxed/simple; bh=ybDXUvRF9y6wAVfgDLw3PDAmgXBzneOlo90cnXJ4qG8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Yhb6YsR2rDwpc3VmM+3/74p2UVMlBnjkv6bC+aYKFbbMY9XHw4icfrEgNw+obgzWUIX/VqBvmsoWnZeG4MspOrViDISlQJpsSNwebx2UiAqqNOZmk1sP8rmS/8lwzz3Fjlp22CIbG7d6lI/8DOSlEZWLLj59GFG8fm2lfn5Nk/w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net; spf=pass smtp.mailfrom=fiberby.net; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b=ZGp1Wkw6; arc=none smtp.client-ip=193.104.135.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fiberby.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="ZGp1Wkw6" Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id 9035E600B1; Mon, 8 Apr 2024 13:10:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1712581838; bh=ybDXUvRF9y6wAVfgDLw3PDAmgXBzneOlo90cnXJ4qG8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZGp1Wkw6pyXtSdbijXOMykk4HWkte2yBaRa8+vodUcCLehD2tAFMJqgRFee3X17y5 wPG8mUMjQ2kmRhxUSXWmqrKn1fD6sVbweETvJC5htAb1RQIu3k65zKvM3k4pzmZvzE TmP3vSwfJCjLHM5Nvg84N6eVgU7y+pND2cUlhab5l6YmL5YchcnX8WLGBXNgz7e95w lFoG9+UCF3cNtqRvOZ6ktgPh/lXo2hIF4dWUoEe432IatfVdL2ZSBz+4QjW6lxHxvO fZL8Nw8Fr6SVb5Tb1PifeS0z7+By465MUAf3KWpY4crSUwR+udE6wEHE8e/YtNw2kx JOsoDa1bgsTRQ== Received: by x201s (Postfix, from userid 1000) id EE36320BDE2; Mon, 08 Apr 2024 13:09:41 +0000 (UTC) From: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Louis Peens , Taras Chornyi , Woojung Huh , UNGLinuxDriver@microchip.com Cc: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yanguo Li , oss-drivers@corigine.com, Andrew Lunn , Florian Fainelli , Vladimir Oltean , Edward Cree , Jamal Hadi Salim , Cong Wang , Jiri Pirko Subject: [PATCH net-next 5/6] flow_offload: add flow_rule_match_no_control_flags() Date: Mon, 8 Apr 2024 13:09:23 +0000 Message-ID: <20240408130927.78594-6-ast@fiberby.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240408130927.78594-1-ast@fiberby.net> References: <20240408130927.78594-1-ast@fiberby.net> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org This helper can by used by drivers, that doesn't look into FLOW_DISSECTOR_KEY_CONTROL at all. This is aimed at drivers, which doesn't call flow_rule_match_control() directly, and therefore doesn't support any control flags. Only compile-tested. Signed-off-by: Asbjørn Sloth Tønnesen --- include/net/flow_offload.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h index 415d225204a1f..b427b93d151a9 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -484,6 +484,26 @@ static inline bool flow_rule_no_control_flags(const u32 flags, return flow_rule_no_unsupp_control_flags(0, flags, extack); } +/** + * flow_rule_match_no_control_flags() - match and check for any control flags + * @rule: The flow_rule under evaluation. + * @extack: The netlink extended ACK for reporting errors. + * + * Returns true if no control flags are set, false otherwise. + */ +static inline bool flow_rule_match_no_control_flags(struct flow_rule *rule, + struct netlink_ext_ack *extack) +{ + struct flow_match_control match; + + if (!flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_CONTROL)) + return true; + + flow_rule_match_control(rule, &match); + + return flow_rule_no_control_flags(match.mask->flags, extack); +} + struct flow_stats { u64 pkts; u64 bytes; From patchwork Mon Apr 8 13:09:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= X-Patchwork-Id: 13621142 X-Patchwork-Delegate: kuba@kernel.org Received: from mail1.fiberby.net (mail1.fiberby.net [193.104.135.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 113D38174E; Mon, 8 Apr 2024 13:20:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.104.135.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712582415; cv=none; b=N7iE5tGtpAs8o0UR1Qcfpz6GwXnPsfRNZ7jbxZw1lifKZZo7bqWcjprMDvKovKMl7dEUTKbhUR3OazHcRGLboDy1ePAzWAYBt7+FtQ4ODe803M3t96qL7Rd/h7kofM4FvWr0ifaQXT+TfQ8o+mwtWV8FrZ3qVu7/Rj01tsANAsM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712582415; c=relaxed/simple; bh=bA6hKYZ82VB6o6udzZS2rqCWCcIdVnx+Qp8TMbmLPiA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D8UAkKME1HP+PIbo7ZjvxlmajWBEoz75tBwchw9MLTehuFVGrePr4RbSlvaVPa5VnrGCeqCRx4eWmyZoylkB22/c+zRh498RWS0K1jDUBc10Yn4VWjk2SvcVM+PMU0Ov2yks3S/69j32T72syz8Q/QGjtOrIyGn9KXOiPDm+D1I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net; spf=pass smtp.mailfrom=fiberby.net; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b=F3Q1XRoh; arc=none smtp.client-ip=193.104.135.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fiberby.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="F3Q1XRoh" Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id 89A85600A7; Mon, 8 Apr 2024 13:10:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1712581838; bh=bA6hKYZ82VB6o6udzZS2rqCWCcIdVnx+Qp8TMbmLPiA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F3Q1XRohx6nleEyeTdL+pgh9xmCk7cMb2eOrrlZDv2oAtbGAm14p7Cm+iyDtVRA/w ABiVn+gb2iVVem/6/Jf4VubV1slww0XYOKMuw5DdngbPtY4cb6+FDzg2qIWe2P9HDf FDU/mfObJ92rmEENQXZtPpGLl0khylNBKUhmDVyIO9pe1um0d2btvcD5tfBtEccjk3 IaCP9YhdxFJ9fxbrFwwLH9bBg5u2aUpKY6m3vNziwssM5BpCNxTdg4GMICotIrKAH5 p4UkEyY59z2QTka6nwMpaxWGD82W+b+25jKCAVHrsjGoTEicHj1kizzRtk05pGObdX FIqnEOx8KZoig== Received: by x201s (Postfix, from userid 1000) id 9C4C320BDE4; Mon, 08 Apr 2024 13:09:43 +0000 (UTC) From: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Louis Peens , Taras Chornyi , Woojung Huh , UNGLinuxDriver@microchip.com Cc: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yanguo Li , oss-drivers@corigine.com, Andrew Lunn , Florian Fainelli , Vladimir Oltean , Edward Cree , Jamal Hadi Salim , Cong Wang , Jiri Pirko Subject: [PATCH net-next 6/6] net: dsa: microchip: ksz9477: flower: validate control flags Date: Mon, 8 Apr 2024 13:09:24 +0000 Message-ID: <20240408130927.78594-7-ast@fiberby.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240408130927.78594-1-ast@fiberby.net> References: <20240408130927.78594-1-ast@fiberby.net> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Add check for unsupported control flags. Only compile-tested, no access to HW. Signed-off-by: Asbjørn Sloth Tønnesen --- drivers/net/dsa/microchip/ksz9477_tc_flower.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/dsa/microchip/ksz9477_tc_flower.c b/drivers/net/dsa/microchip/ksz9477_tc_flower.c index 8b2f5be667e01..4823a876ad8ab 100644 --- a/drivers/net/dsa/microchip/ksz9477_tc_flower.c +++ b/drivers/net/dsa/microchip/ksz9477_tc_flower.c @@ -124,6 +124,9 @@ static int ksz9477_flower_parse_key(struct ksz_device *dev, int port, return -EOPNOTSUPP; } + if (!flow_rule_match_no_control_flags(rule, extack)) + return -EOPNOTSUPP; + if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_BASIC) || flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ETH_ADDRS)) { ret = ksz9477_flower_parse_key_l2(dev, port, extack, rule,