]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
bpf: expose bpf_parse_common() and bpf_load_common()
authorJakub Kicinski <jakub.kicinski@netronome.com>
Fri, 24 Nov 2017 02:12:03 +0000 (18:12 -0800)
committerStephen Hemminger <stephen@networkplumber.org>
Sun, 26 Nov 2017 19:57:57 +0000 (11:57 -0800)
Expose bpf_parse_common() and bpf_load_common() functions
for those users who may want to modify the parameters to
load after parsing is done.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
include/bpf_util.h
lib/bpf.c

index da2dee8bb3aa4dc8dfa689a72befa624383951c3..f6371994252e0b675e7355a1f8d61d7e36eb0b09 100644 (file)
@@ -259,6 +259,9 @@ struct bpf_cfg_in {
                .off   = 0,                                     \
                .imm   = 0 })
 
+int bpf_parse_common(struct bpf_cfg_in *cfg, const struct bpf_cfg_ops *ops);
+int bpf_load_common(struct bpf_cfg_in *cfg, const struct bpf_cfg_ops *ops,
+                   void *nl);
 int bpf_parse_and_load_common(struct bpf_cfg_in *cfg,
                              const struct bpf_cfg_ops *ops, void *nl);
 
index 9a0867124fc4fcbf049d0423e2f2c51ff1654883..f25f7016d10f3cd0d7fcd02bae25eda7dac32a07 100644 (file)
--- a/lib/bpf.c
+++ b/lib/bpf.c
@@ -926,17 +926,12 @@ static int bpf_do_load(struct bpf_cfg_in *cfg)
        return 0;
 }
 
-static int bpf_parse_opt_tbl(struct bpf_cfg_in *cfg,
-                            const struct bpf_cfg_ops *ops, void *nl,
-                            const bool *opt_tbl)
+int bpf_load_common(struct bpf_cfg_in *cfg, const struct bpf_cfg_ops *ops,
+                   void *nl)
 {
        char annotation[256];
        int ret;
 
-       ret = bpf_do_parse(cfg, opt_tbl);
-       if (ret < 0)
-               return ret;
-
        ret = bpf_do_load(cfg);
        if (ret < 0)
                return ret;
@@ -953,8 +948,7 @@ static int bpf_parse_opt_tbl(struct bpf_cfg_in *cfg,
        return 0;
 }
 
-int bpf_parse_and_load_common(struct bpf_cfg_in *cfg,
-                             const struct bpf_cfg_ops *ops, void *nl)
+int bpf_parse_common(struct bpf_cfg_in *cfg, const struct bpf_cfg_ops *ops)
 {
        bool opt_tbl[BPF_MODE_MAX] = {};
 
@@ -968,7 +962,19 @@ int bpf_parse_and_load_common(struct bpf_cfg_in *cfg,
                opt_tbl[EBPF_PINNED]   = true;
        }
 
-       return bpf_parse_opt_tbl(cfg, ops, nl, opt_tbl);
+       return bpf_do_parse(cfg, opt_tbl);
+}
+
+int bpf_parse_and_load_common(struct bpf_cfg_in *cfg,
+                             const struct bpf_cfg_ops *ops, void *nl)
+{
+       int ret;
+
+       ret = bpf_parse_common(cfg, ops);
+       if (ret < 0)
+               return ret;
+
+       return bpf_load_common(cfg, ops, nl);
 }
 
 int bpf_graft_map(const char *map_path, uint32_t *key, int argc, char **argv)