[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <219859e674ef7a9d8af9ab4f64a9095580f04bcc.1730436983.git.dxu@dxuuu.xyz>
Date: Thu, 31 Oct 2024 22:58:30 -0600
From: Daniel Xu <dxu@...uu.xyz>
To: davem@...emloft.net,
michael.chan@...adcom.com,
edumazet@...gle.com,
andrew+netdev@...n.ch,
kuba@...nel.org,
vikas.gupta@...adcom.com,
andrew.gospodarek@...adcom.com,
pabeni@...hat.com,
pavan.chebbi@...adcom.com,
martin.lau@...ux.dev
Cc: netdev@...r.kernel.org,
linux-kernel@...r.kernel.org,
kernel-team@...a.com
Subject: [PATCH net] bnxt_en: ethtool: Fix ip[6] ntuple rule verification
Previously, trying to insert an ip or ip6 only rule would get rejected
with -EOPNOTSUPP. For example, the following would fail:
ethtool -N eth0 flow-type ip6 dst-ip $IP6 context 1
The reason was that all the l4proto validation was being run despite the
l4proto mask being set to 0x0. Fix by only running l4proto validation
when mask is set.
Fixes: 9ba0e56199e3 ("bnxt_en: Enhance ethtool ntuple support for ip flows besides TCP/UDP")
Signed-off-by: Daniel Xu <dxu@...uu.xyz>
---
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
index f71cc8188b4e..1c97ee406bd7 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
@@ -1289,10 +1289,13 @@ static int bnxt_add_l2_cls_rule(struct bnxt *bp,
static bool bnxt_verify_ntuple_ip4_flow(struct ethtool_usrip4_spec *ip_spec,
struct ethtool_usrip4_spec *ip_mask)
{
+ u8 mproto = ip_mask->proto;
+ u8 sproto = ip_spec->proto;
+
if (ip_mask->l4_4_bytes || ip_mask->tos ||
ip_spec->ip_ver != ETH_RX_NFC_IP4 ||
- ip_mask->proto != BNXT_IP_PROTO_FULL_MASK ||
- (ip_spec->proto != IPPROTO_RAW && ip_spec->proto != IPPROTO_ICMP))
+ (mproto && mproto != BNXT_IP_PROTO_FULL_MASK) ||
+ (mproto && sproto != IPPROTO_RAW && sproto != IPPROTO_ICMP))
return false;
return true;
}
@@ -1300,10 +1303,12 @@ static bool bnxt_verify_ntuple_ip4_flow(struct ethtool_usrip4_spec *ip_spec,
static bool bnxt_verify_ntuple_ip6_flow(struct ethtool_usrip6_spec *ip_spec,
struct ethtool_usrip6_spec *ip_mask)
{
+ u8 mproto = ip_mask->l4_proto;
+ u8 sproto = ip_spec->l4_proto;
+
if (ip_mask->l4_4_bytes || ip_mask->tclass ||
- ip_mask->l4_proto != BNXT_IP_PROTO_FULL_MASK ||
- (ip_spec->l4_proto != IPPROTO_RAW &&
- ip_spec->l4_proto != IPPROTO_ICMPV6))
+ (mproto && mproto != BNXT_IP_PROTO_FULL_MASK) ||
+ (mproto && sproto != IPPROTO_RAW && sproto != IPPROTO_ICMPV6))
return false;
return true;
}
--
2.46.0
Powered by blists - more mailing lists