]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
bpf: export bpf_prog_load
authorDavid Ahern <dsa@cumulusnetworks.com>
Mon, 12 Dec 2016 00:53:09 +0000 (16:53 -0800)
committerStephen Hemminger <stephen@networkplumber.org>
Tue, 13 Dec 2016 18:20:15 +0000 (10:20 -0800)
Code move only; no functional change intended.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
include/bpf_util.h
lib/bpf.c

index b038379684a8afb423dd6a0557467dad435428ec..726e34777755e69c6aefe2c44e0cb3aedd7068a2 100644 (file)
@@ -75,6 +75,10 @@ int bpf_trace_pipe(void);
 
 void bpf_print_ops(FILE *f, struct rtattr *bpf_ops, __u16 len);
 
+int bpf_prog_load(enum bpf_prog_type type, const struct bpf_insn *insns,
+                 size_t size_insns, const char *license, char *log,
+                 size_t size_log);
+
 int bpf_prog_attach_fd(int prog_fd, int target_fd, enum bpf_attach_type type);
 int bpf_prog_detach_fd(int target_fd, enum bpf_attach_type type);
 
index 006db9a869bb94bd321b54fcc752a94bf366ba80..64e199b3236f76eeb46a819550e8cf5ff3067050 100644 (file)
--- a/lib/bpf.c
+++ b/lib/bpf.c
@@ -889,6 +889,26 @@ int bpf_prog_detach_fd(int target_fd, enum bpf_attach_type type)
        return bpf(BPF_PROG_DETACH, &attr, sizeof(attr));
 }
 
+int bpf_prog_load(enum bpf_prog_type type, const struct bpf_insn *insns,
+                 size_t size_insns, const char *license, char *log,
+                 size_t size_log)
+{
+       union bpf_attr attr = {};
+
+       attr.prog_type = type;
+       attr.insns = bpf_ptr_to_u64(insns);
+       attr.insn_cnt = size_insns / sizeof(struct bpf_insn);
+       attr.license = bpf_ptr_to_u64(license);
+
+       if (size_log > 0) {
+               attr.log_buf = bpf_ptr_to_u64(log);
+               attr.log_size = size_log;
+               attr.log_level = 1;
+       }
+
+       return bpf(BPF_PROG_LOAD, &attr, sizeof(attr));
+}
+
 #ifdef HAVE_ELF
 struct bpf_elf_prog {
        enum bpf_prog_type      type;
@@ -1006,26 +1026,6 @@ static int bpf_map_create(enum bpf_map_type type, uint32_t size_key,
        return bpf(BPF_MAP_CREATE, &attr, sizeof(attr));
 }
 
-static int bpf_prog_load(enum bpf_prog_type type, const struct bpf_insn *insns,
-                        size_t size_insns, const char *license, char *log,
-                        size_t size_log)
-{
-       union bpf_attr attr = {};
-
-       attr.prog_type = type;
-       attr.insns = bpf_ptr_to_u64(insns);
-       attr.insn_cnt = size_insns / sizeof(struct bpf_insn);
-       attr.license = bpf_ptr_to_u64(license);
-
-       if (size_log > 0) {
-               attr.log_buf = bpf_ptr_to_u64(log);
-               attr.log_size = size_log;
-               attr.log_level = 1;
-       }
-
-       return bpf(BPF_PROG_LOAD, &attr, sizeof(attr));
-}
-
 static int bpf_obj_pin(int fd, const char *pathname)
 {
        union bpf_attr attr = {};