bpf: introduce BPF syscall and maps
authorAlexei Starovoitov <ast@plumgrid.com>
Fri, 26 Sep 2014 07:16:57 +0000 (00:16 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 26 Sep 2014 19:05:14 +0000 (15:05 -0400)
commit99c55f7d47c0dc6fc64729f37bf435abf43f4c60
tree12f09f26bee9813ae33cfc195582c41e94b2e4e9
parent4a8e320c929991c9480a7b936512c57ea02d87b2
bpf: introduce BPF syscall and maps

BPF syscall is a multiplexor for a range of different operations on eBPF.
This patch introduces syscall with single command to create a map.
Next patch adds commands to access maps.

'maps' is a generic storage of different types for sharing data between kernel
and userspace.

Userspace example:
/* this syscall wrapper creates a map with given type and attributes
 * and returns map_fd on success.
 * use close(map_fd) to delete the map
 */
int bpf_create_map(enum bpf_map_type map_type, int key_size,
                   int value_size, int max_entries)
{
    union bpf_attr attr = {
        .map_type = map_type,
        .key_size = key_size,
        .value_size = value_size,
        .max_entries = max_entries
    };

    return bpf(BPF_MAP_CREATE, &attr, sizeof(attr));
}

'union bpf_attr' is backwards compatible with future extensions.

More details in Documentation/networking/filter.txt and in manpage

Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Documentation/networking/filter.txt
include/linux/bpf.h [new file with mode: 0644]
include/uapi/linux/bpf.h
kernel/bpf/Makefile
kernel/bpf/syscall.c [new file with mode: 0644]
This page took 0.035899 seconds and 5 git commands to generate.