From: Alexei Starovoitov <ast@plumgrid.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: Ingo Molnar <mingo@kernel.org>,
Andy Lutomirski <luto@amacapital.net>,
Daniel Borkmann <dborkman@redhat.com>,
Hannes Frederic Sowa <hannes@stressinduktion.org>,
Eric Dumazet <edumazet@google.com>,
linux-api@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH net-next 4/7] bpf: fix BPF_MAP_LOOKUP_ELEM command return code
Date: Mon, 3 Nov 2014 18:54:13 -0800 [thread overview]
Message-ID: <1415069656-14138-5-git-send-email-ast@plumgrid.com> (raw)
In-Reply-To: <1415069656-14138-1-git-send-email-ast@plumgrid.com>
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>
---
I don't think this patch is needed for 'net', since 'net' has syscall shell
only. Actual map types and their implementations are being introduced by
this set of patches.
kernel/bpf/syscall.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index c0d03bf317a2..088ac0b1b106 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -169,7 +169,7 @@ static int map_lookup_elem(union bpf_attr *attr)
if (copy_from_user(key, ukey, map->key_size) != 0)
goto free_key;
- err = -ESRCH;
+ err = -ENOENT;
rcu_read_lock();
value = map->ops->map_lookup_elem(map, key);
if (!value)
--
1.7.9.5
next prev parent reply other threads:[~2014-11-04 2:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-04 2:54 [PATCH net-next 0/7] implementation of eBPF maps Alexei Starovoitov
2014-11-04 2:54 ` [PATCH net-next 1/7] bpf: add 'flags' attribute to BPF_MAP_UPDATE_ELEM command Alexei Starovoitov
2014-11-04 9:25 ` Daniel Borkmann
2014-11-04 23:04 ` Alexei Starovoitov
2014-11-05 14:57 ` Daniel Borkmann
2014-11-06 17:39 ` Alexei Starovoitov
2014-11-04 2:54 ` [PATCH net-next 2/7] bpf: add hashtable type of eBPF maps Alexei Starovoitov
2014-11-04 2:54 ` [PATCH net-next 3/7] bpf: add array " Alexei Starovoitov
2014-11-04 9:58 ` Daniel Borkmann
2014-11-04 23:14 ` Alexei Starovoitov
2014-11-04 2:54 ` Alexei Starovoitov [this message]
2014-11-04 2:54 ` [PATCH net-next 5/7] bpf: add a testsuite for " Alexei Starovoitov
2014-11-04 2:54 ` [PATCH net-next 6/7] bpf: allow eBPF programs to use maps Alexei Starovoitov
2014-11-04 9:50 ` Daniel Borkmann
2014-11-04 23:08 ` Alexei Starovoitov
2014-11-04 2:54 ` [PATCH net-next 7/7] bpf: remove test map scaffolding and use proper types Alexei Starovoitov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1415069656-14138-5-git-send-email-ast@plumgrid.com \
--to=ast@plumgrid.com \
--cc=davem@davemloft.net \
--cc=dborkman@redhat.com \
--cc=edumazet@google.com \
--cc=hannes@stressinduktion.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).