Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bnxt_en: Allow ntuple filters for drops

It appears that in commit 7efd79c0e689 ("bnxt_en: Add drop action
support for ntuple"), bnxt gained support for ntuple filters for packet
drops.

However, support for this does not seem to work in recent kernels or
against net-next:

% sudo ethtool -U eth0 flow-type udp4 src-ip 1.1.1.1 action -1
rmgr: Cannot insert RX class rule: Operation not supported
Cannot insert classification rule

The issue is that the existing code uses ethtool_get_flow_spec_ring_vf,
which will return a non-zero value if the ring_cookie is set to
RX_CLS_FLOW_DISC, which then causes bnxt_add_ntuple_cls_rule to return
-EOPNOTSUPP because it thinks the user is trying to set an ntuple filter
for a vf.

Fix this by first checking that the ring_cookie is not RX_CLS_FLOW_DISC.

After this patch, ntuple filters for drops can be added:

% sudo ethtool -U eth0 flow-type udp4 src-ip 1.1.1.1 action -1
Added rule with ID 0

% ethtool -n eth0
44 RX rings available
Total 1 rules

Filter: 0
Rule Type: UDP over IPv4
Src IP addr: 1.1.1.1 mask: 0.0.0.0
Dest IP addr: 0.0.0.0 mask: 255.255.255.255
TOS: 0x0 mask: 0xff
Src port: 0 mask: 0xffff
Dest port: 0 mask: 0xffff
Action: Drop

Reviewed-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: Joe Damato <joe@dama.to>
Link: https://patch.msgid.link/20260131003042.2570434-1-joe@dama.to
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Joe Damato and committed by
Jakub Kicinski
61cef645 71a58ec6

+7 -6
+7 -6
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
··· 1346 1346 struct bnxt_l2_filter *l2_fltr; 1347 1347 struct bnxt_flow_masks *fmasks; 1348 1348 struct flow_keys *fkeys; 1349 - u32 idx, ring; 1349 + u32 idx; 1350 1350 int rc; 1351 - u8 vf; 1352 1351 1353 1352 if (!bp->vnic_info) 1354 1353 return -EAGAIN; 1355 1354 1356 - vf = ethtool_get_flow_spec_ring_vf(fs->ring_cookie); 1357 - ring = ethtool_get_flow_spec_ring(fs->ring_cookie); 1358 - if ((fs->flow_type & (FLOW_MAC_EXT | FLOW_EXT)) || vf) 1355 + if (fs->flow_type & (FLOW_MAC_EXT | FLOW_EXT)) 1356 + return -EOPNOTSUPP; 1357 + 1358 + if (fs->ring_cookie != RX_CLS_FLOW_DISC && 1359 + ethtool_get_flow_spec_ring_vf(fs->ring_cookie)) 1359 1360 return -EOPNOTSUPP; 1360 1361 1361 1362 if (flow_type == IP_USER_FLOW) { ··· 1482 1481 if (fs->ring_cookie == RX_CLS_FLOW_DISC) 1483 1482 new_fltr->base.flags |= BNXT_ACT_DROP; 1484 1483 else 1485 - new_fltr->base.rxq = ring; 1484 + new_fltr->base.rxq = ethtool_get_flow_spec_ring(fs->ring_cookie); 1486 1485 __set_bit(BNXT_FLTR_VALID, &new_fltr->base.state); 1487 1486 rc = bnxt_insert_ntp_filter(bp, new_fltr, idx); 1488 1487 if (!rc) {