Skip to content

Commit e5c4777

Browse files
committed
bnxt_en: ethtool: Support unset l4proto on ip4/ip6 ntuple rules
JIRA: https://issues.redhat.com/browse/RHEL-54644 commit 5f143ef Author: Daniel Xu <dxu@dxuuu.xyz> Date: Mon Nov 4 21:13:20 2024 -0700 bnxt_en: ethtool: Support unset l4proto on ip4/ip6 ntuple rules Previously, trying to insert an ip4/ip6 ntuple rule with an unset l4proto 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 respecting the mask on l4proto and treating a mask of 0x0 as wildcard l4proto. Signed-off-by: Daniel Xu <dxu@dxuuu.xyz> Reviewed-by: Michael Chan <michael.chan@broadcom.com> Link: https://patch.msgid.link/1ac93a2836b25f79e7045f8874d9a17875229ffc.1730778566.git.dxu@dxuuu.xyz Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
1 parent e0404d8 commit e5c4777

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,12 @@ static int bnxt_grxclsrule(struct bnxt *bp, struct ethtool_rxnfc *cmd)
11311131
fkeys = &fltr->fkeys;
11321132
fmasks = &fltr->fmasks;
11331133
if (fkeys->basic.n_proto == htons(ETH_P_IP)) {
1134-
if (fkeys->basic.ip_proto == IPPROTO_ICMP) {
1134+
if (fkeys->basic.ip_proto == BNXT_IP_PROTO_WILDCARD) {
1135+
fs->flow_type = IP_USER_FLOW;
1136+
fs->h_u.usr_ip4_spec.ip_ver = ETH_RX_NFC_IP4;
1137+
fs->h_u.usr_ip4_spec.proto = BNXT_IP_PROTO_WILDCARD;
1138+
fs->m_u.usr_ip4_spec.proto = 0;
1139+
} else if (fkeys->basic.ip_proto == IPPROTO_ICMP) {
11351140
fs->flow_type = IP_USER_FLOW;
11361141
fs->h_u.usr_ip4_spec.ip_ver = ETH_RX_NFC_IP4;
11371142
fs->h_u.usr_ip4_spec.proto = IPPROTO_ICMP;
@@ -1156,7 +1161,11 @@ static int bnxt_grxclsrule(struct bnxt *bp, struct ethtool_rxnfc *cmd)
11561161
fs->m_u.tcp_ip4_spec.pdst = fmasks->ports.dst;
11571162
}
11581163
} else {
1159-
if (fkeys->basic.ip_proto == IPPROTO_ICMPV6) {
1164+
if (fkeys->basic.ip_proto == BNXT_IP_PROTO_WILDCARD) {
1165+
fs->flow_type = IPV6_USER_FLOW;
1166+
fs->h_u.usr_ip6_spec.l4_proto = BNXT_IP_PROTO_WILDCARD;
1167+
fs->m_u.usr_ip6_spec.l4_proto = 0;
1168+
} else if (fkeys->basic.ip_proto == IPPROTO_ICMPV6) {
11601169
fs->flow_type = IPV6_USER_FLOW;
11611170
fs->h_u.usr_ip6_spec.l4_proto = IPPROTO_ICMPV6;
11621171
fs->m_u.usr_ip6_spec.l4_proto = BNXT_IP_PROTO_FULL_MASK;
@@ -1281,20 +1290,24 @@ static int bnxt_add_l2_cls_rule(struct bnxt *bp,
12811290
static bool bnxt_verify_ntuple_ip4_flow(struct ethtool_usrip4_spec *ip_spec,
12821291
struct ethtool_usrip4_spec *ip_mask)
12831292
{
1293+
u8 mproto = ip_mask->proto;
1294+
u8 sproto = ip_spec->proto;
1295+
12841296
if (ip_mask->l4_4_bytes || ip_mask->tos ||
12851297
ip_spec->ip_ver != ETH_RX_NFC_IP4 ||
1286-
ip_mask->proto != BNXT_IP_PROTO_FULL_MASK ||
1287-
ip_spec->proto != IPPROTO_ICMP)
1298+
(mproto && (mproto != BNXT_IP_PROTO_FULL_MASK || sproto != IPPROTO_ICMP)))
12881299
return false;
12891300
return true;
12901301
}
12911302

12921303
static bool bnxt_verify_ntuple_ip6_flow(struct ethtool_usrip6_spec *ip_spec,
12931304
struct ethtool_usrip6_spec *ip_mask)
12941305
{
1306+
u8 mproto = ip_mask->l4_proto;
1307+
u8 sproto = ip_spec->l4_proto;
1308+
12951309
if (ip_mask->l4_4_bytes || ip_mask->tclass ||
1296-
ip_mask->l4_proto != BNXT_IP_PROTO_FULL_MASK ||
1297-
ip_spec->l4_proto != IPPROTO_ICMPV6)
1310+
(mproto && (mproto != BNXT_IP_PROTO_FULL_MASK || sproto != IPPROTO_ICMPV6)))
12981311
return false;
12991312
return true;
13001313
}
@@ -1348,7 +1361,8 @@ static int bnxt_add_ntuple_cls_rule(struct bnxt *bp,
13481361
struct ethtool_usrip4_spec *ip_spec = &fs->h_u.usr_ip4_spec;
13491362
struct ethtool_usrip4_spec *ip_mask = &fs->m_u.usr_ip4_spec;
13501363

1351-
fkeys->basic.ip_proto = ip_spec->proto;
1364+
fkeys->basic.ip_proto = ip_mask->proto ? ip_spec->proto
1365+
: BNXT_IP_PROTO_WILDCARD;
13521366
fkeys->basic.n_proto = htons(ETH_P_IP);
13531367
fkeys->addrs.v4addrs.src = ip_spec->ip4src;
13541368
fmasks->addrs.v4addrs.src = ip_mask->ip4src;
@@ -1379,7 +1393,8 @@ static int bnxt_add_ntuple_cls_rule(struct bnxt *bp,
13791393
struct ethtool_usrip6_spec *ip_spec = &fs->h_u.usr_ip6_spec;
13801394
struct ethtool_usrip6_spec *ip_mask = &fs->m_u.usr_ip6_spec;
13811395

1382-
fkeys->basic.ip_proto = ip_spec->l4_proto;
1396+
fkeys->basic.ip_proto = ip_mask->l4_proto ? ip_spec->l4_proto
1397+
: BNXT_IP_PROTO_WILDCARD;
13831398
fkeys->basic.n_proto = htons(ETH_P_IPV6);
13841399
fkeys->addrs.v6addrs.src = *(struct in6_addr *)&ip_spec->ip6src;
13851400
fmasks->addrs.v6addrs.src = *(struct in6_addr *)&ip_mask->ip6src;

drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ struct bnxt_led_cfg {
4444
#define BNXT_PXP_REG_LEN 0x3110
4545

4646
#define BNXT_IP_PROTO_FULL_MASK 0xFF
47+
#define BNXT_IP_PROTO_WILDCARD 0x0
4748

4849
extern const struct ethtool_ops bnxt_ethtool_ops;
4950

0 commit comments

Comments
 (0)