linux/kernel/bpf
Alexei Starovoitov a1854d6ac0 bpf: fix BPF_MAP_LOOKUP_ELEM command return code
fix errno of BPF_MAP_LOOKUP_ELEM command as bpf manpage
described it in commit b4fc1a460f30("Merge branch 'bpf-next'"):
-----
BPF_MAP_LOOKUP_ELEM
    int bpf_lookup_elem(int fd, void *key, void *value)
    {
        union bpf_attr attr = {
            .map_fd = fd,
            .key = ptr_to_u64(key),
            .value = ptr_to_u64(value),
        };

        return bpf(BPF_MAP_LOOKUP_ELEM, &attr, sizeof(attr));
    }
    bpf() syscall looks up an element with given key in  a  map  fd.
    If  element  is found it returns zero and stores element's value
    into value.  If element is not found  it  returns  -1  and  sets
    errno to ENOENT.

and further down in manpage:

   ENOENT For BPF_MAP_LOOKUP_ELEM or BPF_MAP_DELETE_ELEM,  indicates  that
          element with given key was not found.
-----

In general all BPF commands return ENOENT when map element is not found
(including BPF_MAP_GET_NEXT_KEY and BPF_MAP_UPDATE_ELEM with
 flags == BPF_MAP_UPDATE_ONLY)

Subsequent patch adds a testsuite to check return values for all of
these combinations.

Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-11-18 13:43:59 -05:00
..
arraymap.c bpf: add array type of eBPF maps 2014-11-18 13:43:59 -05:00
core.c bpf: split eBPF out of NET 2014-10-27 19:09:59 -04:00
hashtab.c bpf: add hashtable type of eBPF maps 2014-11-18 13:43:25 -05:00
Makefile bpf: add array type of eBPF maps 2014-11-18 13:43:59 -05:00
syscall.c bpf: fix BPF_MAP_LOOKUP_ELEM command return code 2014-11-18 13:43:59 -05:00
test_stub.c bpf: mini eBPF library, test stubs and verifier testsuite 2014-09-26 15:05:15 -04:00
verifier.c bpf: reduce verifier memory consumption 2014-10-30 15:44:37 -04:00