[PATCH net] ipv4: fix memory leaks in udp_sendmsg, ping_v4_sendmsg

2018-05-10 Thread Andrey Ignatov
() or ping_v4_sendmsg() IP options have to be freed if they were allocated previously. Add label so that future callers (if any) can use it instead of kfree() before return that is easy to forget. Fixes: c319b4d76b9e (net: ipv4: add IPPROTO_ICMP socket kind) Signed-off-by: Andrey Ignatov <r...@fb.

[PATCH v2 bpf-next 3/5] libbpf: Support guessing sendmsg{4,6} progs

2018-05-22 Thread Andrey Ignatov
libbpf can guess prog type and expected attach type based on section name. Add hints for "cgroup/sendmsg4" and "cgroup/sendmsg6" section names. Signed-off-by: Andrey Ignatov <r...@fb.com> Acked-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Martin KaFai Lau &

[PATCH v2 bpf-next 5/5] selftests/bpf: Selftest for sys_sendmsg hooks

2018-05-22 Thread Andrey Ignatov
(asm) .. [PASS] Test case: sendmsg6: rewrite IP & port (C) .. [PASS] Test case: sendmsg6: IPv4-mapped IPv6 .. [PASS] Test case: sendmsg6: deny call .. [PASS] Summary: 27 PASSED, 0 FAILED Signed-off-by: Andrey Ignatov <r...@fb.com> Acked-by: Alexei Starovoitov <a...@kernel.org

[PATCH v2 bpf-next 1/5] bpf: Hooks for sys_sendmsg

2018-05-22 Thread Andrey Ignatov
`; * `msg_src_ip4` to set source IPv4 for UDPv4; * `msg_src_ip6` to set source IPv6 for UDPv6. Signed-off-by: Andrey Ignatov <r...@fb.com> Acked-by: Alexei Starovoitov <a...@kernel.org> --- include/linux/bpf-cgroup.h | 23 +-- include/linux/filter.h | 1 + include/uapi/linux/

[PATCH v2 bpf-next 4/5] selftests/bpf: Prepare test_sock_addr for extension

2018-05-22 Thread Andrey Ignatov
rite IP & TCP port .. [PASS] Test case: connect6: rewrite IP & UDP port .. [PASS] Summary: 16 PASSED, 0 FAILED (stderr contains errors from libbpf when testing load/attach with invalid arguments) Signed-off-by: Andrey Ignatov <r...@fb.com> Acked-by: Alexei Starovoitov <a..

[PATCH v2 bpf-next 0/5] bpf: Hooks for sys_sendmsg

2018-05-22 Thread Andrey Ignatov
lar to sys_connect hooks, sys_sendmsg ones can be used to make system calls such as sendmsg(2) and sendto(2) return EPERM. Please see patch 0001 for more details. Andrey Ignatov (5): bpf: Hooks for sys_sendmsg bpf: Sync bpf.h to tools/ libbpf: Support guessing sendmsg{4,6} progs selftests/bpf: Prep

[PATCH v2 bpf-next 2/5] bpf: Sync bpf.h to tools/

2018-05-22 Thread Andrey Ignatov
Sync new `BPF_CGROUP_UDP4_SENDMSG` and `BPF_CGROUP_UDP6_SENDMSG` attach types to tools/. Signed-off-by: Andrey Ignatov <r...@fb.com> Acked-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Martin KaFai Lau <ka...@fb.com> --- tools/include/uapi/linux/bpf.h | 8

[PATCH v4 bpf-next 2/6] bpf: Hooks for sys_sendmsg

2018-05-25 Thread Andrey Ignatov
`; * `msg_src_ip4` to set source IPv4 for UDPv4; * `msg_src_ip6` to set source IPv6 for UDPv6. Signed-off-by: Andrey Ignatov <r...@fb.com> Acked-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Martin KaFai Lau <ka...@fb.com> --- include/linux/bpf-cgroup.h | 23 +-- incl

[PATCH v4 bpf-next 0/6] bpf: Hooks for sys_sendmsg

2018-05-25 Thread Andrey Ignatov
e details. Andrey Ignatov (6): bpf: Define cgroup_bpf_enabled for CONFIG_CGROUP_BPF=n bpf: Hooks for sys_sendmsg bpf: Sync bpf.h to tools/ libbpf: Support guessing sendmsg{4,6} progs selftests/bpf: Prepare test_sock_addr for extension selftests/bpf: Selftest for sys_sendmsg hooks incl

[PATCH v4 bpf-next 3/6] bpf: Sync bpf.h to tools/

2018-05-25 Thread Andrey Ignatov
Sync new `BPF_CGROUP_UDP4_SENDMSG` and `BPF_CGROUP_UDP6_SENDMSG` attach types to tools/. Signed-off-by: Andrey Ignatov <r...@fb.com> Acked-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Martin KaFai Lau <ka...@fb.com> --- tools/include/uapi/linux/bpf.h | 8

[PATCH v4 bpf-next 5/6] selftests/bpf: Prepare test_sock_addr for extension

2018-05-25 Thread Andrey Ignatov
rite IP & TCP port .. [PASS] Test case: connect6: rewrite IP & UDP port .. [PASS] Summary: 16 PASSED, 0 FAILED (stderr contains errors from libbpf when testing load/attach with invalid arguments) Signed-off-by: Andrey Ignatov <r...@fb.com> Acked-by: Alexei Starovoitov <a..

[PATCH v4 bpf-next 6/6] selftests/bpf: Selftest for sys_sendmsg hooks

2018-05-25 Thread Andrey Ignatov
(asm) .. [PASS] Test case: sendmsg6: rewrite IP & port (C) .. [PASS] Test case: sendmsg6: IPv4-mapped IPv6 .. [PASS] Test case: sendmsg6: deny call .. [PASS] Summary: 27 PASSED, 0 FAILED Signed-off-by: Andrey Ignatov <r...@fb.com> Acked-by: Alexei Starovoitov <a...@kernel.org

[PATCH v4 bpf-next 1/6] bpf: Define cgroup_bpf_enabled for CONFIG_CGROUP_BPF=n

2018-05-25 Thread Andrey Ignatov
BPF_CGROUP_RUN_PROG_* macros that defined for both states of CONFIG_CGROUP_BPF. Signed-off-by: Andrey Ignatov <r...@fb.com> --- include/linux/bpf-cgroup.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/bpf-cgroup.h b/include/linux/bpf-cgroup.h index 30d15e6..de8e89a

[PATCH v4 bpf-next 4/6] libbpf: Support guessing sendmsg{4,6} progs

2018-05-25 Thread Andrey Ignatov
libbpf can guess prog type and expected attach type based on section name. Add hints for "cgroup/sendmsg4" and "cgroup/sendmsg6" section names. Signed-off-by: Andrey Ignatov <r...@fb.com> Acked-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Martin KaFai Lau &

[PATCH bpf-next] libbpf: Install btf.h with libbpf

2018-05-25 Thread Andrey Ignatov
install_headers target should contain all headers that are part of libbpf. Add missing btf.h Signed-off-by: Andrey Ignatov <r...@fb.com> --- tools/lib/bpf/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile index f3fab4a..5390e77

Re: [PATCH v2 bpf-next 1/5] bpf: Hooks for sys_sendmsg

2018-05-24 Thread Andrey Ignatov
Daniel Borkmann <dan...@iogearbox.net> [Thu, 2018-05-24 18:00 -0700]: > On 05/23/2018 01:40 AM, Andrey Ignatov wrote: > [...] > > diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c > > index ff4d4ba..a1f9ba2 100644 > > --- a/net/ipv4/udp.c > > +++ b/net/ipv4/udp.c >

[PATCH v3 bpf-next 5/5] selftests/bpf: Selftest for sys_sendmsg hooks

2018-05-24 Thread Andrey Ignatov
(asm) .. [PASS] Test case: sendmsg6: rewrite IP & port (C) .. [PASS] Test case: sendmsg6: IPv4-mapped IPv6 .. [PASS] Test case: sendmsg6: deny call .. [PASS] Summary: 27 PASSED, 0 FAILED Signed-off-by: Andrey Ignatov <r...@fb.com> Acked-by: Alexei Starovoitov <a...@kernel.org

[PATCH v3 bpf-next 0/5] bpf: Hooks for sys_sendmsg

2018-05-24 Thread Andrey Ignatov
ed UDP is handled by sys_connect hooks, unconnected by sys_sendmsg ones. Similar to sys_connect hooks, sys_sendmsg ones can be used to make system calls such as sendmsg(2) and sendto(2) return EPERM. Please see patch 0001 for more details. Andrey Ignatov (5): bpf: Hooks for sys_sendmsg bpf

[PATCH v3 bpf-next 1/5] bpf: Hooks for sys_sendmsg

2018-05-24 Thread Andrey Ignatov
`; * `msg_src_ip4` to set source IPv4 for UDPv4; * `msg_src_ip6` to set source IPv6 for UDPv6. Signed-off-by: Andrey Ignatov <r...@fb.com> Acked-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Martin KaFai Lau <ka...@fb.com> --- include/linux/bpf-cgroup.h | 23 +-- incl

[PATCH v3 bpf-next 3/5] libbpf: Support guessing sendmsg{4,6} progs

2018-05-24 Thread Andrey Ignatov
libbpf can guess prog type and expected attach type based on section name. Add hints for "cgroup/sendmsg4" and "cgroup/sendmsg6" section names. Signed-off-by: Andrey Ignatov <r...@fb.com> Acked-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Martin KaFai Lau &

[PATCH v3 bpf-next 4/5] selftests/bpf: Prepare test_sock_addr for extension

2018-05-24 Thread Andrey Ignatov
rite IP & TCP port .. [PASS] Test case: connect6: rewrite IP & UDP port .. [PASS] Summary: 16 PASSED, 0 FAILED (stderr contains errors from libbpf when testing load/attach with invalid arguments) Signed-off-by: Andrey Ignatov <r...@fb.com> Acked-by: Alexei Starovoitov <a..

[PATCH v3 bpf-next 2/5] bpf: Sync bpf.h to tools/

2018-05-24 Thread Andrey Ignatov
Sync new `BPF_CGROUP_UDP4_SENDMSG` and `BPF_CGROUP_UDP6_SENDMSG` attach types to tools/. Signed-off-by: Andrey Ignatov <r...@fb.com> Acked-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Martin KaFai Lau <ka...@fb.com> --- tools/include/uapi/linux/bpf.h | 8

Re: [PATCH bpf-next 1/5] bpf: Hooks for sys_sendmsg

2018-05-22 Thread Andrey Ignatov
Martin KaFai Lau <ka...@fb.com> [Mon, 2018-05-21 16:17 -0700]: > On Fri, May 18, 2018 at 07:21:09PM -0700, Andrey Ignatov wrote: [...] > > diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c > > index 2839c1b..6f580ea 100644 > > --- a/net/ipv6/udp.c > > +++ b/net/ipv6/udp

[PATCH bpf-next 5/5] selftests/bpf: Selftest for sys_sendmsg hooks

2018-05-18 Thread Andrey Ignatov
(asm) .. [PASS] Test case: sendmsg6: rewrite IP & port (C) .. [PASS] Test case: sendmsg6: deny call .. [PASS] Summary: 26 PASSED, 0 FAILED Signed-off-by: Andrey Ignatov <r...@fb.com> Acked-by: Alexei Starovoitov <a...@kernel.org> --- tools/testing/selftests/bpf/Makefile

[PATCH bpf-next 3/5] libbpf: Support guessing sendmsg{4,6} progs

2018-05-18 Thread Andrey Ignatov
libbpf can guess prog type and expected attach type based on section name. Add hints for "cgroup/sendmsg4" and "cgroup/sendmsg6" section names. Signed-off-by: Andrey Ignatov <r...@fb.com> Acked-by: Alexei Starovoitov <a...@kernel.org> --- tools/lib/bpf/li

[PATCH bpf-next 0/5] bpf: Hooks for sys_sendmsg

2018-05-18 Thread Andrey Ignatov
. This makes UDP support complete: connected UDP is handled by sys_connect hooks, unconnected by sys_sendmsg ones. Similar to sys_connect hooks, sys_sendmsg ones can be used to make system calls such as sendmsg(2) and sendto(2) return EPERM. Please see patch 0001 for more details. Andrey Ignatov (5

[PATCH bpf-next 1/5] bpf: Hooks for sys_sendmsg

2018-05-18 Thread Andrey Ignatov
`; * `msg_src_ip4` to set source IPv4 for UDPv4; * `msg_src_ip6` to set source IPv6 for UDPv6. Signed-off-by: Andrey Ignatov <r...@fb.com> Acked-by: Alexei Starovoitov <a...@kernel.org> --- include/linux/bpf-cgroup.h | 23 +-- include/linux/filter.h | 1 + include/uapi/linux/

[PATCH bpf-next 4/5] selftests/bpf: Prepare test_sock_addr for extension

2018-05-18 Thread Andrey Ignatov
rite IP & TCP port .. [PASS] Test case: connect6: rewrite IP & UDP port .. [PASS] Summary: 16 PASSED, 0 FAILED (stderr contains errors from libbpf when testing load/attach with invalid arguments) Signed-off-by: Andrey Ignatov <r...@fb.com> Acked-by: Alexei Starovoitov <a...@

[PATCH bpf-next 2/5] bpf: Sync bpf.h to tools/

2018-05-18 Thread Andrey Ignatov
Sync new `BPF_CGROUP_UDP4_SENDMSG` and `BPF_CGROUP_UDP6_SENDMSG` attach types to tools/. Signed-off-by: Andrey Ignatov <r...@fb.com> Acked-by: Alexei Starovoitov <a...@kernel.org> --- tools/include/uapi/linux/bpf.h | 8 1 file changed, 8 insertions(+) diff --git a/tools/

[PATCH bpf-next] bpftool: Support sendmsg{4,6} attach types

2018-05-29 Thread Andrey Ignatov
Add support for recently added BPF_CGROUP_UDP4_SENDMSG and BPF_CGROUP_UDP6_SENDMSG attach types to bpftool, update documentation and bash completion. Signed-off-by: Andrey Ignatov --- I'm not sure about "since 4.18" in Documentation part. I can follow-up when the next kernel versio

[PATCH bpf-next] selftests/bpf: Test sys_connect BPF hooks with TFO

2018-06-26 Thread Andrey Ignatov
is already covered by BPF_CGROUP_INET{4,6}_CONNECT and the only missing piece is selftest. The patch adds selftest for TFO. Signed-off-by: Andrey Ignatov --- tools/testing/selftests/bpf/test_sock_addr.c | 37 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/tools/testing

[PATCH bpf-next 2/2] bpf: Sync bpf.h to tools/

2018-04-28 Thread Andrey Ignatov
The patch syncs bpf.h to tools/. Signed-off-by: Andrey Ignatov <r...@fb.com> --- tools/include/uapi/linux/bpf.h | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index da77a93..730f448

[PATCH bpf-next 1/2] bpf: Fix helpers ctx struct types in uapi doc

2018-04-28 Thread Andrey Ignatov
to `_kern` structures in BPF helpers description by corresponding user visible structures. Signed-off-by: Andrey Ignatov <r...@fb.com> --- include/uapi/linux/bpf.h | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux

[PATCH bpf-next 0/2] Fix BPF helpers documentation

2018-04-28 Thread Andrey Ignatov
BPF helpers documentation in UAPI refers to kernel ctx structures when it has to refer to user visible ones. Fix it. Andrey Ignatov (2): bpf: Fix helpers ctx struct types in uapi doc bpf: Sync bpf.h to tools/ include/uapi/linux/bpf.h | 12 ++-- tools/include/uapi/linux/bpf.h

[PATCH bpf-next 0/4] Support bpf_get_socket_cookie in more prog types

2018-07-30 Thread Andrey Ignatov
. Patch 4 adds selftest for new functionality. Andrey Ignatov (4): bpf: Support bpf_get_socket_cookie in more prog types bpf: Sync bpf.h to tools/ selftests/bpf: Add bpf_get_socket_cookie to bpf_helpers.h selftests/bpf: Test for get_socket_cookie include/uapi/linux/bpf.h

[PATCH bpf-next 1/4] bpf: Support bpf_get_socket_cookie in more prog types

2018-07-30 Thread Andrey Ignatov
bpf_get_socket_cookie() but adds support to this helper to accept `struct bpf_sock_addr` and `struct bpf_sock_ops`. Documentation in bpf.h is changed in a way that should not break automatic generation of markdown. Signed-off-by: Andrey Ignatov --- include/uapi/linux/bpf.h | 14 ++ net

[PATCH bpf-next 3/4] selftests/bpf: Add bpf_get_socket_cookie to bpf_helpers.h

2018-07-30 Thread Andrey Ignatov
Add missing helper to bpf_helpers.h that is used in tests and samples. Signed-off-by: Andrey Ignatov --- tools/testing/selftests/bpf/bpf_helpers.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/bpf/bpf_helpers.h b/tools/testing/selftests/bpf/bpf_helpers.h index

[PATCH bpf-next 2/4] bpf: Sync bpf.h to tools/

2018-07-30 Thread Andrey Ignatov
Sync bpf_get_socket_cookie() related bpf UAPI changes to tools/. Signed-off-by: Andrey Ignatov --- tools/include/uapi/linux/bpf.h | 14 ++ 1 file changed, 14 insertions(+) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index 870113916cac..0ebaaf7f3568

[PATCH bpf-next 4/4] selftests/bpf: Test for get_socket_cookie

2018-07-30 Thread Andrey Ignatov
y the test verifies the value in the map. Signed-off-by: Andrey Ignatov --- tools/testing/selftests/bpf/Makefile | 6 +- .../selftests/bpf/socket_cookie_prog.c| 60 + .../selftests/bpf/test_socket_cookie.c| 249 ++ 3 files changed, 313 insert

[PATCH v2 bpf-next 2/4] bpf: Sync bpf.h to tools/

2018-07-30 Thread Andrey Ignatov
Sync bpf_get_socket_cookie() related bpf UAPI changes to tools/. Signed-off-by: Andrey Ignatov Acked-by: Yonghong Song --- tools/include/uapi/linux/bpf.h | 14 ++ 1 file changed, 14 insertions(+) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index

[PATCH v2 bpf-next 1/4] bpf: Support bpf_get_socket_cookie in more prog types

2018-07-30 Thread Andrey Ignatov
bpf_get_socket_cookie() but adds support to this helper to accept `struct bpf_sock_addr` and `struct bpf_sock_ops`. Documentation in bpf.h is changed in a way that should not break automatic generation of markdown. Signed-off-by: Andrey Ignatov Acked-by: Yonghong Song --- include/uapi/linux/bpf.h

[PATCH v2 bpf-next 0/4] Support bpf_get_socket_cookie in more prog types

2018-07-30 Thread Andrey Ignatov
ges to tools/. Patch 3 adds missing helper to bpf_helpers.h. Patch 4 adds selftest for new functionality. Andrey Ignatov (4): bpf: Support bpf_get_socket_cookie in more prog types bpf: Sync bpf.h to tools/ selftests/bpf: Add bpf_get_socket_cookie to bpf_helpers.h selftests/bpf: T

[PATCH v2 bpf-next 4/4] selftests/bpf: Test for get_socket_cookie

2018-07-30 Thread Andrey Ignatov
y the test verifies the value in the map. Signed-off-by: Andrey Ignatov --- tools/testing/selftests/bpf/Makefile | 6 +- .../selftests/bpf/socket_cookie_prog.c| 60 + .../selftests/bpf/test_socket_cookie.c| 225 ++ 3 files changed, 289 insert

[PATCH v2 bpf-next 3/4] selftests/bpf: Add bpf_get_socket_cookie to bpf_helpers.h

2018-07-30 Thread Andrey Ignatov
Add missing helper to bpf_helpers.h that is used in tests and samples. Signed-off-by: Andrey Ignatov Acked-by: Yonghong Song --- tools/testing/selftests/bpf/bpf_helpers.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/bpf/bpf_helpers.h b/tools/testing/selftests

Re: [PATCH bpf-next 4/4] selftests/bpf: Test for get_socket_cookie

2018-07-30 Thread Andrey Ignatov
Yonghong Song [Mon, 2018-07-30 16:59 -0700]: > > > On 7/30/18 9:04 AM, Andrey Ignatov wrote: > > Add test to use get_socket_cookie() from BPF programs of types > > BPF_PROG_TYPE_SOCK_OPS and BPF_PROG_TYPE_CGROUP_SOCK_ADDR. > > > > The test attaches two pr

[PATCH bpf-next 3/4] selftests/bpf: Add cgroup id helpers to bpf_helpers.h

2018-08-10 Thread Andrey Ignatov
Add bpf_skb_cgroup_id and bpf_skb_ancestor_cgroup_id helpers to bpf_helpers.h to use them in tests and samples. Signed-off-by: Andrey Ignatov --- tools/testing/selftests/bpf/bpf_helpers.h | 4 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/bpf/bpf_helpers.h b/tools

[PATCH bpf-next 4/4] selftests/bpf: Selftest for bpf_skb_ancestor_cgroup_id

2018-08-10 Thread Andrey Ignatov
: # ./test_skb_cgroup_id.sh Wait for testing link-local IP to become available ... OK Note: 8 bytes struct bpf_elf_map fixup performed due to size mismatch! [PASS] Signed-off-by: Andrey Ignatov --- tools/testing/selftests/bpf/Makefile | 9 +- .../selftests/bpf/test_skb_cgroup_id.sh | 61

[PATCH bpf-next 0/4] bpf_skb_ancestor_cgroup_id helper

2018-08-10 Thread Andrey Ignatov
with skb. Patch 0001 provides more details and describes use-cases. Patch 0002 syncs UAPI changes to tools/. Patch 0003 adds skb*cgroup_id helpers to bpf_helper.h header. Patch 0004 adds selftest for the new helper and is an example of usage. Andrey Ignatov (4): bpf: Introduce

[PATCH bpf-next 2/4] bpf: Sync bpf.h to tools/

2018-08-10 Thread Andrey Ignatov
Sync skb_ancestor_cgroup_id() related bpf UAPI changes to tools/. Signed-off-by: Andrey Ignatov --- tools/include/uapi/linux/bpf.h | 21 - 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index

[PATCH bpf-next 1/4] bpf: Introduce bpf_skb_ancestor_cgroup_id helper

2018-08-10 Thread Andrey Ignatov
's not obviously better). Format of return value of the new helper is same as that of bpf_skb_cgroup_id. Signed-off-by: Andrey Ignatov --- include/linux/cgroup.h | 30 ++ include/uapi/linux/bpf.h | 21 - net/core/filter.c| 28 ++

[PATCH v2 bpf-next 3/4] selftests/bpf: Add cgroup id helpers to bpf_helpers.h

2018-08-12 Thread Andrey Ignatov
Add bpf_skb_cgroup_id and bpf_skb_ancestor_cgroup_id helpers to bpf_helpers.h to use them in tests and samples. Signed-off-by: Andrey Ignatov --- tools/testing/selftests/bpf/bpf_helpers.h | 4 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/bpf/bpf_helpers.h b/tools

[PATCH v2 bpf-next 4/4] selftests/bpf: Selftest for bpf_skb_ancestor_cgroup_id

2018-08-12 Thread Andrey Ignatov
: # ./test_skb_cgroup_id.sh Wait for testing link-local IP to become available ... OK Note: 8 bytes struct bpf_elf_map fixup performed due to size mismatch! [PASS] Signed-off-by: Andrey Ignatov --- tools/testing/selftests/bpf/Makefile | 9 +- .../selftests/bpf/test_skb_cgroup_id.sh | 62

[PATCH v2 bpf-next 0/4] bpf_skb_ancestor_cgroup_id helper

2018-08-12 Thread Andrey Ignatov
per and is an example of usage. Andrey Ignatov (4): bpf: Introduce bpf_skb_ancestor_cgroup_id helper bpf: Sync bpf.h to tools/ selftests/bpf: Add cgroup id helpers to bpf_helpers.h selftests/bpf: Selftest for bpf_skb_ancestor_cgroup_id include/linux/cgroup.h| 30 +++ incl

[PATCH v2 bpf-next 1/4] bpf: Introduce bpf_skb_ancestor_cgroup_id helper

2018-08-12 Thread Andrey Ignatov
's not obviously better). Format of return value of the new helper is same as that of bpf_skb_cgroup_id. Signed-off-by: Andrey Ignatov --- include/linux/cgroup.h | 30 ++ include/uapi/linux/bpf.h | 21 - net/core/filter.c| 28 ++

[PATCH v2 bpf-next 2/4] bpf: Sync bpf.h to tools/

2018-08-12 Thread Andrey Ignatov
Sync skb_ancestor_cgroup_id() related bpf UAPI changes to tools/. Signed-off-by: Andrey Ignatov --- tools/include/uapi/linux/bpf.h | 21 - 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index

Re: [PATCH bpf-next 4/4] selftests/bpf: Selftest for bpf_skb_ancestor_cgroup_id

2018-08-12 Thread Andrey Ignatov
Yonghong Song [Sat, 2018-08-11 23:59 -0700]: > > > On 8/10/18 10:35 PM, Andrey Ignatov wrote: > > Add selftests for bpf_skb_ancestor_cgroup_id helper. > > > > test_skb_cgroup_id.sh prepares testing interface and adds tc qdisc and > > filter for

Re: [PATCH bpf-next 1/4] bpf: Introduce bpf_skb_ancestor_cgroup_id helper

2018-08-13 Thread Andrey Ignatov
Tejun Heo [Mon, 2018-08-13 07:47 -0700]: > Hello, Andrey. Hey Tejun! > On Fri, Aug 10, 2018 at 10:35:23PM -0700, Andrey Ignatov wrote: > > +static inline struct cgroup *cgroup_ancestor(struct cgroup *cgrp, > > +int ancestor_level) >

Re: [PATCH bpf-next v2 05/12] tools: libbpf: expose the prog type guessing from section name logic

2018-07-09 Thread Andrey Ignatov
used across API many times and will be more consistent, when "title" is used just once (IMO bpf_program__title() should have been called bpf_program__name() to be consistent with bpf_map__name() and others, not sure if it's fine to change now). > +enum bpf_attach_type *expected_attach_type); > + > /* Accessors of bpf_program */ > struct bpf_program; > struct bpf_program *bpf_program__next(struct bpf_program *prog, > -- > 2.17.1 > -- Andrey Ignatov

Re: [PATCH bpf-next v2 08/12] tools: libbpf: add extended attributes version of bpf_object__open()

2018-07-09 Thread Andrey Ignatov
pf_object__open_buffer() below), where path is not needed. Otherwise, if bpf_object__open_buffer() has to be extended in the future, another _xattr function will be needed (or caller would need to pass NULL to path, what would make API less convenient). > struct bpf_object *bpf_object__open_buffer(void *obj_buf, > size_t obj_buf_sz, > const char *name); > -- > 2.17.1 > -- Andrey Ignatov

Re: [PATCH bpf-next v2 11/12] tools: libbpf: allow map reuse

2018-07-09 Thread Andrey Ignatov
Jakub Kicinski [Mon, 2018-07-09 19:49 -0700]: > On Mon, 9 Jul 2018 13:22:54 -0700, Andrey Ignatov wrote: > > Jakub Kicinski [Mon, 2018-07-09 11:01 -0700]: > > > More advanced applications may want to only replace programs without > > > destroying associated maps. Al

Re: [PATCH bpf-next v2 11/12] tools: libbpf: allow map reuse

2018-07-09 Thread Andrey Ignatov
p *map, void *priv, > bpf_map_clear_priv_t clear_priv); > void *bpf_map__priv(struct bpf_map *map); > +int bpf_map__reuse_fd(struct bpf_map *map, int fd); > bool bpf_map__is_offload_neutral(struct bpf_map *map); > void bpf_map__set_ifindex(struct bpf_map *map, __u32 ifindex); > int bpf_map__pin(struct bpf_map *map, const char *path); > -- > 2.17.1 > -- Andrey Ignatov

Re: [PATCH bpf-next v3 05/13] tools: libbpf: expose the prog type guessing from section name logic

2018-07-10 Thread Andrey Ignatov
bpf_object_clear_priv_t clear_priv); > void *bpf_object__priv(struct bpf_object *prog); > > +int libbpf_prog_type_by_name(const char *name, enum bpf_prog_type *prog_type, > + enum bpf_attach_type *expected_attach_type); > + > /* Accessors of bpf_program */ > struct bpf_program; > struct bpf_program *bpf_program__next(struct bpf_program *prog, > -- > 2.17.1 > Thanks for changes Jakub! Acked-by: Andrey Ignatov -- Andrey Ignatov

Re: [PATCH bpf-next v3 12/13] tools: libbpf: allow map reuse

2018-07-10 Thread Andrey Ignatov
+261,7 @@ typedef void (*bpf_map_clear_priv_t)(struct bpf_map *, > void *); > int bpf_map__set_priv(struct bpf_map *map, void *priv, > bpf_map_clear_priv_t clear_priv); > void *bpf_map__priv(struct bpf_map *map); > +int bpf_map__reuse_fd(struct bpf_map *ma

Re: [PATCH bpf-next v3 08/13] tools: libbpf: add extended attributes version of bpf_object__open()

2018-07-10 Thread Andrey Ignatov
; > + enum bpf_prog_type prog_type; > +}; > + > struct bpf_object *bpf_object__open(const char *path); > +struct bpf_object *bpf_object__open_xattr(struct bpf_object_open_attr *attr); > struct bpf_object *bpf_object__open_buffer(void *obj_buf, > size_t obj_buf_sz, > const char *name); > -- > 2.17.1 > Acked-by: Andrey Ignatov -- Andrey Ignatov

[PATCH bpf-next 5/6] selftests/bpf: Better verification in test_tcpbpf

2018-07-11 Thread Andrey Ignatov
unexpected field is printed. Signed-off-by: Andrey Ignatov Acked-by: Alexei Starovoitov --- .../testing/selftests/bpf/test_tcpbpf_user.c | 64 +++ 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/tools/testing/selftests/bpf/test_tcpbpf_user.c b/tools/testing/selftests

[PATCH bpf-next 3/6] selftests/bpf: Fix const'ness in cgroup_helpers

2018-07-11 Thread Andrey Ignatov
Lack of const in cgroup helpers signatures forces to write ugly client code. Fix it. Signed-off-by: Andrey Ignatov Acked-by: Alexei Starovoitov --- tools/testing/selftests/bpf/cgroup_helpers.c | 6 +++--- tools/testing/selftests/bpf/cgroup_helpers.h | 6 +++--- 2 files changed, 6 insertions

[PATCH bpf-next 0/6] TCP-BPF callback for listening sockets

2018-07-11 Thread Andrey Ignatov
This patchset adds TCP-BPF callback for listening sockets. Patch 0001 provides more details and is the main patch in the set. Patch 0006 adds selftest for the new callback. Other patches are bug fixes and improvements in TCP-BPF selftest to make it easier to extend in 0006. Andrey Ignatov (6

[PATCH bpf-next 1/6] bpf: Add BPF_SOCK_OPS_TCP_LISTEN_CB

2018-07-11 Thread Andrey Ignatov
. Signed-off-by: Andrey Ignatov Acked-by: Alexei Starovoitov --- include/uapi/linux/bpf.h | 3 +++ net/ipv4/af_inet.c | 1 + 2 files changed, 4 insertions(+) diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index b7db3261c62d..aa11cdcbfcaf 100644 --- a/include/uapi/linux

[PATCH bpf-next 6/6] selftests/bpf: Test case for BPF_SOCK_OPS_TCP_LISTEN_CB

2018-07-11 Thread Andrey Ignatov
ser space later. Signed-off-by: Andrey Ignatov Acked-by: Alexei Starovoitov --- tools/testing/selftests/bpf/test_tcpbpf.h | 1 + tools/testing/selftests/bpf/test_tcpbpf_kern.c | 17 - tools/testing/selftests/bpf/test_tcpbpf_user.c | 4 +++- 3 files changed, 16 insertions(+)

[PATCH bpf-next 4/6] selftests/bpf: Switch test_tcpbpf_user to cgroup_helpers

2018-07-11 Thread Andrey Ignatov
Switch to cgroup_helpers to simplify the code and fix cgroup cleanup: before cgroup was not cleaned up after the test. It also removes SYSTEM macro, that only printed error, but didn't terminate the test. Signed-off-by: Andrey Ignatov Acked-by: Alexei Starovoitov --- tools/testing/selftests

[PATCH bpf-next 2/6] bpf: Sync bpf.h to tools/

2018-07-11 Thread Andrey Ignatov
Sync BPF_SOCK_OPS_TCP_LISTEN_CB related UAPI changes to tools/. Signed-off-by: Andrey Ignatov Acked-by: Alexei Starovoitov --- tools/include/uapi/linux/bpf.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index

Re: [RFC bpf-next v2 7/8] bpf: add documentation for eBPF helpers (51-57)

2018-04-10 Thread Andrey Ignatov
ot;) is not relevant to bpf_bind() and should be removed. It's about sys_connect hook itself that can call to bpf_bind() but also has other functionality (and that other functionality is described by this paragraph). -- Andrey Ignatov

Re: [PATCH bpf] tools/bpf: fix test_sock and test_sock_addr.sh failure

2018-04-18 Thread Andrey Ignatov
The patch looks good to me. Acked-by: Andrey Ignatov <r...@fb.com> Thanks for improving the tests, Yonghong! Yonghong Song <y...@fb.com> [Wed, 2018-04-18 10:49 -0700]: > The bpf selftests test_sock and test_sock_addr.sh failed > in my test machine. The failure looks like: &

[PATCH bpf-next 2/3] libbpf: Support guessing post_bind{4,6} progs

2018-04-16 Thread Andrey Ignatov
E`, for backward compatibility. Signed-off-by: Andrey Ignatov <r...@fb.com> --- tools/lib/bpf/libbpf.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 5922443..0fcc447 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf

[PATCH bpf-next 0/3] Add missing types to bpftool, libbpf

2018-04-16 Thread Andrey Ignatov
Add support for various BPF prog types and attach types that have been added to kernel recently but not to bpftool or libbpf yet. Andrey Ignatov (3): bpftool: Add missing prog types and attach types libbpf: Support guessing post_bind{4,6} progs libbpf: Type functions for raw tracepoints

[PATCH bpf-next 1/3] bpftool: Add missing prog types and attach types

2018-04-16 Thread Andrey Ignatov
Add missing prog types to `bpftool prog` and missing attach types to `bpftool cgroup`. Signed-off-by: Andrey Ignatov <r...@fb.com> --- tools/bpf/bpftool/cgroup.c | 19 --- tools/bpf/bpftool/prog.c | 3 +++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a

[PATCH bpf-next 3/3] libbpf: Type functions for raw tracepoints

2018-04-16 Thread Andrey Ignatov
Add missing pieces for BPF_PROG_TYPE_RAW_TRACEPOINT in libbpf: * is- and set- functions; * support guessing prog type. Signed-off-by: Andrey Ignatov <r...@fb.com> --- tools/lib/bpf/libbpf.c | 2 ++ tools/lib/bpf/libbpf.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tools/l

[PATCH net-next] net: Remove unused tcp_set_state tracepoint

2018-04-16 Thread Andrey Ignatov
This tracepoint was replaced by inet_sock_set_state in 563e0bb and not used anywhere in the kernel anymore. Remove it. Signed-off-by: Andrey Ignatov <r...@fb.com> --- include/trace/events/tcp.h | 47 -- 1 file changed, 47 deletions(-) diff

[PATCH v2 bpf-next 1/3] bpftool: Support new prog types and attach types

2018-04-17 Thread Andrey Ignatov
Add recently added prog types to `bpftool prog` and attach types to `bpftool cgroup`. Update bpftool documentation and bash completion appropriately. Signed-off-by: Andrey Ignatov <r...@fb.com> --- tools/bpf/bpftool/Documentation/bpftool-cgroup.rst | 11 +-- tools/bpf/bpftoo

[PATCH v2 bpf-next 0/3] Add missing types to bpftool, libbpf

2018-04-17 Thread Andrey Ignatov
v1->v2: - add new types to bpftool-cgroup man page; - add new types to bash completion for bpftool; - don't add types that should not be in bpftool cgroup. Add support for various BPF prog types and attach types that have been added to kernel recently but not to bpftool or libbpf yet. And

[PATCH v2 bpf-next 2/3] libbpf: Support guessing post_bind{4,6} progs

2018-04-17 Thread Andrey Ignatov
E`, for backward compatibility. Signed-off-by: Andrey Ignatov <r...@fb.com> --- tools/lib/bpf/libbpf.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 5922443..0fcc447 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf

[PATCH v2 bpf-next 3/3] libbpf: Type functions for raw tracepoints

2018-04-17 Thread Andrey Ignatov
Add missing pieces for BPF_PROG_TYPE_RAW_TRACEPOINT in libbpf: * is- and set- functions; * support guessing prog type. Signed-off-by: Andrey Ignatov <r...@fb.com> --- tools/lib/bpf/libbpf.c | 2 ++ tools/lib/bpf/libbpf.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tools/l

Re: [PATCH bpf-next v3 7/8] bpf: add documentation for eBPF helpers (51-57)

2018-04-17 Thread Andrey Ignatov
rks for IPv4 and IPv6, TCP and UDP sockets. The > + * domain (*addr*\ **->sa_family**) must be **AF_INET** (or > + * **AF_INET6**). Looking for a free port to bind to can be > + * expensive, therefore binding to port is not permitted by the > + * he

Re: [PATCH bpf-next 1/3] bpftool: Add missing prog types and attach types

2018-04-16 Thread Andrey Ignatov
Jakub Kicinski <kubak...@wp.pl> [Mon, 2018-04-16 16:53 -0700]: > On Mon, 16 Apr 2018 14:41:57 -0700, Andrey Ignatov wrote: > > diff --git a/tools/bpf/bpftool/cgroup.c b/tools/bpf/bpftool/cgroup.c > > index cae32a6..8689916 100644 > > --- a/tools/bpf/bpftool/cgroup.c

Re: [PATCH bpf-next v2 7/8] bpf: add tls support for testing in test_sockmap

2018-10-15 Thread Andrey Ignatov
*/ > + if (!txmsg_redir || (txmsg_redir && txmsg_ingress)) { > + err = sockmap_init_ktls(opt->verbose, rx_fd); > + if (err) > + return err; > + } > + err = sockmap_init_ktls(opt->verbose, c1); > + if (err) > + return err; > + } > + > rxpid = fork(); > if (rxpid == 0) { > if (opt->drop_expected) > @@ -907,6 +994,8 @@ static void test_options(char *options) > strncat(options, "ingress,", OPTSTRING); > if (txmsg_skb) > strncat(options, "skb,", OPTSTRING); > + if (ktls) > + strncat(options, "ktls,", OPTSTRING); > } > > static int __test_exec(int cgrp, int test, struct sockmap_options *opt) > -- > 2.9.5 > -- Andrey Ignatov

[PATCH bpf-next] libbpf: Per-symbol visibility for DSO

2018-10-15 Thread Andrey Ignatov
sn't break bpftool since bpftool links libbpf statically. [1] https://www.akkadia.org/drepper/dsohowto.pdf (2.2 Export Control) [2] https://www.mail-archive.com/netdev@vger.kernel.org/msg251434.html Signed-off-by: Andrey Ignatov --- tools/lib/bpf/Makefile | 1 + tools/lib/bpf/bpf.

Re: libbpf build failure on debian:9 with clang

2018-10-31 Thread Andrey Ignatov
; This is the cset: > > commit 956b620fcf0b64de403cd26a56bc41e6e4826ea6 > Author: Andrey Ignatov > Date: Wed Sep 26 15:24:53 2018 -0700 > > libbpf: Introduce libbpf_attach_type_by_name > > > > Tests are continuing, so f

[PATCH bpf] libbpf: Fix compile error in libbpf_attach_type_by_name

2018-10-31 Thread Andrey Ignatov
6b620fcf0b ("libbpf: Introduce libbpf_attach_type_by_name") Reported-by: Arnaldo Carvalho de Melo Signed-off-by: Andrey Ignatov --- tools/lib/bpf/libbpf.c | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.

[PATCH bpf-next 2/3] selftests/bpf: Test narrow loads with off > 0 in test_verifier

2018-11-06 Thread Andrey Ignatov
Test the following narrow loads in test_verifier for context __sk_buff: * off=1, size=1 - ok; * off=2, size=1 - ok; * off=3, size=1 - ok; * off=0, size=2 - ok; * off=1, size=2 - fail; * off=0, size=2 - ok; * off=3, size=2 - fail. Signed-off-by: Andrey Ignatov --- tools/testing/selftests/bpf

[PATCH bpf-next 1/3] bpf: Allow narrow loads with offset > 0

2018-11-06 Thread Andrey Ignatov
* off=0, size=4 (full). Reported-by: Yonghong Song Signed-off-by: Andrey Ignatov --- include/linux/filter.h | 16 +--- kernel/bpf/verifier.c | 19 +++ 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/include/linux/filter.h b/include/linux/filter.h inde

[PATCH bpf-next 0/3] bpf: Allow narrow loads with offset > 0

2018-11-06 Thread Andrey Ignatov
This patch set adds support for narrow loads with offset > 0 to BPF verifier. Patch 1 provides more details and is the main patch in the set. Patches 2 and 3 add new test cases to test_verifier and test_sock_addr selftests. Andrey Ignatov (3): bpf: Allow narrow loads with offset

[PATCH bpf-next 3/3] selftests/bpf: Test narrow loads with off > 0 for bpf_sock_addr

2018-11-06 Thread Andrey Ignatov
Add more test cases for context bpf_sock_addr to test narrow loads with offset > 0 for ctx->user_ip4 field (__u32): * off=1, size=1; * off=2, size=1; * off=3, size=1; * off=2, size=2. Signed-off-by: Andrey Ignatov --- tools/testing/selftests/bpf/test_sock_addr.c | 28 +

[PATCH bpf] bpf: Fix IPv6 dport byte order in bpf_sk_lookup_udp

2018-11-07 Thread Andrey Ignatov
for IPv6 incorrect. The patch fixes byte order of dport passed to __udp6_lib_lookup. Originally sk_lookup properly handled UDPv6, but not TCPv6. 5ef0ae84f02a fixes TCPv6 but breaks UDPv6. Fixes: 5ef0ae84f02a ("bpf: Fix IPv6 dport byte-order in bpf_sk_lookup") Signed-off-by: Andrey Ignatov ---

[PATCH bpf-next v2 1/3] bpf: Allow narrow loads with offset > 0

2018-11-10 Thread Andrey Ignatov
* off=0, size=4 (full). Reported-by: Yonghong Song Signed-off-by: Andrey Ignatov --- include/linux/filter.h | 16 +--- kernel/bpf/verifier.c | 21 - 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/include/linux/filter.h b/include/linux/filter

[PATCH bpf-next v2 3/3] selftests/bpf: Test narrow loads with off > 0 for bpf_sock_addr

2018-11-10 Thread Andrey Ignatov
Add more test cases for context bpf_sock_addr to test narrow loads with offset > 0 for ctx->user_ip4 field (__u32): * off=1, size=1; * off=2, size=1; * off=3, size=1; * off=2, size=2. Signed-off-by: Andrey Ignatov --- tools/testing/selftests/bpf/test_sock_addr.c | 28 +

[PATCH bpf-next v2 0/3] bpf: Allow narrow loads with offset > 0

2018-11-10 Thread Andrey Ignatov
This patch set adds support for narrow loads with offset > 0 to BPF verifier. Patch 1 provides more details and is the main patch in the set. Patches 2 and 3 add new test cases to test_verifier and test_sock_addr selftests. v1->v2: - fix -Wdeclaration-after-statement warning. Andrey Igna

[PATCH bpf-next v2 2/3] selftests/bpf: Test narrow loads with off > 0 in test_verifier

2018-11-10 Thread Andrey Ignatov
Test the following narrow loads in test_verifier for context __sk_buff: * off=1, size=1 - ok; * off=2, size=1 - ok; * off=3, size=1 - ok; * off=0, size=2 - ok; * off=1, size=2 - fail; * off=0, size=2 - ok; * off=3, size=2 - fail. Signed-off-by: Andrey Ignatov --- tools/testing/selftests/bpf

[PATCH bpf-next 1/4] bpf: Fix IPv6 dport byte order in bpf_sk_lookup_udp

2018-11-08 Thread Andrey Ignatov
for IPv6 incorrect. The patch fixes byte order of dport passed to __udp6_lib_lookup. Originally sk_lookup properly handled UDPv6, but not TCPv6. 5ef0ae84f02a fixes TCPv6 but breaks UDPv6. Fixes: 5ef0ae84f02a ("bpf: Fix IPv6 dport byte-order in bpf_sk_lookup") Signed-off-by: Andrey Ignatov Ack

[PATCH bpf-next 0/4] bpf: Support socket lookup in CGROUP_SOCK_ADDR progs

2018-11-08 Thread Andrey Ignatov
ic changes and simply moves code around. Patch 3 is the main patch in the set, it makes the helpers available for BPF_PROG_TYPE_CGROUP_SOCK_ADDR and provides more details about use-case. Patch 4 adds selftest for new functionality. Andrey Ignatov (4): bpf: Fix IPv6 dport byte order in bpf_sk_lookup

[PATCH bpf-next 4/4] selftest/bpf: Use bpf_sk_lookup_{tcp,udp} in test_sock_addr

2018-11-08 Thread Andrey Ignatov
Use bpf_sk_lookup_tcp, bpf_sk_lookup_udp and bpf_sk_release helpers from test_sock_addr programs to make sure they're available and can lookup and release socket properly for IPv4/IPv4, TCP/UDP. Reading from a few fields of returned struct bpf_sock is also tested. Signed-off-by: Andrey Ignatov

  1   2   >