netdevsim: add fake FT/CLS_FLOWER offload
Subsystems (5)
Florian Westphal
maintainerv2 cover netdevsim: add fake FT/CLS_FLOWER offload
v2: fix up error reporting via extack
shellcheck cleanups
sort config toggles
1) Enable nf_tables offload control plane testing in netdevsim. Tag existing offload fn to allow error injection for testing rollback and abort logic.
2) Add nft_offload selftest to exercise the control plane and error unwind via fault injection.
Florian Westphal (2):
netdevsim: tc: allow to test nf_tables offload control plane code
selftests: netfilter: add phony nft_offload test
drivers/net/netdevsim/bpf.c | 6 - drivers/net/netdevsim/tc.c | 20 ++- .../testing/selftests/net/netfilter/Makefile | 1 + tools/testing/selftests/net/netfilter/config | 6 + .../selftests/net/netfilter/nft_offload.sh | 132 ++++++++++++++++++ 5 files changed, 158 insertions(+), 7 deletions(-) create mode 100755 tools/testing/selftests/net/netfilter/nft_offload.sh
Signature · 1 line
2.53.0
Florian Westphal
maintainerPATCH v2 1/2 netdevsim: tc: allow to test nf_tables offload control plane code
The actual 'offload' is phony, all commands are ignored: this is only useful to test control plane code.
Tag the existing callback to permit error injection to test rollback/abort code in nf_tables. This is also for fuzzers - the fault injection framework allows probabilistic error insertion.
---
v2: move extack error to nsim_setup_tc_block_cb
drivers/net/netdevsim/bpf.c | 6 ------ drivers/net/netdevsim/tc.c | 20 +++++++++++++++++++- 2 files changed, 19 insertions(+), 7 deletions(-)
drivers/net/netdevsim/bpf.c +0 -6
@@ -123,12 +123,6 @@ int nsim_bpf_setup_tc_block_cb(enum tc_setup_type type,struct netdevsim *ns = cb_priv;struct bpf_prog *oldprog; -if (type !=TC_SETUP_CLSBPF ) { -NSIM_EA (cls_bpf->common.extack, -"only offload of BPF classifiers supported" ); -return -EOPNOTSUPP ; - } -if (!tc_cls_can_offload_and_chain0 (ns->netdev, &cls_bpf->common))return -EOPNOTSUPP ;
drivers/net/netdevsim/tc.c +19 -1
@@ -9,7 +9,22 @@static int nsim_setup_tc_block_cb (enum tc_setup_type type,void *type_data,void *cb_priv) { -return nsim_bpf_setup_tc_block_cb (type, type_data, cb_priv); +struct flow_cls_common_offload *common = type_data; +int err =0 ; + +switch (type) { +case TC_SETUP_CLSBPF : + err =nsim_bpf_setup_tc_block_cb (type, type_data, cb_priv); +break ; +case TC_SETUP_CLSFLOWER : +break ; +default : +NSIM_EA (common->extack,"offload type not supported" ); + err = -EOPNOTSUPP ; +break ; + } + +return err; }static void nsim_taprio_stats (struct tc_taprio_qopt_stats *stats)
@@ -73,7 +88,10 @@ nsim_setup_tc(struct net_device *dev, enum tc_setup_type type, void *type_data) &nsim_block_cb_list, nsim_setup_tc_block_cb, ns, ns, true); +case TC_SETUP_FT : +return 0 ;default :return -EOPNOTSUPP ; } } +ALLOW_ERROR_INJECTION (nsim_setup_tc,ERRNO );
Signature · 1 line
2.53.0
Florian Westphal
maintainerPATCH v2 2/2 selftests: netfilter: add phony nft_offload test
In reply to Florian Westphal... "phony", because its not testing offloads, it tests the control plane code. Also test error unwind via fault injection framework.
For a proper test, real hardware would be required given we'd have check if 'previously handed off to hardware' offload commands are properly removed again on failure or rule flush.
---
v2: sort config
shellcheck fixups
.../testing/selftests/net/netfilter/Makefile | 1 + tools/testing/selftests/net/netfilter/config | 6 + .../selftests/net/netfilter/nft_offload.sh | 132 ++++++++++++++++++ 3 files changed, 139 insertions(+) create mode 100755 tools/testing/selftests/net/netfilter/nft_offload.sh
tools/testing/selftests/net/netfilter/Makefile +1 -0
@@ -32,6 +32,7 @@ TEST_PROGS := \ nft_meta.sh \ nft_nat.sh \ nft_nat_zones.sh \ + nft_offload.sh \ nft_queue.sh \ nft_synproxy.sh \ nft_tproxy_tcp.sh \
tools/testing/selftests/net/netfilter/config +6 -0
@@ -11,7 +11,12 @@ CONFIG_BRIDGE_NF_EBTABLES_LEGACY=m CONFIG_BRIDGE_VLAN_FILTERING=y CONFIG_CGROUP_BPF=y CONFIG_CRYPTO_SHA1=m +CONFIG_DEBUG_FS=y CONFIG_DUMMY=m +CONFIG_FAIL_FUNCTION=y +CONFIG_FAULT_INJECTION=y +CONFIG_FAULT_INJECTION_DEBUG_FS=y +CONFIG_FUNCTION_ERROR_INJECTION=y CONFIG_INET_DIAG=m CONFIG_INET_ESP=m CONFIG_INET_SCTP_DIAG=m
@@ -36,6 +41,7 @@ CONFIG_IP_VS_RR=m CONFIG_MACVLAN=m CONFIG_NAMESPACES=y CONFIG_NET_CLS_U32=m +CONFIG_NETDEVSIM=m CONFIG_NETFILTER=y CONFIG_NETFILTER_ADVANCED=y CONFIG_NETFILTER_NETLINK=m
tools/testing/selftests/net/netfilter/nft_offload.sh new file +132 -0
132 lines not on this page · raw message
Signature · 1 line
2.53.0
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Fri, 12 Jun 2026 11:22:07 +0200 you wrote:
v2: fix up error reporting via extack
shellcheck cleanups
sort config toggles1) Enable
nf_tablesoffload control plane testing in netdevsim. Tag existing offload fn to allow error injection for testing rollback and abort logic.[...]
Here is the summary with links:
- [v2,net-next,1/2] netdevsim: tc: allow to test nf_tables offload control plane code
https://git.kernel.org/netdev/net-next/c/07ca2ab4ce84 - [v2,net-next,2/2] selftests: netfilter: add phony nft_offload test https://git.kernel.org/netdev/net-next/c/5394aa0bb00d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html