[PATCH net-next 2/6] ipv6: Remove external dependency on rt6i_gateway and RTF_ANYCAST

2015-04-28 Thread Martin KaFai Lau
on rt6i_gateway and RTF_ANYCAST. Signed-off-by: Martin KaFai Lau Reviewed-by: Hannes Frederic Sowa Cc: Steffen Klassert --- include/net/ip6_route.h| 14 +- net/bluetooth/6lowpan.c| 2 +- net/ipv6/icmp.c| 4 ++-- net/ipv6

[PATCH net-next 6/6] ipv6: Create percpu rt6_info

2015-04-28 Thread Martin KaFai Lau
After the patch 'ipv6: Only create RTF_CACHE routes after encountering pmtu exception', we need to compensate the performance hit (bouncing dst->__refcnt). Signed-off-by: Martin KaFai Lau Reviewed-by: Hannes Frederic Sowa Cc: Steffen Klassert --- include/net/ip6_fib.h

[PATCH net-next 5/6] ipv6: Break up ip6_rt_copy()

2015-04-28 Thread Martin KaFai Lau
This patch breaks up ip6_rt_copy() into ip6_rt_copy_init() and ip6_rt_cache_alloc(). In the later patch, we need to create a percpu rt6_info copy. Hence, refactor the common rt6_info init codes to ip6_rt_copy_init(). Signed-off-by: Martin KaFai Lau Reviewed-by: Hannes Frederic Sowa Cc: Steffen

[PATCH net-next 1/6] ipv6: Remove external dependency on rt6i_dst and rt6i_src

2015-04-28 Thread Martin KaFai Lau
) later. Signed-off-by: Martin KaFai Lau Reviewed-by: Hannes Frederic Sowa Cc: Steffen Klassert --- drivers/scsi/cxgbi/libcxgbi.c | 2 +- include/net/ipv6.h | 3 ++- net/ipv6/icmp.c | 2 +- net/ipv6/ip6_output.c | 22 +++--- net/ipv6

[PATCH net-next 4/6] ipv6: Only create RTF_CACHE routes after encountering pmtu exception

2015-04-28 Thread Martin KaFai Lau
This patch creates a RTF_CACHE routes only after encountering a pmtu exception. After ip6_rt_update_pmtu() has inserted the RTF_CACHE route to the fib6 tree, the rt->rt6i_node->fn_sernum is bumped which will fail the ip6_dst_check() and trigger a relookup. Signed-off-by: Martin KaF

Re: [PATCH net-next 2/6] ipv6: Remove external dependency on rt6i_gateway and RTF_ANYCAST

2015-04-29 Thread Martin KaFai Lau
Hi, On Wed, Apr 29, 2015 at 11:28:46AM +0300, Julian Anastasov wrote: > > Hello, > > On Tue, 28 Apr 2015, Martin KaFai Lau wrote: > > > -static inline struct in6_addr *rt6_nexthop(struct rt6_info *rt) > > +static inline struct in6_addr *rt6_

[RFC PATCH net-next v3 8/9] ipv6: Break up ip6_rt_copy()

2015-05-01 Thread Martin KaFai Lau
This patch breaks up ip6_rt_copy() into ip6_rt_copy_init() and ip6_rt_cache_alloc(). In the later patch, we need to create a percpu rt6_info copy. Hence, refactor the common rt6_info init codes to ip6_rt_copy_init(). Signed-off-by: Martin KaFai Lau Cc: Hannes Frederic Sowa Cc: Steffen Klassert

Re: [PATCH net v2] udp6: set dst cache for a connected sk before udp_v6_send_skb

2018-03-27 Thread Martin KaFai Lau
On Tue, Mar 27, 2018 at 04:27:30PM +0300, Alexey Kodanev wrote: > On 26.03.2018 20:02, Martin KaFai Lau wrote: > > On Mon, Mar 26, 2018 at 05:48:47PM +0300, Alexey Kodanev wrote: > >> After commit 33c162a980fe ("ipv6: datagram: Update dst cache of a > >> connecte

[PATCH bpf-next 05/10] bpf: btf: Add BPF_BTF_LOAD command

2018-03-30 Thread Martin KaFai Lau
This patch adds a BPF_BTF_LOAD command which 1) loads and verifies the BTF (implemented in earlier patches) 2) returns a BTF fd to userspace. In the next patch, the BTF fd can be specified during BPF_MAP_CREATE. It currently limits to CAP_SYS_ADMIN. Signed-off-by: Martin KaFai Lau Acked-by

[PATCH bpf-next 04/10] bpf: btf: Add pretty print capability for data with BTF type info

2018-03-30 Thread Martin KaFai Lau
This patch adds pretty print capability for data with BTF type info. The current usage is to allow pretty print of a BPF map. The next few patches will allow a read() on a pinned map with BTF type info for its key and value. This patch uses the seq_printf() infra. Signed-off-by: Martin KaFai

[PATCH bpf-next 06/10] bpf: btf: Add BPF_OBJ_GET_INFO_BY_FD support to BTF fd

2018-03-30 Thread Martin KaFai Lau
, the userspace should realloc with the kernel-returned info.info_len and call the BPF_OBJ_GET_INFO_BY_FD again. Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- include/linux/btf.h | 5 + kernel/bpf/btf.c | 17 - kernel/bpf/syscall.c | 2 ++ 3 files change

[PATCH bpf-next 07/10] bpf: btf: Add pretty print support to the basic arraymap

2018-03-30 Thread Martin KaFai Lau
sample output when reading a pinned arraymap with the following map's value: struct map_value { int count_a; int count_b; }; cat /sys/fs/bpf/pinned_array_map: 0: {1,2} 1: {3,4} 2: {5,6} ... Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- include/linux/

[PATCH bpf-next 02/10] bpf: btf: Validate type reference

2018-03-30 Thread Martin KaFai Lau
array). This info will be useful in checking the struct's members in a later patch. They will also be useful in doing pretty print later. Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- include/linux/btf.h | 37 +++ kernel/bpf/btf.c

[PATCH bpf-next 03/10] bpf: btf: Check members of struct/union

2018-03-30 Thread Martin KaFai Lau
he above can only be done after the needs_resolve member's type is resolved. Hence, the above is done together in btf_struct_resolve(). Each possible member's type (e.g. int, enum, modifier...) implements the check_member() ops which will be called from btf_struct_resolve(). Sign

[PATCH bpf-next 08/10] bpf: btf: Sync bpf.h and btf.h to tools/

2018-03-30 Thread Martin KaFai Lau
This patch sync up the bpf.h and btf.h to tools/ Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- tools/include/uapi/linux/bpf.h | 13 tools/include/uapi/linux/btf.h | 132 + 2 files changed, 145 insertions(+) create mode 100644

[PATCH bpf-next 00/10] BTF: BPF Type Format

2018-03-30 Thread Martin KaFai Lau
capability for a BPF map. A modified pahole that can convert dwarf to BTF is here: https://github.com/iamkafai/pahole/tree/btf Please see individual patch for details. Martin KaFai Lau (10): bpf: btf: Introduce BPF Type Format (BTF) bpf: btf: Validate type reference bpf: btf: Check members of

[PATCH bpf-next 09/10] bpf: btf: Add BTF support to libbpf

2018-03-30 Thread Martin KaFai Lau
key_id and btf_value_id of a map by finding the BTF type with name "_key" and "_name". If they cannot be found, it will continue without using the BTF. Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- tools/lib/bpf/Build| 2 +- tools/lib/bpf/bpf.c|

[PATCH bpf-next 10/10] bpf: btf: Add BTF tests

2018-03-30 Thread Martin KaFai Lau
of the llvm repo for now. BTF_PAHOLE: The modified pahole with BTF support: https://github.com/iamkafai/pahole/tree/btf To add a BTF section: "pahole -J bpf_prog.o" LLVM_OBJCOPY: Any llvm-objcopy should do Signed-off-by: Martin KaFai Lau Acked-by: Alexei S

[PATCH bpf-next 01/10] bpf: btf: Introduce BPF Type Format (BTF)

2018-03-30 Thread Martin KaFai Lau
can only be done in the second pass. The second verification pass will be implemented in the next patch. Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- include/uapi/linux/btf.h | 132 +++ kernel/bpf/Makefile | 1 + kernel/bpf/btf.c | 915

Re: [PATCH net v4 0/3] ipv6: udp6: set dst cache for a connected sk if current not valid

2018-03-30 Thread Martin KaFai Lau
On Fri, Mar 30, 2018 at 08:53:06PM +0300, Alexey Kodanev wrote: > A new RTF_CACHE route can be created with the socket's dst cache > update between the below calls in udpv6_sendmsg(), when datagram > sending results to ICMPV6_PKT_TOOBIG error: > >dst = ip6_sk_dst_lookup_flow(...) >... > re

Re: [PATCH bpf-next 01/10] bpf: btf: Introduce BPF Type Format (BTF)

2018-03-30 Thread Martin KaFai Lau
On Sat, Mar 31, 2018 at 01:22:53AM +0200, Daniel Borkmann wrote: > On 03/30/2018 08:26 PM, Martin KaFai Lau wrote: > [...] > > +static int btf_add_type(struct btf_verifier_env *env, struct btf_type *t) > > +{ > > + struct btf *btf = env->btf; > > + > > +

[PATCH v2 bpf-next 05/10] bpf: btf: Add BPF_BTF_LOAD command

2018-03-31 Thread Martin KaFai Lau
This patch adds a BPF_BTF_LOAD command which 1) loads and verifies the BTF (implemented in earlier patches) 2) returns a BTF fd to userspace. In the next patch, the BTF fd can be specified during BPF_MAP_CREATE. It currently limits to CAP_SYS_ADMIN. Signed-off-by: Martin KaFai Lau Acked-by

[PATCH v2 bpf-next 06/10] bpf: btf: Add BPF_OBJ_GET_INFO_BY_FD support to BTF fd

2018-03-31 Thread Martin KaFai Lau
, the userspace should realloc with the kernel-returned info.info_len and call the BPF_OBJ_GET_INFO_BY_FD again. Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- include/linux/btf.h | 5 + kernel/bpf/btf.c | 17 - kernel/bpf/syscall.c | 2 ++ 3 files change

[PATCH v2 bpf-next 04/10] bpf: btf: Add pretty print capability for data with BTF type info

2018-03-31 Thread Martin KaFai Lau
This patch adds pretty print capability for data with BTF type info. The current usage is to allow pretty print of a BPF map. The next few patches will allow a read() on a pinned map with BTF type info for its key and value. This patch uses the seq_printf() infra. Signed-off-by: Martin KaFai

[PATCH v2 bpf-next 10/10] bpf: btf: Add BTF tests

2018-03-31 Thread Martin KaFai Lau
of the llvm repo for now. BTF_PAHOLE: The modified pahole with BTF support: https://github.com/iamkafai/pahole/tree/btf To add a BTF section: "pahole -J bpf_prog.o" LLVM_OBJCOPY: Any llvm-objcopy should do Signed-off-by: Martin KaFai Lau Acked-by: Alexei S

[PATCH v2 bpf-next 00/10] BTF: BPF Type Format

2018-03-31 Thread Martin KaFai Lau
incorrect goto target in map_create() during the btf-error-path in patch 7 - re-org some local vars to keep the rev xmas tree in btf.c Martin KaFai Lau (10): bpf: btf: Introduce BPF Type Format (BTF) bpf: btf: Validate type reference bpf: btf: Check members of struct/union bpf: btf: Add

[PATCH v2 bpf-next 02/10] bpf: btf: Validate type reference

2018-03-31 Thread Martin KaFai Lau
array). This info will be useful in checking the struct's members in a later patch. They will also be useful in doing pretty print later. Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- include/linux/btf.h | 37 +++ kernel/bpf/btf.c

[PATCH v2 bpf-next 01/10] bpf: btf: Introduce BPF Type Format (BTF)

2018-03-31 Thread Martin KaFai Lau
can only be done in the second pass. The second verification pass will be implemented in the next patch. Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- include/uapi/linux/btf.h | 132 +++ kernel/bpf/Makefile | 1 + kernel/bpf/btf.c | 924

[PATCH v2 bpf-next 09/10] bpf: btf: Add BTF support to libbpf

2018-03-31 Thread Martin KaFai Lau
key_id and btf_value_id of a map by finding the BTF type with name "_key" and "_name". If they cannot be found, it will continue without using the BTF. Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- tools/lib/bpf/Build| 2 +- tools/lib/bpf/bpf.c|

[PATCH v2 bpf-next 07/10] bpf: btf: Add pretty print support to the basic arraymap

2018-03-31 Thread Martin KaFai Lau
sample output when reading a pinned arraymap with the following map's value: struct map_value { int count_a; int count_b; }; cat /sys/fs/bpf/pinned_array_map: 0: {1,2} 1: {3,4} 2: {5,6} ... Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- include/linux/

[PATCH v2 bpf-next 03/10] bpf: btf: Check members of struct/union

2018-03-31 Thread Martin KaFai Lau
he above can only be done after the needs_resolve member's type is resolved. Hence, the above is done together in btf_struct_resolve(). Each possible member's type (e.g. int, enum, modifier...) implements the check_member() ops which will be called from btf_struct_resolve(). Sign

[PATCH v2 bpf-next 08/10] bpf: btf: Sync bpf.h and btf.h to tools/

2018-03-31 Thread Martin KaFai Lau
This patch sync up the bpf.h and btf.h to tools/ Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- tools/include/uapi/linux/bpf.h | 13 tools/include/uapi/linux/btf.h | 132 + 2 files changed, 145 insertions(+) create mode 100644

Re: [PATCH bpf-next 07/10] bpf: btf: Add pretty print support to the basic arraymap

2018-03-31 Thread Martin KaFai Lau
On Sat, Mar 31, 2018 at 05:12:36PM +0800, kbuild test robot wrote: > Hi Martin, > > Thank you for the patch! Perhaps something to improve: > > [auto build test WARNING on bpf-next/master] > > url: > https://github.com/0day-ci/linux/commits/Martin-KaFai-Lau/BTF-

Re: [PATCH bpf-next 01/10] bpf: btf: Introduce BPF Type Format (BTF)

2018-03-31 Thread Martin KaFai Lau
On Sat, Mar 31, 2018 at 04:43:28PM +0800, kbuild test robot wrote: > Hi Martin, > > Thank you for the patch! Perhaps something to improve: > > [auto build test WARNING on bpf-next/master] > > url: > https://github.com/0day-ci/linux/commits/Martin-KaFai-Lau/BTF-

Re: [PATCH net v6 0/4] ipv6: udp: set dst cache for a connected sk if current not valid

2018-04-03 Thread Martin KaFai Lau
o be consistent with ip6_sk_dst_store_flow(), changes its type > from int to bool. > > The last patch contains the actual fix that removes sk dst cache > update in the end of udpv6_sendmsg(), and allows to do it in > ip6_sk_dst_lookup_flow(). Thanks for the patches! Acked-by: Marti

[PATCH bpf-next v3 06/10] bpf: btf: Add BPF_OBJ_GET_INFO_BY_FD support to BTF fd

2018-04-16 Thread Martin KaFai Lau
, the userspace should realloc with the kernel-returned info.info_len and call the BPF_OBJ_GET_INFO_BY_FD again. Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- include/linux/btf.h | 5 + kernel/bpf/btf.c | 17 - kernel/bpf/syscall.c | 2 ++ 3 files change

[PATCH bpf-next v3 09/10] bpf: btf: Add BTF support to libbpf

2018-04-16 Thread Martin KaFai Lau
key_id and btf_value_id of a map by finding the BTF type with name "_key" and "_value". If they cannot be found, it will continue without using the BTF. Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- tools/lib/bpf/Build| 2 +- tools/lib/bpf/bpf.c|

[PATCH bpf-next v3 08/10] bpf: btf: Sync bpf.h and btf.h to tools/

2018-04-16 Thread Martin KaFai Lau
This patch sync up the bpf.h and btf.h to tools/ Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- tools/include/uapi/linux/bpf.h | 13 tools/include/uapi/linux/btf.h | 132 + 2 files changed, 145 insertions(+) create mode 100644

[PATCH bpf-next v3 07/10] bpf: btf: Add pretty print support to the basic arraymap

2018-04-16 Thread Martin KaFai Lau
sample output when reading a pinned arraymap with the following map's value: struct map_value { int count_a; int count_b; }; cat /sys/fs/bpf/pinned_array_map: 0: {1,2} 1: {3,4} 2: {5,6} ... Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- include/linux/

[PATCH bpf-next v3 04/10] bpf: btf: Add pretty print capability for data with BTF type info

2018-04-16 Thread Martin KaFai Lau
This patch adds pretty print capability for data with BTF type info. The current usage is to allow pretty print for a BPF map. The next few patches will allow a read() on a pinned map with BTF type info for its key and value. This patch uses the seq_printf() infra. Signed-off-by: Martin KaFai

[PATCH bpf-next v3 10/10] bpf: btf: Add BTF tests

2018-04-16 Thread Martin KaFai Lau
of the llvm repo for now. BTF_PAHOLE: The modified pahole with BTF support: https://github.com/iamkafai/pahole/tree/btf To add a BTF section: "pahole -J bpf_prog.o" LLVM_OBJCOPY: Any llvm-objcopy should do Signed-off-by: Martin KaFai Lau Acked-by: Alexei S

[PATCH bpf-next v3 01/10] bpf: btf: Introduce BPF Type Format (BTF)

2018-04-16 Thread Martin KaFai Lau
can only be done in the second pass. The second verification pass will be implemented in the next patch. Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- include/uapi/linux/btf.h | 132 +++ kernel/bpf/Makefile | 1 + kernel/bpf/btf.c | 940

[PATCH bpf-next v3 00/10] BTF: BPF Type Format

2018-04-16 Thread Martin KaFai Lau
eta() in patch 1 - Fix an incorrect goto target in map_create() during the btf-error-path in patch 7 - re-org some local vars to keep the rev xmas tree in btf.c Martin KaFai Lau (10): bpf: btf: Introduce BPF Type Format (BTF) bpf: btf: Validate type reference bpf: btf: Check members of str

[PATCH bpf-next v3 02/10] bpf: btf: Validate type reference

2018-04-16 Thread Martin KaFai Lau
array). This info will be useful in checking the struct's members in a later patch. They will also be useful in doing pretty print later. Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- include/linux/btf.h | 37 +++ kernel/bpf/btf.c

[PATCH bpf-next v3 03/10] bpf: btf: Check members of struct/union

2018-04-16 Thread Martin KaFai Lau
he above can only be done after the needs_resolve member's type is resolved. Hence, the above is done together in btf_struct_resolve(). Each possible member's type (e.g. int, enum, modifier...) implements the check_member() ops which will be called from btf_struct_resolve(). Sign

[PATCH bpf-next v3 05/10] bpf: btf: Add BPF_BTF_LOAD command

2018-04-16 Thread Martin KaFai Lau
This patch adds a BPF_BTF_LOAD command which 1) loads and verifies the BTF (implemented in earlier patches) 2) returns a BTF fd to userspace. In the next patch, the BTF fd can be specified during BPF_MAP_CREATE. It currently limits to CAP_SYS_ADMIN. Signed-off-by: Martin KaFai Lau Acked-by

Re: [PATCH bpf-next v3 00/10] BTF: BPF Type Format

2018-04-17 Thread Martin KaFai Lau
On Mon, Apr 16, 2018 at 05:22:00PM -0300, Arnaldo Carvalho de Melo wrote: > Em Mon, Apr 16, 2018 at 12:33:17PM -0700, Martin KaFai Lau escreveu: > > This patch introduces BPF Type Format (BTF). > > > > BTF (BPF Type Format) is the meta data format which describes > > th

[PATCH bpf-next v4 04/10] bpf: btf: Add pretty print capability for data with BTF type info

2018-04-17 Thread Martin KaFai Lau
This patch adds pretty print capability for data with BTF type info. The current usage is to allow pretty print for a BPF map. The next few patches will allow a read() on a pinned map with BTF type info for its key and value. This patch uses the seq_printf() infra. Signed-off-by: Martin KaFai

[PATCH bpf-next v4 08/10] bpf: btf: Sync bpf.h and btf.h to tools/

2018-04-17 Thread Martin KaFai Lau
This patch sync up the bpf.h and btf.h to tools/ Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- tools/include/uapi/linux/bpf.h | 13 tools/include/uapi/linux/btf.h | 132 + 2 files changed, 145 insertions(+) create mode 100644

[PATCH bpf-next v4 09/10] bpf: btf: Add BTF support to libbpf

2018-04-17 Thread Martin KaFai Lau
key_id and btf_value_id of a map by finding the BTF type with name "_key" and "_value". If they cannot be found, it will continue without using the BTF. Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- tools/lib/bpf/Build| 2 +- tools/lib/bpf/bpf.c|

[PATCH bpf-next v4 00/10] BTF: BPF Type Format

2018-04-17 Thread Martin KaFai Lau
rev xmas tree in btf.c Martin KaFai Lau (10): bpf: btf: Introduce BPF Type Format (BTF) bpf: btf: Validate type reference bpf: btf: Check members of struct/union bpf: btf: Add pretty print capability for data with BTF type info bpf: btf: Add BPF_BTF_LOAD command bpf: btf:

[PATCH bpf-next v4 01/10] bpf: btf: Introduce BPF Type Format (BTF)

2018-04-17 Thread Martin KaFai Lau
can only be done in the second pass. The second verification pass will be implemented in the next patch. Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- include/uapi/linux/btf.h | 132 +++ kernel/bpf/Makefile | 1 + kernel/bpf/btf.c | 938

[PATCH bpf-next v4 02/10] bpf: btf: Validate type reference

2018-04-17 Thread Martin KaFai Lau
array). This info will be useful in checking the struct's members in a later patch. They will also be useful in doing pretty print later. Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- include/linux/btf.h | 37 +++ kernel/bpf/btf.c

[PATCH bpf-next v4 03/10] bpf: btf: Check members of struct/union

2018-04-17 Thread Martin KaFai Lau
he above can only be done after the needs_resolve member's type is resolved. Hence, the above is done together in btf_struct_resolve(). Each possible member's type (e.g. int, enum, modifier...) implements the check_member() ops which will be called from btf_struct_resolve(). Sign

[PATCH bpf-next v4 10/10] bpf: btf: Add BTF tests

2018-04-17 Thread Martin KaFai Lau
of the llvm repo for now. BTF_PAHOLE: The modified pahole with BTF support: https://github.com/iamkafai/pahole/tree/btf To add a BTF section: "pahole -J bpf_prog.o" LLVM_OBJCOPY: Any llvm-objcopy should do Signed-off-by: Martin KaFai Lau Acked-by: Alexei S

[PATCH bpf-next v4 05/10] bpf: btf: Add BPF_BTF_LOAD command

2018-04-17 Thread Martin KaFai Lau
This patch adds a BPF_BTF_LOAD command which 1) loads and verifies the BTF (implemented in earlier patches) 2) returns a BTF fd to userspace. In the next patch, the BTF fd can be specified during BPF_MAP_CREATE. It currently limits to CAP_SYS_ADMIN. Signed-off-by: Martin KaFai Lau Acked-by

[PATCH bpf-next v4 06/10] bpf: btf: Add BPF_OBJ_GET_INFO_BY_FD support to BTF fd

2018-04-17 Thread Martin KaFai Lau
, the userspace should realloc with the kernel-returned info.info_len and call the BPF_OBJ_GET_INFO_BY_FD again. Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- include/linux/btf.h | 5 + kernel/bpf/btf.c | 17 - kernel/bpf/syscall.c | 2 ++ 3 files change

[PATCH bpf-next v4 07/10] bpf: btf: Add pretty print support to the basic arraymap

2018-04-17 Thread Martin KaFai Lau
sample output when reading a pinned arraymap with the following map's value: struct map_value { int count_a; int count_b; }; cat /sys/fs/bpf/pinned_array_map: 0: {1,2} 1: {3,4} 2: {5,6} ... Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- include/linux/

Re: [PATCH bpf-next v4 07/10] bpf: btf: Add pretty print support to the basic arraymap

2018-04-18 Thread Martin KaFai Lau
On Wed, Apr 18, 2018 at 05:20:11PM +0200, Daniel Borkmann wrote: > Hi Martin, > > first of all great work on the set! One issue that puzzled me > while digesting it further below. > > On 04/17/2018 10:42 PM, Martin KaFai Lau wrote: > > This patch adds pretty print suppo

Re: [PATCH bpf-next v4 03/10] bpf: btf: Check members of struct/union

2018-04-18 Thread Martin KaFai Lau
On Wed, Apr 18, 2018 at 10:22:10AM -0700, Jakub Kicinski wrote: > On Tue, 17 Apr 2018 13:42:36 -0700, Martin KaFai Lau wrote: > > This patch checks a few things of struct's members: > > > > 1) It has a valid size (e.g. a "const void" is invalid) > > 2) A

[PATCH bpf-next v5 08/10] bpf: btf: Sync bpf.h and btf.h to tools/

2018-04-18 Thread Martin KaFai Lau
This patch sync up the bpf.h and btf.h to tools/ Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- tools/include/uapi/linux/bpf.h | 12 tools/include/uapi/linux/btf.h | 130 + 2 files changed, 142 insertions(+) create mode 100644

[PATCH bpf-next v5 00/10] BTF: BPF Type Format

2018-04-18 Thread Martin KaFai Lau
the rev xmas tree in btf.c Martin KaFai Lau (10): bpf: btf: Introduce BPF Type Format (BTF) bpf: btf: Validate type reference bpf: btf: Check members of struct/union bpf: btf: Add pretty print capability for data with BTF type info bpf: btf: Add BPF_BTF_LOAD command bpf: btf:

[PATCH bpf-next v5 04/10] bpf: btf: Add pretty print capability for data with BTF type info

2018-04-18 Thread Martin KaFai Lau
This patch adds pretty print capability for data with BTF type info. The current usage is to allow pretty print for a BPF map. The next few patches will allow a read() on a pinned map with BTF type info for its key and value. This patch uses the seq_printf() infra. Signed-off-by: Martin KaFai

[PATCH bpf-next v5 05/10] bpf: btf: Add BPF_BTF_LOAD command

2018-04-18 Thread Martin KaFai Lau
This patch adds a BPF_BTF_LOAD command which 1) loads and verifies the BTF (implemented in earlier patches) 2) returns a BTF fd to userspace. In the next patch, the BTF fd can be specified during BPF_MAP_CREATE. It currently limits to CAP_SYS_ADMIN. Signed-off-by: Martin KaFai Lau Acked-by

[PATCH bpf-next v5 09/10] bpf: btf: Add BTF support to libbpf

2018-04-18 Thread Martin KaFai Lau
key_id and btf_value_id of a map by finding the BTF type with name "_key" and "_value". If they cannot be found, it will continue without using the BTF. Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- tools/lib/bpf/Build| 2 +- tools/lib/bpf/bpf.c|

[PATCH bpf-next v5 06/10] bpf: btf: Add BPF_OBJ_GET_INFO_BY_FD support to BTF fd

2018-04-18 Thread Martin KaFai Lau
, the userspace should realloc with the kernel-returned info.info_len and call the BPF_OBJ_GET_INFO_BY_FD again. Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- include/linux/btf.h | 5 + kernel/bpf/btf.c | 17 - kernel/bpf/syscall.c | 2 ++ 3 files change

[PATCH bpf-next v5 07/10] bpf: btf: Add pretty print support to the basic arraymap

2018-04-18 Thread Martin KaFai Lau
ount_b; }; cat /sys/fs/bpf/pinned_array_map: 0: {1,2} 1: {3,4} 2: {5,6} ... Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- include/linux/bpf.h | 20 +- include/uapi/linux/bpf.h | 3 + kernel/bpf/arraymap.c| 50 +++ kernel/bpf

[PATCH bpf-next v5 10/10] bpf: btf: Add BTF tests

2018-04-18 Thread Martin KaFai Lau
of the llvm repo for now. BTF_PAHOLE: The modified pahole with BTF support: https://github.com/iamkafai/pahole/tree/btf To add a BTF section: "pahole -J bpf_prog.o" LLVM_OBJCOPY: Any llvm-objcopy should do Signed-off-by: Martin KaFai Lau Acked-by: Alexei S

[PATCH bpf-next v5 01/10] bpf: btf: Introduce BPF Type Format (BTF)

2018-04-18 Thread Martin KaFai Lau
can only be done in the second pass. The second verification pass will be implemented in the next patch. Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- include/uapi/linux/btf.h | 130 +++ kernel/bpf/Makefile | 1 + kernel/bpf/btf.c | 915

[PATCH bpf-next v5 02/10] bpf: btf: Validate type reference

2018-04-18 Thread Martin KaFai Lau
array). This info will be useful in checking the struct's members in a later patch. They will also be useful in doing pretty print later. Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- include/linux/btf.h | 37 +++ kernel/bpf/btf.c

[PATCH bpf-next v5 03/10] bpf: btf: Check members of struct/union

2018-04-18 Thread Martin KaFai Lau
he above can only be done after the needs_resolve member's type is resolved. Hence, the above is done together in btf_struct_resolve(). Each possible member's type (e.g. int, enum, modifier...) implements the check_member() ops which will be called from btf_struct_resolve(). Sign

Re: [PATCH bpf-next v3 6/8] bpf: add documentation for eBPF helpers (42-50)

2018-04-18 Thread Martin KaFai Lau
0 on success, or a negative error in case of failure. > + * LGTM. Thanks! Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next v5 00/10] BTF: BPF Type Format

2018-04-19 Thread Martin KaFai Lau
On Thu, Apr 19, 2018 at 04:40:34PM -0300, Arnaldo Carvalho de Melo wrote: > Em Wed, Apr 18, 2018 at 03:55:56PM -0700, Martin KaFai Lau escreveu: > > This patch introduces BPF Type Format (BTF). > > > > BTF (BPF Type Format) is the meta data format which describes > > th

[PATCH RFC net-next] net: ipvs: Adjust gso_size for IPPROTO_TCP

2018-04-19 Thread Martin KaFai Lau
l local 2401:db00:1011:1f01:face:b00c:0:85 dev lo src 2401:db00:1011:10af:face:0:27:0 metric 1024 mtu 1460 advmss 1440 pref medium Signed-off-by: Martin KaFai Lau --- net/netfilter/ipvs/ip_vs_xmit.c | 49 +++-- 1 file changed, 33 insertions(+), 16 deletions(

Re: [PATCH bpf-next] libbpf: fixed build error for samples/bpf/

2018-04-20 Thread Martin KaFai Lau
On Fri, Apr 20, 2018 at 10:05:16AM +0200, Björn Töpel wrote: > From: Björn Töpel > > Commit 8a138aed4a80 ("bpf: btf: Add BTF support to libbpf") did not > include stdbool.h, so GCC complained when building samples/bpf/. > > In file included from /home/btopel/src/ext/linux/samples/bpf/libbpf.h:6:

Re: [PATCH RFC net-next] net: ipvs: Adjust gso_size for IPPROTO_TCP

2018-04-20 Thread Martin KaFai Lau
On Fri, Apr 20, 2018 at 11:43:59PM +0300, Julian Anastasov wrote: > > Hello, > > On Thu, 19 Apr 2018, Martin KaFai Lau wrote: > > > This patch is not a proper fix and mainly serves for discussion purpose. > > It is based on net-next which I have been using to de

[PATCH bpf-next] bpf: btf: Clean up btf.h in uapi

2018-04-21 Thread Martin KaFai Lau
This patch cleans up btf.h in uapi: 1) Rename "name" to "name_off" to better reflect it is an offset to the string section instead of a char array. 2) Remove unused value BTF_FLAGS_COMPR and BTF_MAGIC_SWAP Suggested-by: Daniel Borkmann Signed-off-by: Martin KaFai Lau ---

Re: [PATCH RFC net-next 18/20] net/ipv6: separate handling of FIB entries from dst based routes

2018-02-28 Thread Martin KaFai Lau
On Sun, Feb 25, 2018 at 11:47:28AM -0800, David Ahern wrote: > Signed-off-by: David Ahern > --- > include/net/ip6_fib.h | 4 +- > include/net/ip6_route.h | 3 +- > net/ipv6/addrconf.c | 31 ++--- > net/ipv6/anycast.c | 7 +- > net/ipv6/ip6_fib.c | 50 +-- >

Re: [PATCH RFC net-next 10/20] net/ipv6: move expires into rt6_info

2018-02-28 Thread Martin KaFai Lau
On Mon, Feb 26, 2018 at 03:55:14PM -0700, David Ahern wrote: > On 2/26/18 3:28 PM, Wei Wang wrote: > >> @@ -213,11 +234,6 @@ static inline void rt6_set_expires(struct rt6_info > >> *rt, unsigned long expires) > >> > >> static inline void rt6_update_expires(struct rt6_info *rt0, int timeout) > >>

Re: [PATCH RFC net-next 10/20] net/ipv6: move expires into rt6_info

2018-02-28 Thread Martin KaFai Lau
On Wed, Feb 28, 2018 at 03:25:02PM -0700, David Ahern wrote: > On 2/28/18 12:21 PM, Martin KaFai Lau wrote: > > On Mon, Feb 26, 2018 at 03:55:14PM -0700, David Ahern wrote: > >> On 2/26/18 3:28 PM, Wei Wang wrote: > >>>> @@ -213,11 +234,6 @@ static inline voi

[PATCH bpf-next 0/2] bpf_verifier_log changes

2018-03-24 Thread Martin KaFai Lau
This patch set has some changes and clean-up works for the bpf_verifier_log. They are the prep works for the BTF (BPF Type Format). Martin KaFai Lau (2): bpf: Rename bpf_verifer_log bpf: Add bpf_verifier_vlog() and bpf_verifier_log_needed() include/linux/bpf_verifier.h | 13

[PATCH bpf-next 1/2] bpf: Rename bpf_verifer_log

2018-03-24 Thread Martin KaFai Lau
bpf_verifer_log => bpf_verifier_log Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- include/linux/bpf_verifier.h | 6 +++--- kernel/bpf/verifier.c| 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/bpf_verifier.h b/include/li

[PATCH bpf-next 2/2] bpf: Add bpf_verifier_vlog() and bpf_verifier_log_needed()

2018-03-24 Thread Martin KaFai Lau
pf_verifier_log_needed(). Since it is re-factored, we can check it before va_start() in the current bpf_verifier_log_write() and verbose(). Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- include/linux/bpf_verifier.h | 7 +++ kernel/bpf/verifier.c| 19

Re: [PATCH net v2] udp6: set dst cache for a connected sk before udp_v6_send_skb

2018-03-26 Thread Martin KaFai Lau
On Mon, Mar 26, 2018 at 05:48:47PM +0300, Alexey Kodanev wrote: > After commit 33c162a980fe ("ipv6: datagram: Update dst cache of a > connected datagram sk during pmtu update"), when the error occurs on > sending datagram in udpv6_sendmsg() due to ICMPV6_PKT_TOOBIG type, > error handler can trigger

Re: [bpf-next PATCH v2 1/7] bpf: refactor sockmap sample program update for arg parsing

2018-01-11 Thread Martin KaFai Lau
On Wed, Jan 10, 2018 at 10:39:04AM -0800, John Fastabend wrote: > sockmap sample program takes arguments from cmd line but it reads them > in using offsets into the array. Because we want to add more arguments > in the future lets do proper argument handling. > > Also refactor code to pull apart s

Re: [bpf-next PATCH v2 2/7] bpf: add sendmsg option for testing BPF programs

2018-01-11 Thread Martin KaFai Lau
On Wed, Jan 10, 2018 at 10:39:21AM -0800, John Fastabend wrote: > When testing BPF programs using sockmap I often want to have more > control over how sendmsg is exercised. This becomes even more useful > as new sockmap program types are added. > > This adds a test type option to select type of te

Re: [bpf-next PATCH v2 3/7] bpf: sockmap sample, use fork() for send and recv

2018-01-11 Thread Martin KaFai Lau
On Wed, Jan 10, 2018 at 10:39:37AM -0800, John Fastabend wrote: > Currently for SENDMSG tests first send completes then recv runs. This > does not work well for large data sizes and/or many iterations. So > fork the recv and send handler so that we run both send and recv. In > the future we can add

Re: [bpf-next PATCH v2 5/7] bpf: sockmap sample add base test without any BPF for comparison

2018-01-11 Thread Martin KaFai Lau
On Wed, Jan 10, 2018 at 10:40:11AM -0800, John Fastabend wrote: > Add a base test that does not use BPF hooks to test baseline case. > > Signed-off-by: John Fastabend > --- > samples/sockmap/sockmap_user.c | 26 +- > 1 file changed, 21 insertions(+), 5 deletions(-) > >

Re: [bpf-next PATCH v3 1/7] bpf: refactor sockmap sample program update for arg parsing

2018-01-12 Thread Martin KaFai Lau
e to pull apart sock init and ping/pong test. This > allows us to add new tests in the future. > > Signed-off-by: John Fastabend One nit below. Acked-by: Martin KaFai Lau > --- [ ... ] > @@ -280,12 +333,21 @@ int main(int argc, char **argv) > retu

Re: [bpf-next PATCH v3 2/7] bpf: add sendmsg option for testing BPF programs

2018-01-12 Thread Martin KaFai Lau
On Thu, Jan 11, 2018 at 09:06:34PM -0800, John Fastabend wrote: > When testing BPF programs using sockmap I often want to have more > control over how sendmsg is exercised. This becomes even more useful > as new sockmap program types are added. > > This adds a test type option to select type of te

Re: [bpf-next PATCH v3 3/7] bpf: sockmap sample, use fork() for send and recv

2018-01-12 Thread Martin KaFai Lau
uture we can add a parameter to do more than a single fork of > tx/rx. > > With this we can get many GBps of data which helps exercise the > sockmap code. > > Signed-off-by: John Fastabend Some nits. Acked-by: Martin KaFai Lau > --- [ ... ] > @@ -274,25 +275,50 @@ stati

Re: [bpf-next PATCH v3 6/7] bpf: sockmap put client sockets in blocking mode

2018-01-12 Thread Martin KaFai Lau
with > a single thread the client/accepted sockets do not need to be > non-blocking. > > Signed-off-by: John Fastabend Acked-by: Martin KaFai Lau

Re: [bpf-next PATCH v3 4/7] bpf: sockmap sample, report bytes/sec

2018-01-12 Thread Martin KaFai Lau
On Thu, Jan 11, 2018 at 09:07:10PM -0800, John Fastabend wrote: > Report bytes/sec sent as well as total bytes. Useful to get rough > idea how different configurations and usage patterns perform with > sockmap. > > Signed-off-by: John Fastabend Acked-by: Martin KaFai Lau

Re: [bpf-next PATCH v3 3/7] bpf: sockmap sample, use fork() for send and recv

2018-01-12 Thread Martin KaFai Lau
uture we can add a parameter to do more than a single fork of > tx/rx. > > With this we can get many GBps of data which helps exercise the > sockmap code. > > Signed-off-by: John Fastabend One nit. Acked-by: Martin KaFai Lau > --- [ ... ] > @@ -274,25 +275,50 @@ static int

Re: [bpf-next PATCH v3 5/7] bpf: sockmap sample add base test without any BPF for comparison

2018-01-12 Thread Martin KaFai Lau
On Thu, Jan 11, 2018 at 09:07:29PM -0800, John Fastabend wrote: > Add a base test that does not use BPF hooks to test baseline case. > > Signed-off-by: John Fastabend Acked-by: Martin KaFai Lau

Re: [bpf-next PATCH v3 7/7] bpf: sockmap set rlimit

2018-01-12 Thread Martin KaFai Lau
On Thu, Jan 11, 2018 at 09:08:02PM -0800, John Fastabend wrote: > Avoid extra step of setting limit from cmdline and do it directly in > the program. > > Signed-off-by: John Fastabend Acked-by: Martin KaFai Lau

Re: [bpf-next PATCH 5/7] bpf: create tcp_bpf_ulp allowing BPF to monitor socket TX/RX data

2018-01-17 Thread Martin KaFai Lau
On Fri, Jan 12, 2018 at 10:11:11AM -0800, John Fastabend wrote: > This implements a BPF ULP layer to allow policy enforcement and > monitoring at the socket layer. In order to support this a new > program type BPF_PROG_TYPE_SK_MSG is used to run the policy at > the sendmsg/sendpage hook. To attach

Re: [PATCH net] ipv6: don't let tb6_root node share routes with other node

2018-01-18 Thread Martin KaFai Lau
On Thu, Jan 18, 2018 at 10:40:03AM -0800, Wei Wang wrote: > From: Wei Wang > > After commit 4512c43eac7e, if we add a route to the subtree of tb6_root > which does not have any route attached to it yet, the current code will > let tb6_root and the node in the subtree share the same route. > This

Re: [PATCH net] ipv6: don't let tb6_root node share routes with other node

2018-01-18 Thread Martin KaFai Lau
On Thu, Jan 18, 2018 at 03:31:29PM -0800, Wei Wang wrote: > On Thu, Jan 18, 2018 at 2:47 PM, Martin KaFai Lau wrote: > > On Thu, Jan 18, 2018 at 10:40:03AM -0800, Wei Wang wrote: > >> From: Wei Wang > >> > >> After commit 4512c43eac7e, if we add a route to the

Re: [PATCH net] ipv6: remove null_entry before adding default route

2018-01-05 Thread Martin KaFai Lau
On Fri, Jan 05, 2018 at 05:38:35PM -0800, Wei Wang wrote: > From: Wei Wang > > In the current code, when creating a new fib6 table, tb6_root.leaf gets > initialized to net->ipv6.ip6_null_entry. > If a default route is being added with rt->rt6i_metric = 0x, > fib6_add() will add this route

<    1   2   3   4   5   6   7   8   9   10   >