From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jakub Kicinski Subject: [RFC net-next 8/8] cls_bpf: drivers: don't try to use extack before callback type is validated Date: Tue, 23 Jan 2018 13:33:40 -0800 Message-ID: <20180123213340.19235-9-jakub.kicinski@netronome.com> References: <20180123213340.19235-1-jakub.kicinski@netronome.com> Cc: netdev@vger.kernel.org, oss-drivers@netronome.com, dsahern@gmail.com, Jakub Kicinski To: jiri@resnulli.us Return-path: Received: from mail-pf0-f196.google.com ([209.85.192.196]:42630 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932128AbeAWVeD (ORCPT ); Tue, 23 Jan 2018 16:34:03 -0500 Received: by mail-pf0-f196.google.com with SMTP id b25so1338432pfd.9 for ; Tue, 23 Jan 2018 13:34:03 -0800 (PST) In-Reply-To: <20180123213340.19235-1-jakub.kicinski@netronome.com> Sender: netdev-owner@vger.kernel.org List-ID: Although today only classifier offloads call block callbacks, we shouldn't really assume that @type_data starts with struct tc_cls_common_offload until we validated the type. Signed-off-by: Jakub Kicinski --- drivers/net/ethernet/netronome/nfp/bpf/main.c | 5 +---- drivers/net/netdevsim/bpf.c | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/bpf/main.c b/drivers/net/ethernet/netronome/nfp/bpf/main.c index 552e2657b536..165276b50b4c 100644 --- a/drivers/net/ethernet/netronome/nfp/bpf/main.c +++ b/drivers/net/ethernet/netronome/nfp/bpf/main.c @@ -125,11 +125,8 @@ static int nfp_bpf_setup_tc_block_cb(enum tc_setup_type type, struct nfp_bpf_vnic *bv; int err; - if (type != TC_SETUP_CLSBPF) { - NL_SET_ERR_MSG_MOD(cls_bpf->common.extack, - "only offload of BPF classifiers supported"); + if (type != TC_SETUP_CLSBPF) return -EOPNOTSUPP; - } if (!tc_can_offload_cls(nn->dp.netdev, &cls_bpf->common)) return -EOPNOTSUPP; if (!nfp_net_ebpf_capable(nn)) { diff --git a/drivers/net/netdevsim/bpf.c b/drivers/net/netdevsim/bpf.c index bbcb8ec42208..5b2c5260624d 100644 --- a/drivers/net/netdevsim/bpf.c +++ b/drivers/net/netdevsim/bpf.c @@ -129,11 +129,8 @@ 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"); + if (type != TC_SETUP_CLSBPF) return -EOPNOTSUPP; - } if (!tc_can_offload_cls(ns->netdev, &cls_bpf->common)) return -EOPNOTSUPP; -- 2.15.1