Skip to content

Commit 728461f

Browse files
qmonnetdavem330
authored andcommitted
netdevsim: add extack support for TC eBPF offload
Use the recently added extack support for TC eBPF filters in netdevsim. Signed-off-by: Quentin Monnet <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5215046 commit 728461f

File tree

1 file changed

+28
-7
lines changed
  • drivers/net/netdevsim

1 file changed

+28
-7
lines changed

drivers/net/netdevsim/bpf.c

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,35 @@ int nsim_bpf_setup_tc_block_cb(enum tc_setup_type type,
123123
struct netdevsim *ns = cb_priv;
124124
struct bpf_prog *oldprog;
125125

126-
if (type != TC_SETUP_CLSBPF ||
127-
!tc_can_offload(ns->netdev) ||
128-
cls_bpf->common.protocol != htons(ETH_P_ALL) ||
129-
cls_bpf->common.chain_index)
126+
if (type != TC_SETUP_CLSBPF) {
127+
NSIM_EA(cls_bpf->common.extack,
128+
"only offload of BPF classifiers supported");
130129
return -EOPNOTSUPP;
130+
}
131+
132+
if (!tc_can_offload_extack(ns->netdev, cls_bpf->common.extack))
133+
return -EOPNOTSUPP;
134+
135+
if (cls_bpf->common.protocol != htons(ETH_P_ALL)) {
136+
NSIM_EA(cls_bpf->common.extack,
137+
"only ETH_P_ALL supported as filter protocol");
138+
return -EOPNOTSUPP;
139+
}
131140

132-
if (!ns->bpf_tc_accept)
141+
if (cls_bpf->common.chain_index)
133142
return -EOPNOTSUPP;
143+
144+
if (!ns->bpf_tc_accept) {
145+
NSIM_EA(cls_bpf->common.extack,
146+
"netdevsim configured to reject BPF TC offload");
147+
return -EOPNOTSUPP;
148+
}
134149
/* Note: progs without skip_sw will probably not be dev bound */
135-
if (prog && !prog->aux->offload && !ns->bpf_tc_non_bound_accept)
150+
if (prog && !prog->aux->offload && !ns->bpf_tc_non_bound_accept) {
151+
NSIM_EA(cls_bpf->common.extack,
152+
"netdevsim configured to reject unbound programs");
136153
return -EOPNOTSUPP;
154+
}
137155

138156
if (cls_bpf->command != TC_CLSBPF_OFFLOAD)
139157
return -EOPNOTSUPP;
@@ -145,8 +163,11 @@ int nsim_bpf_setup_tc_block_cb(enum tc_setup_type type,
145163
oldprog = NULL;
146164
if (!cls_bpf->prog)
147165
return 0;
148-
if (ns->bpf_offloaded)
166+
if (ns->bpf_offloaded) {
167+
NSIM_EA(cls_bpf->common.extack,
168+
"driver and netdev offload states mismatch");
149169
return -EBUSY;
170+
}
150171
}
151172

152173
return nsim_bpf_offload(ns, cls_bpf->prog, oldprog);

0 commit comments

Comments
 (0)