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

2018-05-22 Thread Martin KaFai Lau
> Summary: 26 PASSED, 0 FAILED > > Signed-off-by: Andrey Ignatov > Acked-by: Alexei Starovoitov Acked-by: Martin KaFai Lau

Re: [PATCH 1/1] tools/lib/libbpf.c: fix string format to allow build on arm32

2018-05-23 Thread Martin KaFai Lau
On Wed, May 23, 2018 at 12:41:14PM +0200, Daniel Borkmann wrote: > [ +Martin ] > > On 05/21/2018 08:59 AM, Sirio Balmelli wrote: > > On arm32, 'cd tools/testing/selftests/bpf && make' fails with: > > > > libbpf.c:80:10: error: format ‘%ld’ expects argument of type ‘long int’, > > but argument 4

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

2018-05-23 Thread Martin KaFai Lau
Pv4 for UDPv4; > * `msg_src_ip6` to set source IPv6 for UDPv6. > > Signed-off-by: Andrey Ignatov > Acked-by: Alexei Starovoitov Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next v3 2/7] bpf: introduce bpf subcommand BPF_TASK_FD_QUERY

2018-05-23 Thread Martin KaFai Lau
On Tue, May 22, 2018 at 09:30:46AM -0700, Yonghong Song wrote: > Currently, suppose a userspace application has loaded a bpf program > and attached it to a tracepoint/kprobe/uprobe, and a bpf > introspection tool, e.g., bpftool, wants to show which bpf program > is attached to which tracepoint/kpro

Re: [PATCH bpf-next v3 4/7] tools/bpf: add ksym_get_addr() in trace_helpers

2018-05-23 Thread Martin KaFai Lau
s is used to initiate a kprobe perf event. > > Signed-off-by: Yonghong Song Acked-by: Martin KaFai Lau

[PATCH bpf-next] bpf: btf: Avoid variable length array

2018-05-23 Thread Martin KaFai Lau
Sparse warning: kernel/bpf/btf.c:1985:34: warning: Variable length array is used. This patch moves the nr_secs from btf_check_sec_info() to a macro. Fixes: f80442a4cd18 ("bpf: btf: Change how section is supported in btf_header") Signed-off-by: Martin KaFai Lau --- kernel/bpf/

[PATCH v2 bpf-next] bpf: btf: Avoid variable length array

2018-05-23 Thread Martin KaFai Lau
Sparse warning: kernel/bpf/btf.c:1985:34: warning: Variable length array is used. This patch directly uses ARRAY_SIZE(). Fixes: f80442a4cd18 ("bpf: btf: Change how section is supported in btf_header") Signed-off-by: Martin KaFai Lau --- kernel/bpf/btf.c | 11 +-- 1 file

Re: [PATCH V4 net 0/2] ipv6: fix flowlabel issue for reset packet

2017-11-15 Thread Martin KaFai Lau
Aug 18, 2017 at 3:27 PM, David Miller > > >> wrote: > > >> > From: Martin KaFai Lau > > >> > Date: Fri, 18 Aug 2017 13:51:36 -0700 > > >> > > > >> >> It seems like that middle box specifically drops TCP_RST if it > > >

[PATCH RFC net-next 2/4] udp: Move udp[46]_portaddr_hash() to net/ip[v6].h

2017-11-20 Thread Martin KaFai Lau
This patch moves the udp[46]_portaddr_hash() to net/ip[v6].h. The function name is renamed to ipv[46]_portaddr_hash(). It will be used by a later patch which adds a second listener hashtable hashed by the address and port. Signed-off-by: Martin KaFai Lau --- include/net/ip.h | 9

[PATCH RFC net-next 4/4] tcp: Enable 2nd listener hashtable in TCP

2017-11-20 Thread Martin KaFai Lau
Enable the second listener hashtable in TCP. The scale is the same as UDP which is one slot per 2MB. Signed-off-by: Martin KaFai Lau --- net/ipv4/tcp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index bf97317e6c97..180311636023 100644 --- a/net/ipv4

[PATCH RFC net-next 1/4] inet: Add a count to struct inet_listen_hashbucket

2017-11-20 Thread Martin KaFai Lau
This patch adds a count to the 'struct inet_listen_hashbucket'. It counts how many sk is hashed to a bucket. It will be used to decide if the (to-be-added) portaddr listener's hashtable should be used during inet[6]_lookup_listener(). Signed-off-by: Martin KaFai Lau -

[PATCH RFC net-next 0/4] tcp: Add a 2nd listener hashtable (port+addr)

2017-11-20 Thread Martin KaFai Lau
This patch set adds a 2nd listener hashtable. It is to resolve the performance issue when a process is listening at many IP addresses with the same port (e.g. [IP1]:443, [IP2]:443... [IPN]:443) Martin KaFai Lau (4): inet: Add a count to struct inet_listen_hashbucket udp: Move udp[46

[PATCH RFC net-next 3/4] inet: Add a 2nd listener hashtable (port+addr)

2017-11-20 Thread Martin KaFai Lau
off as UDP such that it will only consult the new portaddr hashtable if the current port-only hashtable has >10 sk in the link-list. Signed-off-by: Martin KaFai Lau --- include/net/inet_connection_sock.h | 1 + include/net/inet_hashtables.h | 15 net/ipv4/inet_hashtabl

[PATCH net-next 1/4] inet: Add a count to struct inet_listen_hashbucket

2017-11-30 Thread Martin KaFai Lau
This patch adds a count to the 'struct inet_listen_hashbucket'. It counts how many sk is hashed to a bucket. It will be used to decide if the (to-be-added) portaddr listener's hashtable should be used during inet[6]_lookup_listener(). Signed-off-by: Martin KaFai Lau -

[PATCH net-next 0/4] tcp: Add a 2nd listener hashtable (port+addr)

2017-11-30 Thread Martin KaFai Lau
This patch set adds a 2nd listener hashtable. It is to resolve the performance issue when a process is listening at many IP addresses with the same port (e.g. [IP1]:443, [IP2]:443... [IPN]:443) Martin KaFai Lau (4): inet: Add a count to struct inet_listen_hashbucket udp: Move udp[46

[PATCH net-next 4/4] tcp: Enable 2nd listener hashtable in TCP

2017-11-30 Thread Martin KaFai Lau
Enable the second listener hashtable in TCP. The scale is the same as UDP which is one slot per 2MB. Signed-off-by: Martin KaFai Lau --- net/ipv4/tcp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index bf97317e6c97..180311636023 100644 --- a/net/ipv4

[PATCH net-next 3/4] inet: Add a 2nd listener hashtable (port+addr)

2017-11-30 Thread Martin KaFai Lau
off as UDP such that it will only consult the new portaddr hashtable if the current port-only hashtable has >10 sk in the link-list. Signed-off-by: Martin KaFai Lau --- include/net/inet_connection_sock.h | 2 + include/net/inet_hashtables.h | 15 net/ipv4/inet_hashtabl

[PATCH net-next 2/4] udp: Move udp[46]_portaddr_hash() to net/ip[v6].h

2017-11-30 Thread Martin KaFai Lau
This patch moves the udp[46]_portaddr_hash() to net/ip[v6].h. The function name is renamed to ipv[46]_portaddr_hash(). It will be used by a later patch which adds a second listener hashtable hashed by the address and port. Signed-off-by: Martin KaFai Lau --- include/net/ip.h | 9

Re: [PATCH net-next 3/4] inet: Add a 2nd listener hashtable (port+addr)

2017-12-01 Thread Martin KaFai Lau
On Fri, Dec 01, 2017 at 09:26:46AM -0800, Eric Dumazet wrote: > On Thu, 2017-11-30 at 15:23 -0800, Martin KaFai Lau wrote: > > The current listener hashtable is hashed by port only. > > When a process is listening at many IP addresses with the same port > > (e.g. > > [

[PATCH v2 net-next 3/4] inet: Add a 2nd listener hashtable (port+addr)

2017-12-01 Thread Martin KaFai Lau
t_cachep up and then add the new (int lhash2_mask, *lhash2) after the existing bhash_size. Signed-off-by: Martin KaFai Lau --- include/net/inet_connection_sock.h | 2 + include/net/inet_hashtables.h | 28 +-- net/ipv4/inet_hashtables.c | 168 +++

[PATCH v2 net-next 4/4] tcp: Enable 2nd listener hashtable in TCP

2017-12-01 Thread Martin KaFai Lau
Enable the second listener hashtable in TCP. The scale is the same as UDP which is one slot per 2MB. Signed-off-by: Martin KaFai Lau Reviewed-by: Eric Dumazet --- net/ipv4/tcp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index bf97317e6c97

[PATCH v2 net-next 1/4] inet: Add a count to struct inet_listen_hashbucket

2017-12-01 Thread Martin KaFai Lau
This patch adds a count to the 'struct inet_listen_hashbucket'. It counts how many sk is hashed to a bucket. It will be used to decide if the (to-be-added) portaddr listener's hashtable should be used during inet[6]_lookup_listener(). Signed-off-by: Martin KaFai Lau Reviewed-b

[PATCH v2 net-next 0/4] tcp: Add a 2nd listener hashtable (port+addr)

2017-12-01 Thread Martin KaFai Lau
cacheline to inet_hashinfo (Suggested by Eric Dumazet, Thanks!) - I take this chance to plug an existing 4 bytes hole while adding 'unsigned int lhash2_mask'. - Add some comments about lhash2 in inet_hashtables.h Martin KaFai Lau (4): inet: Add a count to struct inet_listen_hashbu

[PATCH v2 net-next 2/4] udp: Move udp[46]_portaddr_hash() to net/ip[v6].h

2017-12-01 Thread Martin KaFai Lau
This patch moves the udp[46]_portaddr_hash() to net/ip[v6].h. The function name is renamed to ipv[46]_portaddr_hash(). It will be used by a later patch which adds a second listener hashtable hashed by the address and port. Signed-off-by: Martin KaFai Lau Reviewed-by: Eric Dumazet --- include

Re: [PATCH bpf-next v2 2/3] bpf, netns: Keep attached programs in bpf_prog_array

2020-06-23 Thread Martin KaFai Lau
On Tue, Jun 23, 2020 at 12:34:58PM +0200, Jakub Sitnicki wrote: [ ... ] > @@ -93,8 +108,16 @@ static int bpf_netns_link_update_prog(struct bpf_link > *link, > goto out_unlock; > } > > + run_array = rcu_dereference_protected(net->bpf.run_array[type], > +

Re: [PATCH bpf-next v2 2/3] bpf, netns: Keep attached programs in bpf_prog_array

2020-06-23 Thread Martin KaFai Lau
On Tue, Jun 23, 2020 at 10:59:37PM +0200, Jakub Sitnicki wrote: > On Tue, Jun 23, 2020 at 09:33 PM CEST, Martin KaFai Lau wrote: > > On Tue, Jun 23, 2020 at 12:34:58PM +0200, Jakub Sitnicki wrote: > > > > [ ... ] > > > >> @@ -93,8 +108,16 @@ static int bpf_ne

Re: [PATCH bpf-next v4 00/15] implement bpf iterator for tcp and udp sockets

2020-06-23 Thread Martin KaFai Lau
CONFIG_NET > (Martin) > - reuse the btf_ids, computed for new helper argument, for return > values (Martin) > - using BTF_TYPE_EMIT to express intent of btf type generation (Andrii) > - abstract out common net macros into bpf_tracing_net.h (Andrii) Acked-by: Martin KaFai Lau

Re: [bpf PATCH] bpf, sockmap: RCU splat with TLS redirect and strparser

2020-06-24 Thread Martin KaFai Lau
On Wed, Jun 24, 2020 at 02:09:23PM -0700, John Fastabend wrote: > Redirect on non-TLS sockmap side has RCU lock held from sockmap code > path but when called from TLS this is no longer true. The RCU section > is needed because we use rcu dereference to fetch the psock of the > socket we are redirec

Re: [PATCH bpf-next v3 1/4] flow_dissector: Pull BPF program assignment up to bpf-netns

2020-06-25 Thread Martin KaFai Lau
; pointer. This will let us do it all from one place, bpf/net_namespace.c, in > the subsequent patch. > > No functional change intended. Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next v3 2/4] bpf, netns: Keep attached programs in bpf_prog_array

2020-06-25 Thread Martin KaFai Lau
t bpf_link *links[MAX_NETNS_BPF_ATTACH_TYPE]; With the new run_array, I think the "*progs[]" is not needed. It seems the original "*progs[]" is only used to tell if it is in the prog_attach mode or the newer link mode. There is other ways to do that. It is something to thin

Re: [PATCH bpf-next v3 3/4] bpf, netns: Keep a list of attached bpf_link's

2020-06-25 Thread Martin KaFai Lau
i-prog attachment will be available only for bpf_link, and > we don't need to build a list of programs attached directly and indirectly > via links. Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next v3 4/4] selftests/bpf: Test updating flow_dissector link with same program

2020-06-25 Thread Martin KaFai Lau
mmary that fell out of sync when tests > extended to cover links. Acked-by: Martin KaFai Lau

Re: [bpf PATCH v2 1/3] bpf, sockmap: RCU splat with redirect and strparser error or TLS

2020-06-25 Thread Martin KaFai Lau
end the rcu_read_lock/unnlock block to > include the call to sk_psock_tls_verdict_apply(). This will fix both > TLS redirect case and non-TLS redirect+error case. Also remove > psock from the sk_psock_tls_verdict_apply() function signature its > not used there. Acked-by: Martin KaFai Lau

Re: [bpf PATCH v2 2/3] bpf, sockmap: RCU dereferenced psock may be used outside RCU block

2020-06-25 Thread Martin KaFai Lau
s seen above and > a performance issue. For example, in the Cilium case we always > set the strparser up to return sbks 1:1 without any merging and > have avoided above issues. Thanks for the details explanation. I have to admit that I cannot fully comprehend the concurrency situation in skmsg and psock. The change makes sense to me after reading the description though. Acked-by: Martin KaFai Lau

Re: [bpf PATCH v2 3/3] bpf, sockmap: Add ingres skb tests that utilize merge skbs

2020-06-25 Thread Martin KaFai Lau
On Thu, Jun 25, 2020 at 04:13:38PM -0700, John Fastabend wrote: > Add a test to check strparser merging skbs is working. Acked-by: Martin KaFai Lau

[PATCH bpf-next 00/10] BPF TCP header options

2020-06-26 Thread Martin KaFai Lau
info to the bpf program to make decision. Patch 4 is the main patch and has more details on the API and design. The set ends with an example which sends the max delay ack in the BPF TCP header option and the receiving side can then adjust its RTO accordingly. Martin KaFai Lau (10): tcp: Use a

[PATCH bpf-next 01/10] tcp: Use a struct to represent a saved_syn

2020-06-26 Thread Martin KaFai Lau
tter patch can then also gets the offset to the TCP bpf header option by "network header len + bpf_hdr_opt_off". Signed-off-by: Martin KaFai Lau --- include/linux/tcp.h| 11 ++- include/net/request_sock.h | 7 ++- net/core/filter.c | 4 ++-- net/ipv4/tc

[PATCH bpf-next 03/10] bpf: sock_ops: Change some members of sock_ops_kern from u32 to u8

2020-06-26 Thread Martin KaFai Lau
A latter patch needs to add a few pointers and a few u8 to sock_ops_kern. Hence, this patch saves some spaces by moving some of the existing members from u32 to u8 so that the latter patch can still fit everything in a cacheline. Signed-off-by: Martin KaFai Lau --- include/linux/filter.h | 4

[PATCH bpf-next 06/10] bpf: selftests: Add fastopen_connect to network_helpers

2020-06-26 Thread Martin KaFai Lau
This patch adds a fastopen_connect() helper which will be used in a latter test. Signed-off-by: Martin KaFai Lau --- tools/testing/selftests/bpf/network_helpers.c | 37 +++ tools/testing/selftests/bpf/network_helpers.h | 2 + 2 files changed, 39 insertions(+) diff --git a

[PATCH bpf-next 07/10] bpf: selftests: Restore netns after each test

2020-06-26 Thread Martin KaFai Lau
it after every test. Since the restore "setns()" is not expensive, it does it on all tests without tracking if a test has created a new netns or not. Signed-off-by: Martin KaFai Lau --- tools/testing/selftests/bpf/test_progs.c | 21 + tools/testing/selftests/bpf/te

[PATCH bpf-next 09/10] tcp: bpf: Add TCP_BPF_DELACK_MAX and TCP_BPF_RTO_MIN to bpf_setsockopt

2020-06-26 Thread Martin KaFai Lau
then use this max delay ack and set a potentially lower rto by using bpf_setsockopt(TCP_BPF_RTO_MIN). A latter patch will use it like this in a test as an example. Signed-off-by: Martin KaFai Lau --- include/net/inet_connection_sock.h | 2 ++ include/net/tcp.h | 2 +- include

[PATCH bpf-next 04/10] bpf: tcp: Allow bpf prog to write and parse BPF TCP header option

2020-06-26 Thread Martin KaFai Lau
is set, the bpf prog will be called in the "BPF_SOCK_OPS_PARSE_HDR_OPT_CB" op. The received skb will be available through sock_ops->skb_data and the bpf header option offset will also be specified in sock_ops->skb_bpf_hdr_opt_off. [1]: draft-wang-tcpm-low-latency-opt-00 http

[PATCH bpf-next 05/10] bpf: selftests: A few improvements to network_helpers.c

2020-06-26 Thread Martin KaFai Lau
lookup.c. Make changes to do it more consistently in save_errno_close() and log_err(). Signed-off-by: Martin KaFai Lau --- tools/testing/selftests/bpf/network_helpers.c | 157 +++--- tools/testing/selftests/bpf/network_helpers.h | 9 +- .../bpf/prog_tests/cgroup_skb_sk_lookup.

[PATCH bpf-next 10/10] bpf: selftest: Add test for TCP_BPF_DELACK_MAX and TCP_BPF_RTO_MIN

2020-06-26 Thread Martin KaFai Lau
This patch tests a bpf prog that parses/writes a max_delack_ms bpf header option and also bpf_setsockopt its TCP_BPF_DELACK_MAX/TCP_BPF_RTO_MIN accordingly. Signed-off-by: Martin KaFai Lau --- .../bpf/prog_tests/tcp_hdr_options.c | 6 ++-- .../bpf/progs/test_tcp_hdr_options.c

[PATCH bpf-next 08/10] bpf: selftests: tcp header options

2020-06-26 Thread Martin KaFai Lau
n a latter test. Signed-off-by: Martin KaFai Lau --- .../bpf/prog_tests/tcp_hdr_options.c | 520 ++ .../bpf/progs/test_tcp_hdr_options.c | 674 ++ .../selftests/bpf/test_tcp_hdr_options.h | 34 + 3 files changed, 1228 insertions(+) create mo

[PATCH bpf-next 02/10] tcp: bpf: Parse BPF experimental header option

2020-06-26 Thread Martin KaFai Lau
stores the offset to the bpf experimental option and will be made available to BPF prog in a latter patch. This offset is also stored in the saved_syn. Signed-off-by: Martin KaFai Lau --- include/net/request_sock.h | 1 + include/net/tcp.h | 3 +++ net/ipv4/tcp_input.c | 6 ++ net

Re: [Potential Spoof] [PATCH bpf-next 0/2] Support disabling auto-loading of BPF programs

2020-06-26 Thread Martin KaFai Lau
t support > necessary features, while falling back to reduced/less performant > functionality, if kernel is outdated. Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next 07/10] bpf: selftests: Restore netns after each test

2020-06-26 Thread Martin KaFai Lau
On Fri, Jun 26, 2020 at 03:45:04PM -0700, Andrii Nakryiko wrote: > On Fri, Jun 26, 2020 at 10:56 AM Martin KaFai Lau wrote: > > > > It is common for networking tests creating its netns and making its own > > setting under this new netns (e.g. changing tcp sysctl). If t

Re: [PATCH bpf-next 02/10] tcp: bpf: Parse BPF experimental header option

2020-06-28 Thread Martin KaFai Lau
On Sat, Jun 27, 2020 at 10:17:26AM -0700, Eric Dumazet wrote: > On Fri, Jun 26, 2020 at 10:55 AM Martin KaFai Lau wrote: > > > > This patch adds logic to parse experimental kind 254 with 16 bit magic > > 0xeB9F. The latter patch will allow bpf prog to write and pars

Re: [PATCH bpf-next 04/10] bpf: tcp: Allow bpf prog to write and parse BPF TCP header option

2020-06-28 Thread Martin KaFai Lau
On Sun, Jun 28, 2020 at 11:24:27AM -0700, Alexei Starovoitov wrote: > On Fri, Jun 26, 2020 at 10:55:26AM -0700, Martin KaFai Lau wrote: > > > > Parsing BPF Header Option > > ─ > > > > As mentioned earlier, the received SYN/SYNACK/ACK duri

Re: [PATCH bpf-next 02/10] tcp: bpf: Parse BPF experimental header option

2020-06-28 Thread Martin KaFai Lau
On Sat, Jun 27, 2020 at 10:17:26AM -0700, Eric Dumazet wrote: [ ... ] > It seems strange that we want to add code in TCP stack only to cover a > limited use case (kind 254 and 0xEB9F magic) > > For something like the work Petar Penkov did (to be able to generate > SYNCOOKIES from XDP), we do not

Re: [PATCH bpf-next 07/10] bpf: selftests: Restore netns after each test

2020-06-29 Thread Martin KaFai Lau
On Sat, Jun 27, 2020 at 01:31:42PM -0700, Andrii Nakryiko wrote: > On Fri, Jun 26, 2020 at 5:23 PM Martin KaFai Lau wrote: > > > > On Fri, Jun 26, 2020 at 03:45:04PM -0700, Andrii Nakryiko wrote: > > > On Fri, Jun 26, 2020 at 10:56 AM Martin KaFai Lau wrote: > >

Re: [PATCH bpf-next 07/10] bpf: selftests: Restore netns after each test

2020-06-29 Thread Martin KaFai Lau
On Mon, Jun 29, 2020 at 11:13:07AM -0700, Andrii Nakryiko wrote: > On Mon, Jun 29, 2020 at 11:00 AM Martin KaFai Lau wrote: > > > > On Sat, Jun 27, 2020 at 01:31:42PM -0700, Andrii Nakryiko wrote: > > > On Fri, Jun 26, 2020 at 5:23 PM Martin KaFai Lau wrote: > > &g

Re: [PATCH bpf-next 02/17] bpf: Introduce SK_LOOKUP program type with a dedicated attach point

2020-05-07 Thread Martin KaFai Lau
On Wed, May 06, 2020 at 03:53:35PM +0200, Jakub Sitnicki wrote: > On Wed, May 06, 2020 at 03:16 PM CEST, Lorenz Bauer wrote: > > On Wed, 6 May 2020 at 13:55, Jakub Sitnicki wrote: > > [...] > > >> @@ -4012,4 +4051,18 @@ struct bpf_pidns_info { > >> __u32 pid; > >> __u32 tgid; > >

Re: [PATCH bpf-next 02/17] bpf: Introduce SK_LOOKUP program type with a dedicated attach point

2020-05-08 Thread Martin KaFai Lau
On Wed, May 06, 2020 at 02:54:58PM +0200, Jakub Sitnicki wrote: > Add a new program type BPF_PROG_TYPE_SK_LOOKUP and a dedicated attach type > called BPF_SK_LOOKUP. The new program kind is to be invoked by the > transport layer when looking up a socket for a received packet. > > When called, SK_LO

Re: [PATCH bpf-next v4 2/4] selftests/bpf: move existing common networking parts into network_helpers

2020-05-08 Thread Martin KaFai Lau
On Thu, May 07, 2020 at 12:12:13PM -0700, Stanislav Fomichev wrote: > 1. Move pkt_v4 and pkt_v6 into network_helpers and adjust the users. > 2. Copy-paste spin_lock_thread into two tests that use it. > > Cc: Martin KaFai Lau > Signed-off-by: Stanislav Fomichev Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next v4 1/4] selftests/bpf: generalize helpers to control background listener

2020-05-08 Thread Martin KaFai Lau
tified by fd > > These will be used in the next commit. > > Also, extend these helpers to support AF_INET6 and accept the family > as an argument. > > v4: > * export extra helper to start server without a thread (Martin KaFai Lau) > * tcp_rtt is no longer starting backg

Re: [PATCH bpf-next 02/17] bpf: Introduce SK_LOOKUP program type with a dedicated attach point

2020-05-08 Thread Martin KaFai Lau
On Fri, May 08, 2020 at 12:45:14PM +0200, Jakub Sitnicki wrote: > On Fri, May 08, 2020 at 09:06 AM CEST, Martin KaFai Lau wrote: > > On Wed, May 06, 2020 at 02:54:58PM +0200, Jakub Sitnicki wrote: > >> Add a new program type BPF_PROG_TYPE_SK_LOOKUP and a dedicated attac

Re: [PATCH bpf-next 02/17] bpf: Introduce SK_LOOKUP program type with a dedicated attach point

2020-05-11 Thread Martin KaFai Lau
On Mon, May 11, 2020 at 11:08:15AM +0200, Jakub Sitnicki wrote: > On Fri, May 08, 2020 at 08:39 PM CEST, Martin KaFai Lau wrote: > > On Fri, May 08, 2020 at 12:45:14PM +0200, Jakub Sitnicki wrote: > >> On Fri, May 08, 2020 at 09:06 AM CEST, Martin KaFai Lau wrote: > >> &

Re: [PATCH bpf-next v2 00/17] Run a BPF program on socket lookup

2020-05-11 Thread Martin KaFai Lau
On Mon, May 11, 2020 at 08:52:01PM +0200, Jakub Sitnicki wrote: [ ... ] > Performance considerations > == > > Patch set adds new code on receive hot path. This comes with a cost, > especially in a scenario of a SYN flood or small UDP packet flood. > > Measuring the perfo

Re: [PATCH bpf-next 02/17] bpf: Introduce SK_LOOKUP program type with a dedicated attach point

2020-05-11 Thread Martin KaFai Lau
On Mon, May 11, 2020 at 09:26:02PM +0200, Jakub Sitnicki wrote: > On Mon, May 11, 2020 at 08:59 PM CEST, Martin KaFai Lau wrote: > > On Mon, May 11, 2020 at 11:08:15AM +0200, Jakub Sitnicki wrote: > >> On Fri, May 08, 2020 at 08:39 PM CEST, Martin KaFai Lau wrote: > >> &

Re: [PATCH bpf-next v2 00/17] Run a BPF program on socket lookup

2020-05-12 Thread Martin KaFai Lau
On Tue, May 12, 2020 at 01:57:45PM +0200, Jakub Sitnicki wrote: > On Mon, May 11, 2020 at 09:45 PM CEST, Martin KaFai Lau wrote: > > On Mon, May 11, 2020 at 08:52:01PM +0200, Jakub Sitnicki wrote: > > > > [ ... ] > > > >> Performance considerations > >&g

Re: [PATCH bpf-next v2 02/17] bpf: Introduce SK_LOOKUP program type with a dedicated attach point

2020-05-12 Thread Martin KaFai Lau
On Mon, May 11, 2020 at 08:52:03PM +0200, Jakub Sitnicki wrote: [ ... ] > +BPF_CALL_3(bpf_sk_lookup_assign, struct bpf_sk_lookup_kern *, ctx, > +struct sock *, sk, u64, flags) The SK_LOOKUP bpf_prog may have already selected the proper reuseport sk. It is possible by looking up sk from so

Re: [PATCH bpf-next v2 02/17] bpf: Introduce SK_LOOKUP program type with a dedicated attach point

2020-05-13 Thread Martin KaFai Lau
On Wed, May 13, 2020 at 04:34:13PM +0200, Jakub Sitnicki wrote: > On Wed, May 13, 2020 at 07:41 AM CEST, Martin KaFai Lau wrote: > > On Mon, May 11, 2020 at 08:52:03PM +0200, Jakub Sitnicki wrote: > > > > [ ... ] > > > >> +BPF_CALL_3(bpf_sk_lookup_assi

Re: [PATCH bpf-next] bpf: add SO_KEEPALIVE and related options to bpf_setsockopt

2020-05-27 Thread Martin KaFai Lau
ger value and do not need ns_capable()), do_tcp_setsockopt() and sock_setsockopt() can be directly called with some refactoring. The change looks good. For this patch, Acked-by: Martin KaFai Lau

Re: [PATCH v2 bpf-next 1/3] bpf: Consolidate inner-map-compatible properties into bpf_types.h

2020-05-28 Thread Martin KaFai Lau
On Tue, May 26, 2020 at 10:54:26AM -0700, Andrii Nakryiko wrote: > On Fri, May 22, 2020 at 6:01 PM Martin KaFai Lau wrote: > > > > On Sat, May 23, 2020 at 12:22:48AM +0200, Daniel Borkmann wrote: > > > On 5/22/20 4:23 AM, Martin KaFai Lau wrote: > > > [...] > &

[PATCH net] net: inet_csk: Fix so_reuseport bind-address cache in tb->fast*

2020-05-18 Thread Martin KaFai Lau
match_sk1_wildcard" and "bool match_sk2_wildcard". This change only affects the sk_reuseport_match() which is only used by inet_csk (e.g. TCP). The other use cases are calling inet_rcv_saddr_equal() and this patch makes it pass the same "match_wildcard" arg twice to the "ip

[PATCH bpf-next 1/3] bpf: Clean up inner map type check

2020-05-21 Thread Martin KaFai Lau
l be less error prone to decide its capability at the same place as the new map type is added in bpf_types.h. That will help to avoid mistake like missing modification in other source files like the map_in_map.c here. Cc: Andrey Ignatov Signed-off-by: Martin KaFai Lau --- include/linux/b

[PATCH bpf-next 0/3] bpf: Allow inner map with different max_entries

2020-05-21 Thread Martin KaFai Lau
This series allows the outer map to be updated with inner map in different size as long as it is safe (meaning the max_entries is not used in the verification time during prog load). Please see individual patch for details. Martin KaFai Lau (3): bpf: Clean up inner map type check bpf: Relax

[PATCH bpf-next 2/3] bpf: Relax the max_entries check for inner map

2020-05-21 Thread Martin KaFai Lau
xskmap are used statically in verification time to generate the inline code, so they are excluded in this patch. Cc: Andrey Ignatov Signed-off-by: Martin KaFai Lau --- include/linux/bpf.h | 12 include/linux/bpf_types.h | 6 -- kernel/bpf/map_in_map.c | 3 ++- 3 files

[PATCH bpf-next 3/3] bpf: selftests: Add test for different inner map size

2020-05-21 Thread Martin KaFai Lau
This patch tests the inner map size can be different for reuseport_sockarray but has to be the same for arraymap. Cc: Andrey Ignatov Signed-off-by: Martin KaFai Lau --- .../selftests/bpf/prog_tests/btf_map_in_map.c | 12 +++ .../selftests/bpf/progs/test_btf_map_in_map.c | 31

Re: [PATCH bpf-next 0/3] bpf: Allow inner map with different max_entries

2020-05-21 Thread Martin KaFai Lau
On Thu, May 21, 2020 at 03:39:10PM -0700, Andrii Nakryiko wrote: > On Thu, May 21, 2020 at 12:18 PM Martin KaFai Lau wrote: > > > > This series allows the outer map to be updated with inner map in different > > size as long as it is safe (meaning the max_entri

Re: [PATCH bpf-next 0/3] bpf: Allow inner map with different max_entries

2020-05-21 Thread Martin KaFai Lau
On Thu, May 21, 2020 at 04:16:18PM -0700, Alexei Starovoitov wrote: > On Thu, May 21, 2020 at 04:10:36PM -0700, Andrii Nakryiko wrote: > > > > 4. Then for size check change, again, it's really much simpler and > > > > cleaner just to have a special case in check in bpf_map_meta_equal for > > > > ca

[PATCH v2 bpf-next 1/3] bpf: Consolidate inner-map-compatible properties into bpf_types.h

2020-05-21 Thread Martin KaFai Lau
one when a map's properties is decided at the same place as the new map type is added in bpf_types.h. That will help to avoid mistake like missing modification in other source files like the map_in_map.c here or other source files in the future. Cc: Andrey Ignatov Signed-off-by: Martin KaFai Lau

[PATCH v2 bpf-next 2/3] bpf: Relax the max_entries check for inner map

2020-05-21 Thread Martin KaFai Lau
with a smaller inner map first and then replaces it with a larger inner map later when it is needed. The max_entries of arraymap and xskmap are used statically in verification time to generate the inline code, so they are excluded in this patch. Cc: Andrey Ignatov Signed-off-by: Martin KaFai Lau

[PATCH v2 bpf-next 0/3] bpf: Allow inner map with different max_entries

2020-05-21 Thread Martin KaFai Lau
time during prog load). Please see individual patch for details. v2: - New BPF_MAP_TYPE_FL to minimize code churns (Alexei) - s/capabilities/properties/ (Andrii) - Describe WHY in commit log (Andrii) Martin KaFai Lau (3): bpf: Consolidate inner-map-compatible properties into bpf_types.h bpf

[PATCH v2 bpf-next 3/3] bpf: selftests: Add test for different inner map size

2020-05-21 Thread Martin KaFai Lau
This patch tests the inner map size can be different for reuseport_sockarray but has to be the same for arraymap. Cc: Andrey Ignatov Signed-off-by: Martin KaFai Lau --- .../selftests/bpf/prog_tests/btf_map_in_map.c | 12 +++ .../selftests/bpf/progs/test_btf_map_in_map.c | 31

Re: [PATCH v2 bpf-next 1/3] bpf: Consolidate inner-map-compatible properties into bpf_types.h

2020-05-22 Thread Martin KaFai Lau
On Sat, May 23, 2020 at 12:22:48AM +0200, Daniel Borkmann wrote: > On 5/22/20 4:23 AM, Martin KaFai Lau wrote: > [...] > > }; > > +/* Cannot be used as an inner map */ > > +#define BPF_MAP_NO_INNER_MAP (1 << 0) > > + > > struct bpf_map { > >

Re: [PATCH bpf-next] bpf: bpf_{g,s}etsockopt for struct bpf_sock

2020-04-29 Thread Martin KaFai Lau
On Tue, Apr 28, 2020 at 11:57:19AM -0700, Stanislav Fomichev wrote: > Currently, bpf_getsocktop and bpf_setsockopt helpers operate on the > 'struct bpf_sock_ops' context in BPF_PROG_TYPE_CGROUP_SOCKOPT program. > Let's generalize them and make the first argument be 'struct bpf_sock'. > That way, in

Re: [PATCH bpf-next v1 07/19] bpf: create anonymous bpf iterator

2020-04-29 Thread Martin KaFai Lau
On Wed, Apr 29, 2020 at 11:16:35AM -0700, Andrii Nakryiko wrote: > On Wed, Apr 29, 2020 at 12:07 AM Yonghong Song wrote: > > > > > > > > On 4/28/20 11:56 PM, Andrii Nakryiko wrote: > > > On Mon, Apr 27, 2020 at 1:19 PM Yonghong Song wrote: > > >> > > >> A new bpf command BPF_ITER_CREATE is added.

Re: [PATCH bpf-next v1 07/19] bpf: create anonymous bpf iterator

2020-04-29 Thread Martin KaFai Lau
On Wed, Apr 29, 2020 at 12:20:05PM -0700, Yonghong Song wrote: > > > On 4/29/20 11:46 AM, Martin KaFai Lau wrote: > > On Wed, Apr 29, 2020 at 11:16:35AM -0700, Andrii Nakryiko wrote: > > > On Wed, Apr 29, 2020 at 12:07 AM Yonghong Song wrote: > > > > > &

Re: [PATCH bpf-next v3] bpf: bpf_{g,s}etsockopt for struct bpf_sock_addr

2020-04-30 Thread Martin KaFai Lau
> v3: > * Expose custom helpers for bpf_sock_addr context instead of doing > generic bpf_sock argument (as suggested by Daniel). Even with > try_socket_lock that doesn't sleep we have a problem where context sk > is already locked and socket lock is non-nestable. Acked-by: Martin KaFai Lau

Re: [Potential Spoof] [PATCH bpf-next] bpf: fix use-after-free of bpf_link when priming half-fails

2020-04-30 Thread Martin KaFai Lau
On Thu, Apr 30, 2020 at 12:46:08PM -0700, Andrii Nakryiko wrote: > If bpf_link_prime() succeeds to allocate new anon file, but then fails to > allocate ID for it, link priming is considered to be failed and user is > supposed ot be able to directly kfree() bpf_link, because it was never exposed > t

Re: [Potential Spoof] [PATCH bpf-next] bpf: fix use-after-free of bpf_link when priming half-fails

2020-05-01 Thread Martin KaFai Lau
On Thu, Apr 30, 2020 at 11:32:59PM -0700, Andrii Nakryiko wrote: > On Thu, Apr 30, 2020 at 11:25 PM Martin KaFai Lau wrote: > > > > On Thu, Apr 30, 2020 at 12:46:08PM -0700, Andrii Nakryiko wrote: > > > If bpf_link_prime() succeeds to allocate new anon file, but then fa

Re: [PATCH v2 bpf-next] bpf: fix use-after-free of bpf_link when priming half-fails

2020-05-01 Thread Martin KaFai Lau
file. Adding ID to > link_idr is ok, because link at that point still doesn't have its ID set, so > no user-space process can create a new FD for it. Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next] selftests/bpf: use reno instead of dctcp

2020-05-01 Thread Martin KaFai Lau
On Fri, May 01, 2020 at 03:43:20PM -0700, Stanislav Fomichev wrote: > Andrey pointed out that we can use reno instead of dctcp for CC > tests and drop CONFIG_TCP_CONG_DCTCP=y requirement. Acked-by: Martin KaFai Lau

Re: [PATCH] sysctl: fix unused function warning

2020-05-05 Thread Martin KaFai Lau
27;bpf_stats_handler' > [-Werror,-Wunused-function] > static int bpf_stats_handler(struct ctl_table *table, int write, > > Fix the check to match the reference. > > Fixes: d46edd671a14 ("bpf: Sharing bpf runtime stats with BPF_ENABLE_STATS") > Signed-off-by: Arnd Bergmann Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next 3/4] net: refactor arguments of inet{,6}_bind

2020-05-05 Thread Martin KaFai Lau
On Mon, May 04, 2020 at 10:34:29AM -0700, Stanislav Fomichev wrote: > The intent is to add an additional bind parameter in the next commit. > Instead of adding another argument, let's convert all existing > flag arguments into an extendable bit field. > > No functional changes. > > Cc: Andrey Ign

Re: [PATCH 1/2] bpf: sockmap, msg_pop_data can incorrecty set an sge length

2020-05-05 Thread Martin KaFai Lau
this. > > Fixes: 7246d8ed4dcce ("bpf: helper to pop data from messages") > Signed-off-by: John Fastabend Acked-by: Martin KaFai Lau

Re: [PATCH 2/2] bpf: sockmap, bpf_tcp_ingress needs to subtract bytes from sg.size

2020-05-05 Thread Martin KaFai Lau
_elem+0xdd/0x120 > [ 173.700060] kasan_report+0x32/0x50 > [ 173.700070] sk_msg_free_elem+0xdd/0x120 > [ 173.700080] __sk_msg_free+0x87/0x150 > [ 173.700094] tcp_bpf_send_verdict+0x179/0x4f0 > [ 173.700109] tcp_bpf_sendpage+0x3ce/0x5d0 > > Fixes: 604326b41a6fb ("bpf, sockmap: convert to generic sk_msg interface") > Signed-off-by: John Fastabend Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next v2 4/5] bpf: allow any port in bpf_bind helper

2020-05-05 Thread Martin KaFai Lau
On Tue, May 05, 2020 at 01:27:29PM -0700, Stanislav Fomichev wrote: > We want to have a tighter control on what ports we bind to in > the BPF_CGROUP_INET{4,6}_CONNECT hooks even if it means > connect() becomes slightly more expensive. The expensive part > comes from the fact that we now need to cal

Re: [PATCH bpf-next v2 1/5] selftests/bpf: generalize helpers to control background listener

2020-05-06 Thread Martin KaFai Lau
On Tue, May 05, 2020 at 01:27:26PM -0700, Stanislav Fomichev wrote: > Move the following routines that let us start a background listener > thread and connect to a server by fd to the test_prog: > * start_server_thread - start background INADDR_ANY thread > * stop_server_thread - stop the thread >

Re: [PATCH bpf-next v2 1/5] selftests/bpf: generalize helpers to control background listener

2020-05-06 Thread Martin KaFai Lau
On Wed, May 06, 2020 at 09:28:02AM -0700, s...@google.com wrote: > On 05/06, Martin KaFai Lau wrote: > > On Tue, May 05, 2020 at 01:27:26PM -0700, Stanislav Fomichev wrote: > > > Move the following routines that let us start a background listener > > > thread and conne

Re: [PATCH bpf-next v2 4/5] bpf: allow any port in bpf_bind helper

2020-05-06 Thread Martin KaFai Lau
On Wed, May 06, 2020 at 09:22:45AM -0700, s...@google.com wrote: > On 05/05, Martin KaFai Lau wrote: > > On Tue, May 05, 2020 at 01:27:29PM -0700, Stanislav Fomichev wrote: > > > We want to have a tighter control on what ports we bind to in > > > the BPF_CGROUP_INET{4,

Re: [PATCH v2] bpf, i386: remove unneeded conversion to bool

2020-05-06 Thread Martin KaFai Lau
On Wed, May 06, 2020 at 10:03:52PM +0800, Jason Yan wrote: > The '==' expression itself is bool, no need to convert it to bool again. > This fixes the following coccicheck warning: Make sense. It may belong to bpf-next instead. Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next v3 1/5] selftests/bpf: generalize helpers to control background listener

2020-05-06 Thread Martin KaFai Lau
p the thread > * connect_to_fd - connect to the server identified by fd > > These will be used in the next commit. > > Also, extend these helpers to support AF_INET6 and accept the family > as an argument. > > v3: > * export extra helper to start server without a thr

Re: [PATCH bpf-next v3 3/5] selftests/bpf: move existing common networking parts into network_helpers

2020-05-06 Thread Martin KaFai Lau
On Wed, May 06, 2020 at 03:32:08PM -0700, Stanislav Fomichev wrote: > 1. Move pkt_v4 and pkt_v6 into network_helpers and adjust the users. > 2. Copy-paste spin_lock_thread into two tests that use it. Instead of copying it into two tests, can spin_lock_thread be moved to network-helpers.c?

Re: [PATCH bpf-next v3 4/5] net: refactor arguments of inet{,6}_bind

2020-05-06 Thread Martin KaFai Lau
ges. > > Cc: Andrey Ignatov > Cc: Martin KaFai Lau > Signed-off-by: Stanislav Fomichev Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next v3 5/5] bpf: allow any port in bpf_bind helper

2020-05-06 Thread Martin KaFai Lau
nd flag > to indicate that the call site is BPF program. > > v3: > * More bpf_bind documentation refinements (Martin KaFai Lau) > * Add UDP tests as well (Martin KaFai Lau) > * Don't start the thread, just do socket+bind+listen (Martin KaFai Lau) > > v2: > * Update d

[PATCH net] ipv4: tcp: Fix SO_MARK in RST and ACK packet

2020-06-30 Thread Martin KaFai Lau
ing the ipc.sockc.mark to fl4.flowi4_mark. Fixes: c6af0c227a22 ("ip: support SO_MARK cmsg") Cc: Willem de Bruijn Signed-off-by: Martin KaFai Lau --- net/ipv4/ip_output.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 090d3097ee15..03

<    3   4   5   6   7   8   9   10   11   12   >