]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
netdevsim: tc: allow to test nf_tables offload control plane code
authorFlorian Westphal <fw@strlen.de>
Fri, 12 Jun 2026 09:22:08 +0000 (11:22 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sat, 13 Jun 2026 17:29:39 +0000 (10:29 -0700)
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.

Signed-off-by: Florian Westphal <fw@strlen.de>
Link: https://patch.msgid.link/20260612092209.11966-2-fw@strlen.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/netdevsim/bpf.c
drivers/net/netdevsim/tc.c

index 8eebcc933ddbdd2b84d0973ef45244e0816968d0..16aa8827839840a71abc21b25dd5c6fd1c60d855 100644 (file)
@@ -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;
 
index 8f013a5895a2b67b3b337f701b20a150cbc74689..a415e02a6df1e391894600ac74fd9c70fb94432a 100644 (file)
@@ -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);