Skip to content

Commit 613fd52

Browse files
committed
Merge branch 'fix-ntuple-rules-targeting-default-rss'
Gal Pressman says: ==================== Fix ntuple rules targeting default RSS This series addresses a regression in ethtool flow steering where rules targeting the default RSS context (context 0) were incorrectly rejected. The default RSS context always exists but is not stored in the rss_ctx xarray like additional contexts. The current validation logic was checking for the existence of context 0 in this array, causing valid flow steering rules to be rejected. This prevented configurations such as: - High priority rules directing specific traffic to the default context - Low priority catch-all rules directing remaining traffic to additional contexts Patch 1 fixes the validation logic to skip the existence check for context 0. Patch 2 adds a selftest that verifies this behavior. v3: https://lore.kernel.org/[email protected] v2: https://lore.kernel.org/[email protected] ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents d5441ac + 56c5d29 commit 613fd52

File tree

2 files changed

+60
-2
lines changed

2 files changed

+60
-2
lines changed

net/ethtool/ioctl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,8 @@ static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,
10831083
ethtool_get_flow_spec_ring(info.fs.ring_cookie))
10841084
return -EINVAL;
10851085

1086-
if (!xa_load(&dev->ethtool->rss_ctx, info.rss_context))
1086+
if (info.rss_context &&
1087+
!xa_load(&dev->ethtool->rss_ctx, info.rss_context))
10871088
return -EINVAL;
10881089
}
10891090

tools/testing/selftests/drivers/net/hw/rss_ctx.py

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,62 @@ def test_rss_ntuple_addition(cfg):
747747
'noise' : (0,) })
748748

749749

750+
def test_rss_default_context_rule(cfg):
751+
"""
752+
Allocate a port, direct this port to context 0, then create a new RSS
753+
context and steer all TCP traffic to it (context 1). Verify that:
754+
* Traffic to the specific port continues to use queues of the main
755+
context (0/1).
756+
* Traffic to any other TCP port is redirected to the new context
757+
(queues 2/3).
758+
"""
759+
760+
require_ntuple(cfg)
761+
762+
queue_cnt = len(_get_rx_cnts(cfg))
763+
if queue_cnt < 4:
764+
try:
765+
ksft_pr(f"Increasing queue count {queue_cnt} -> 4")
766+
ethtool(f"-L {cfg.ifname} combined 4")
767+
defer(ethtool, f"-L {cfg.ifname} combined {queue_cnt}")
768+
except Exception as exc:
769+
raise KsftSkipEx("Not enough queues for the test") from exc
770+
771+
# Use queues 0 and 1 for the main context
772+
ethtool(f"-X {cfg.ifname} equal 2")
773+
defer(ethtool, f"-X {cfg.ifname} default")
774+
775+
# Create a new RSS context that uses queues 2 and 3
776+
ctx_id = ethtool_create(cfg, "-X", "context new start 2 equal 2")
777+
defer(ethtool, f"-X {cfg.ifname} context {ctx_id} delete")
778+
779+
# Generic low-priority rule: redirect all TCP traffic to the new context.
780+
# Give it an explicit higher location number (lower priority).
781+
flow_generic = f"flow-type tcp{cfg.addr_ipver} dst-ip {cfg.addr} context {ctx_id} loc 1"
782+
ethtool(f"-N {cfg.ifname} {flow_generic}")
783+
defer(ethtool, f"-N {cfg.ifname} delete 1")
784+
785+
# Specific high-priority rule for a random port that should stay on context 0.
786+
# Assign loc 0 so it is evaluated before the generic rule.
787+
port_main = rand_port()
788+
flow_main = f"flow-type tcp{cfg.addr_ipver} dst-ip {cfg.addr} dst-port {port_main} context 0 loc 0"
789+
ethtool(f"-N {cfg.ifname} {flow_main}")
790+
defer(ethtool, f"-N {cfg.ifname} delete 0")
791+
792+
_ntuple_rule_check(cfg, 1, ctx_id)
793+
794+
# Verify that traffic matching the specific rule still goes to queues 0/1
795+
_send_traffic_check(cfg, port_main, "context 0",
796+
{ 'target': (0, 1),
797+
'empty' : (2, 3) })
798+
799+
# And that traffic for any other port is steered to the new context
800+
port_other = rand_port()
801+
_send_traffic_check(cfg, port_other, f"context {ctx_id}",
802+
{ 'target': (2, 3),
803+
'noise' : (0, 1) })
804+
805+
750806
def main() -> None:
751807
with NetDrvEpEnv(__file__, nsim_test=False) as cfg:
752808
cfg.context_cnt = None
@@ -760,7 +816,8 @@ def main() -> None:
760816
test_rss_context_overlap, test_rss_context_overlap2,
761817
test_rss_context_out_of_order, test_rss_context4_create_with_cfg,
762818
test_flow_add_context_missing,
763-
test_delete_rss_context_busy, test_rss_ntuple_addition],
819+
test_delete_rss_context_busy, test_rss_ntuple_addition,
820+
test_rss_default_context_rule],
764821
args=(cfg, ))
765822
ksft_exit()
766823

0 commit comments

Comments
 (0)