{"id":834092,"url":"http://patchwork.ozlabs.org/api/1.2/patches/834092/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20171103205630.1083-16-jakub.kicinski@netronome.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/1.2/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20171103205630.1083-16-jakub.kicinski@netronome.com>","list_archive_url":null,"date":"2017-11-03T20:56:30","name":"[net-next,v2,15/15] bpf: remove old offload/analyzer","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"62056aafe4163f32905d0918a518da11dfecf522","submitter":{"id":67484,"url":"http://patchwork.ozlabs.org/api/1.2/people/67484/?format=json","name":"Jakub Kicinski","email":"jakub.kicinski@netronome.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/1.2/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20171103205630.1083-16-jakub.kicinski@netronome.com/mbox/","series":[{"id":11839,"url":"http://patchwork.ozlabs.org/api/1.2/series/11839/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=11839","date":"2017-11-03T20:56:15","name":"bpf: add offload as a first class citizen","version":2,"mbox":"http://patchwork.ozlabs.org/series/11839/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/834092/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/834092/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=netronome-com.20150623.gappssmtp.com\n\theader.i=@netronome-com.20150623.gappssmtp.com\n\theader.b=\"PUHeoWJv\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3yTDm13qSwz9s7p\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat,  4 Nov 2017 07:57:05 +1100 (AEDT)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1755852AbdKCU5D (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tFri, 3 Nov 2017 16:57:03 -0400","from mail-pg0-f67.google.com ([74.125.83.67]:45918 \"EHLO\n\tmail-pg0-f67.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1752454AbdKCU5A (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Fri, 3 Nov 2017 16:57:00 -0400","by mail-pg0-f67.google.com with SMTP id b192so3455550pga.2\n\tfor <netdev@vger.kernel.org>; Fri, 03 Nov 2017 13:57:00 -0700 (PDT)","from jkicinski-Precision-T1700.netronome.com ([75.53.12.129])\n\tby smtp.gmail.com with ESMTPSA id\n\to10sm9989029pgq.69.2017.11.03.13.56.58\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tFri, 03 Nov 2017 13:56:58 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=netronome-com.20150623.gappssmtp.com; s=20150623;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=7lMRw+gQWys4436v/dcIgT3eOOVu+pPWuVd36+aZ5VU=;\n\tb=PUHeoWJvhbkhbZ0OuQ39JqALC9SFjtxpjWpizwHaoNEnl4r2Yw1fhuXjjt5aUjMC/8\n\tWbbQJK8nq1juc8Hgznh3n/9O/XL/coWO/KFzxu7lZfwUwbGgJF0Ng2POhx0BjTZXWR7E\n\tSHcC9wXtlI5pBa+nVRX9bAWRadIFK3UoGq/tQFdCY8wBpAv/qhKwJXqkgmmp9oi4FMWV\n\tDvY80UJp+SCST4bGqJdfeZasw7anPSG7wj4apfxjKvBxr86G5QF+hpR4qTfMwr8vcO4y\n\totNYAIX/GgSjywP3vtk+SPWGMRzlm7A6i7UTGK6uixgqHwf9c+BqOMxoWtJUUd8GNrrP\n\tY8VA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=7lMRw+gQWys4436v/dcIgT3eOOVu+pPWuVd36+aZ5VU=;\n\tb=Y0tl3wY43e07yYYRBHfw8zqOkJwmy8Fw1f04f5Lx8bQ+tLVwZLK3dbtQFb4GC5Su1G\n\tO5AKqRPW5q0ezFcQVPe5mLhpMdcqBNywamhH/uy+fVY43aNxKdenen8hVK3G6HBLYJ3I\n\tM9OUzxt+ZqoTIS91I05b8MiXUUICZNK708X6XgXO3uXI6ATSLSbo5uAkh9iY2cyHkxdT\n\t0aKITWOJsCI5VQtwMby5pDBvEZRqkY14th0CHDcHz1eofVn7VrFq/noY5KA1WM6Roatm\n\tQiO9QSVik0rCQtC8pOJ3t9/Uj/UDo+lkJH24VNnhDhROKwVpP/b2v71s85uDm1uCMIX4\n\tPxWA==","X-Gm-Message-State":"AMCzsaW2SPnh3VU14i5bu9J9d8/MxP29efCEjqyyuiE9dfGK7SD8hYvF\n\tVWEdMX8Nh5p0738zX2nwtyPIwdNU","X-Google-Smtp-Source":"ABhQp+RhHu36cniA5ObJpKwjm6lQFxN1N5eCIGKhRK067oNjhHyXdp51R6p8eAUL8dKeXGQs+oeN4A==","X-Received":"by 10.101.90.133 with SMTP id c5mr8244000pgt.441.1509742619650; \n\tFri, 03 Nov 2017 13:56:59 -0700 (PDT)","From":"Jakub Kicinski <jakub.kicinski@netronome.com>","To":"netdev@vger.kernel.org","Cc":"oss-drivers@netronome.com, alexei.starovoitov@gmail.com,\n\tdaniel@iogearbox.net, Jakub Kicinski <jakub.kicinski@netronome.com>","Subject":"[PATCH net-next v2 15/15] bpf: remove old offload/analyzer","Date":"Fri,  3 Nov 2017 13:56:30 -0700","Message-Id":"<20171103205630.1083-16-jakub.kicinski@netronome.com>","X-Mailer":"git-send-email 2.14.1","In-Reply-To":"<20171103205630.1083-1-jakub.kicinski@netronome.com>","References":"<20171103205630.1083-1-jakub.kicinski@netronome.com>","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"Thanks to the ability to load a program for a specific device,\nrunning verifier twice is no longer needed.\n\nSigned-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>\nReviewed-by: Quentin Monnet <quentin.monnet@netronome.com>\n---\n include/linux/bpf_verifier.h |  5 ---\n kernel/bpf/verifier.c        | 75 --------------------------------------------\n net/core/filter.c            | 42 -------------------------\n 3 files changed, 122 deletions(-)","diff":"diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h\nindex e45011dbc02d..07b96aaca256 100644\n--- a/include/linux/bpf_verifier.h\n+++ b/include/linux/bpf_verifier.h\n@@ -152,9 +152,7 @@ struct bpf_verifier_env {\n \tbool strict_alignment;\t\t/* perform strict pointer alignment checks */\n \tstruct bpf_verifier_state *cur_state; /* current verifier state */\n \tstruct bpf_verifier_state_list **explored_states; /* search pruning optimization */\n-\tconst struct bpf_ext_analyzer_ops *analyzer_ops; /* external analyzer ops */\n \tconst struct bpf_ext_analyzer_ops *dev_ops; /* device analyzer ops */\n-\tvoid *analyzer_priv; /* pointer to external analyzer's private data */\n \tstruct bpf_map *used_maps[MAX_USED_MAPS]; /* array of map's used by eBPF program */\n \tu32 used_map_cnt;\t\t/* number of used maps */\n \tu32 id_gen;\t\t\t/* used to generate unique reg IDs */\n@@ -179,7 +177,4 @@ int bpf_prog_offload_verifier_prep(struct bpf_verifier_env *env)\n }\n #endif\n \n-int bpf_analyzer(struct bpf_prog *prog, const struct bpf_ext_analyzer_ops *ops,\n-\t\t void *priv);\n-\n #endif /* _LINUX_BPF_VERIFIER_H */\ndiff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c\nindex 51aabb32ad67..add845fe788a 100644\n--- a/kernel/bpf/verifier.c\n+++ b/kernel/bpf/verifier.c\n@@ -949,9 +949,6 @@ static int check_ctx_access(struct bpf_verifier_env *env, int insn_idx, int off,\n \t\t */\n \t\t*reg_type = info.reg_type;\n \n-\t\tif (env->analyzer_ops)\n-\t\t\treturn 0;\n-\n \t\tenv->insn_aux_data[insn_idx].ctx_field_size = info.ctx_field_size;\n \t\t/* remember the offset of last byte accessed in ctx */\n \t\tif (env->prog->aux->max_ctx_offset < off + size)\n@@ -3736,9 +3733,6 @@ static int is_state_visited(struct bpf_verifier_env *env, int insn_idx)\n static int ext_analyzer_insn_hook(struct bpf_verifier_env *env,\n \t\t\t\t  int insn_idx, int prev_insn_idx)\n {\n-\tif (env->analyzer_ops && env->analyzer_ops->insn_hook)\n-\t\treturn env->analyzer_ops->insn_hook(env, insn_idx,\n-\t\t\t\t\t\t    prev_insn_idx);\n \tif (env->dev_ops && env->dev_ops->insn_hook)\n \t\treturn env->dev_ops->insn_hook(env, insn_idx, prev_insn_idx);\n \n@@ -4601,72 +4595,3 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr)\n \tkfree(env);\n \treturn ret;\n }\n-\n-static const struct bpf_verifier_ops * const bpf_analyzer_ops[] = {\n-#ifdef CONFIG_NET\n-\t[BPF_PROG_TYPE_XDP]\t\t= &xdp_analyzer_ops,\n-\t[BPF_PROG_TYPE_SCHED_CLS]\t= &tc_cls_act_analyzer_ops,\n-#endif\n-};\n-\n-int bpf_analyzer(struct bpf_prog *prog, const struct bpf_ext_analyzer_ops *ops,\n-\t\t void *priv)\n-{\n-\tstruct bpf_verifier_env *env;\n-\tint ret;\n-\n-\tif (prog->type >= ARRAY_SIZE(bpf_analyzer_ops) ||\n-\t    !bpf_analyzer_ops[prog->type])\n-\t\treturn -EOPNOTSUPP;\n-\n-\tenv = kzalloc(sizeof(struct bpf_verifier_env), GFP_KERNEL);\n-\tif (!env)\n-\t\treturn -ENOMEM;\n-\n-\tenv->insn_aux_data = vzalloc(sizeof(struct bpf_insn_aux_data) *\n-\t\t\t\t     prog->len);\n-\tret = -ENOMEM;\n-\tif (!env->insn_aux_data)\n-\t\tgoto err_free_env;\n-\tenv->prog = prog;\n-\tenv->ops = bpf_analyzer_ops[env->prog->type];\n-\tenv->analyzer_ops = ops;\n-\tenv->analyzer_priv = priv;\n-\n-\t/* grab the mutex to protect few globals used by verifier */\n-\tmutex_lock(&bpf_verifier_lock);\n-\n-\tenv->strict_alignment = false;\n-\tif (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS))\n-\t\tenv->strict_alignment = true;\n-\n-\tenv->explored_states = kcalloc(env->prog->len,\n-\t\t\t\t       sizeof(struct bpf_verifier_state_list *),\n-\t\t\t\t       GFP_KERNEL);\n-\tret = -ENOMEM;\n-\tif (!env->explored_states)\n-\t\tgoto skip_full_check;\n-\n-\tret = check_cfg(env);\n-\tif (ret < 0)\n-\t\tgoto skip_full_check;\n-\n-\tenv->allow_ptr_leaks = capable(CAP_SYS_ADMIN);\n-\n-\tret = do_check(env);\n-\tif (env->cur_state) {\n-\t\tfree_verifier_state(env->cur_state, true);\n-\t\tenv->cur_state = NULL;\n-\t}\n-\n-skip_full_check:\n-\twhile (!pop_stack(env, NULL, NULL));\n-\tfree_states(env);\n-\n-\tmutex_unlock(&bpf_verifier_lock);\n-\tvfree(env->insn_aux_data);\n-err_free_env:\n-\tkfree(env);\n-\treturn ret;\n-}\n-EXPORT_SYMBOL_GPL(bpf_analyzer);\ndiff --git a/net/core/filter.c b/net/core/filter.c\nindex a0112168d6f9..1afa17935954 100644\n--- a/net/core/filter.c\n+++ b/net/core/filter.c\n@@ -3777,25 +3777,6 @@ static bool tc_cls_act_is_valid_access(int off, int size,\n \treturn bpf_skb_is_valid_access(off, size, type, info);\n }\n \n-static bool\n-tc_cls_act_is_valid_access_analyzer(int off, int size,\n-\t\t\t\t    enum bpf_access_type type,\n-\t\t\t\t    struct bpf_insn_access_aux *info)\n-{\n-\tswitch (off) {\n-\tcase offsetof(struct sk_buff, len):\n-\t\treturn true;\n-\tcase offsetof(struct sk_buff, data):\n-\t\tinfo->reg_type = PTR_TO_PACKET;\n-\t\treturn true;\n-\tcase offsetof(struct sk_buff, cb) +\n-\t     offsetof(struct bpf_skb_data_end, data_end):\n-\t\tinfo->reg_type = PTR_TO_PACKET_END;\n-\t\treturn true;\n-\t}\n-\treturn false;\n-}\n-\n static bool __is_valid_xdp_access(int off, int size)\n {\n \tif (off < 0 || off >= sizeof(struct xdp_md))\n@@ -3830,21 +3811,6 @@ static bool xdp_is_valid_access(int off, int size,\n \treturn __is_valid_xdp_access(off, size);\n }\n \n-static bool xdp_is_valid_access_analyzer(int off, int size,\n-\t\t\t\t\t enum bpf_access_type type,\n-\t\t\t\t\t struct bpf_insn_access_aux *info)\n-{\n-\tswitch (off) {\n-\tcase offsetof(struct xdp_buff, data):\n-\t\tinfo->reg_type = PTR_TO_PACKET;\n-\t\treturn true;\n-\tcase offsetof(struct xdp_buff, data_end):\n-\t\tinfo->reg_type = PTR_TO_PACKET_END;\n-\t\treturn true;\n-\t}\n-\treturn false;\n-}\n-\n void bpf_warn_invalid_xdp_action(u32 act)\n {\n \tconst u32 act_max = XDP_REDIRECT;\n@@ -4516,10 +4482,6 @@ const struct bpf_verifier_ops tc_cls_act_verifier_ops = {\n \t.gen_prologue\t\t= tc_cls_act_prologue,\n };\n \n-const struct bpf_verifier_ops tc_cls_act_analyzer_ops = {\n-\t.is_valid_access\t= tc_cls_act_is_valid_access_analyzer,\n-};\n-\n const struct bpf_prog_ops tc_cls_act_prog_ops = {\n \t.test_run\t\t= bpf_prog_test_run_skb,\n };\n@@ -4530,10 +4492,6 @@ const struct bpf_verifier_ops xdp_verifier_ops = {\n \t.convert_ctx_access\t= xdp_convert_ctx_access,\n };\n \n-const struct bpf_verifier_ops xdp_analyzer_ops = {\n-\t.is_valid_access\t= xdp_is_valid_access_analyzer,\n-};\n-\n const struct bpf_prog_ops xdp_prog_ops = {\n \t.test_run\t\t= bpf_prog_test_run_xdp,\n };\n","prefixes":["net-next","v2","15/15"]}