]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Support sk lookup in netns with id 0
authorJoe Stringer <joe@wand.net.nz>
Fri, 30 Nov 2018 23:32:20 +0000 (15:32 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 1 Dec 2018 01:17:38 +0000 (17:17 -0800)
commit4226decd06fd260667a7991e45e50d949c0a82c3
treefef0cee90ee0a015b24c8916c6ccb3983b47d688
parent8822b3d09ead3a3b5ce9f36177d4eeab265d6261
bpf: Support sk lookup in netns with id 0

David Ahern and Nicolas Dichtel report that the handling of the netns id
0 is incorrect for the BPF socket lookup helpers: rather than finding
the netns with id 0, it is resolving to the current netns. This renders
the netns_id 0 inaccessible.

To fix this, adjust the API for the netns to treat all negative s32
values as a lookup in the current netns (including u64 values which when
truncated to s32 become negative), while any values with a positive
value in the signed 32-bit integer space would result in a lookup for a
socket in the netns corresponding to that id. As before, if the netns
with that ID does not exist, no socket will be found. Any netns outside
of these ranges will fail to find a corresponding socket, as those
values are reserved for future usage.

Signed-off-by: Joe Stringer <joe@wand.net.nz>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Joey Pabalinas <joeypabalinas@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/uapi/linux/bpf.h
net/core/filter.c
tools/include/uapi/linux/bpf.h
tools/testing/selftests/bpf/bpf_helpers.h
tools/testing/selftests/bpf/test_sk_lookup_kern.c