[PATCH v3 bpf-next 11/11] bpf: Test BPF_SK_REUSEPORT_SELECT_OR_MIGRATE.

2021-04-20 Thread Kuniyuki Iwashima
This patch adds a test for BPF_SK_REUSEPORT_SELECT_OR_MIGRATE and removes 'static' from settimeo() in network_helpers.c. Signed-off-by: Kuniyuki Iwashima --- tools/testing/selftests/bpf/network_helpers.c | 2 +- tools/testing/selftests/bpf/network_helpers.h | 1 + .../bpf/prog_tests

[PATCH v3 bpf-next 10/11] libbpf: Set expected_attach_type for BPF_PROG_TYPE_SK_REUSEPORT.

2021-04-20 Thread Kuniyuki Iwashima
This commit introduces a new section (sk_reuseport/migrate) and sets expected_attach_type to two each section in BPF_PROG_TYPE_SK_REUSEPORT program. Signed-off-by: Kuniyuki Iwashima --- tools/lib/bpf/libbpf.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/lib/bpf

[PATCH v3 bpf-next 09/11] bpf: Support socket migration by eBPF.

2021-04-20 Thread Kuniyuki Iwashima
Suggested-by: Martin KaFai Lau Signed-off-by: Kuniyuki Iwashima --- include/linux/bpf.h| 1 + include/linux/filter.h | 2 ++ include/uapi/linux/bpf.h | 15 +++ kernel/bpf/syscall.c | 13 + net/core/filter.c | 13 -

[PATCH v3 bpf-next 01/11] net: Introduce net.ipv4.tcp_migrate_req.

2021-04-20 Thread Kuniyuki Iwashima
This commit adds a new sysctl option: net.ipv4.tcp_migrate_req. If this option is enabled or eBPF program is attached, we will be able to migrate child sockets from a listener to another in the same reuseport group after close() or shutdown() syscalls. Signed-off-by: Kuniyuki Iwashima Reviewed

[PATCH v3 bpf-next 08/11] bpf: Support BPF_FUNC_get_socket_cookie() for BPF_PROG_TYPE_SK_REUSEPORT.

2021-04-20 Thread Kuniyuki Iwashima
-by: Kuniyuki Iwashima --- include/uapi/linux/bpf.h | 1 + net/core/filter.c | 10 ++ tools/include/uapi/linux/bpf.h | 1 + 3 files changed, 12 insertions(+) diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index 49371eba98ba..ab8584701334 100644 --- a/include

[PATCH v3 bpf-next 07/11] tcp: Migrate TCP_NEW_SYN_RECV requests at receiving the final ACK.

2021-04-20 Thread Kuniyuki Iwashima
PU 1 loses the race CPU 3 looks up req2, unhashes it, then CPU 2 loses the race ... Signed-off-by: Kuniyuki Iwashima --- net/ipv4/inet_connection_sock.c | 30 +- net/ipv4/tcp_ipv4.c | 20 ++-- net/ipv6/tcp_ipv6.c | 14 +++

[PATCH v3 bpf-next 06/11] tcp: Migrate TCP_NEW_SYN_RECV requests at retransmitting SYN+ACKs.

2021-04-20 Thread Kuniyuki Iwashima
new timer will recover this situation. Signed-off-by: Kuniyuki Iwashima --- net/core/request_sock.c | 1 + net/ipv4/inet_connection_sock.c | 76 + 2 files changed, 68 insertions(+), 9 deletions(-) diff --git a/net/core/request_sock.c b/net/core/request_so

[PATCH v3 bpf-next 05/11] tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues.

2021-04-20 Thread Kuniyuki Iwashima
tps://lore.kernel.org/netdev/20201209030903.hhow5r53l6fmo...@kafai-mbp.dhcp.thefacebook.com/ Suggested-by: Martin KaFai Lau Signed-off-by: Kuniyuki Iwashima --- include/net/request_sock.h | 2 ++ net/core/request_sock.c | 37 + net/ipv4/inet_connection_soc

[PATCH v3 bpf-next 04/11] tcp: Add reuseport_migrate_sock() to select a new listener.

2021-04-20 Thread Kuniyuki Iwashima
to decrement it later. We will support migration by eBPF in the later commits. Signed-off-by: Kuniyuki Iwashima Signed-off-by: Martin KaFai Lau --- include/net/sock_reuseport.h | 3 ++ net/core/sock_reuseport.c| 78 +--- 2 files changed, 67 insertions

[PATCH v3 bpf-next 03/11] tcp: Keep TCP_CLOSE sockets in the reuseport group.

2021-04-20 Thread Kuniyuki Iwashima
- we cannot attach an eBPF prog to listening sockets via shutdowned sockets Note that when the number of sockets gets over U16_MAX, we try to detach a closed socket randomly to make room for the new listening socket in reuseport_grow(). Signed-off-by: Kuniyuki Iwashima Signed-off-by: Martin

[PATCH v3 bpf-next 02/11] tcp: Add num_closed_socks to struct sock_reuseport.

2021-04-20 Thread Kuniyuki Iwashima
_socks. Signed-off-by: Kuniyuki Iwashima --- include/net/sock_reuseport.h | 5 ++- net/core/sock_reuseport.c| 76 +++- 2 files changed, 60 insertions(+), 21 deletions(-) diff --git a/include/net/sock_reuseport.h b/include/net/sock_reuseport.h index 505f1e

[PATCH v3 bpf-next 00/11] Socket migration for SO_REUSEPORT.

2021-04-20 Thread Kuniyuki Iwashima
ges and coverletter RFC: https://lore.kernel.org/netdev/20201117094023.3685-1-kun...@amazon.co.jp/ Kuniyuki Iwashima (11): net: Introduce net.ipv4.tcp_migrate_req. tcp: Add num_closed_socks to struct sock_reuseport. tcp: Keep TCP_CLOSE sockets in the reuseport group. tcp:

[PATCH v5 net-next] net: Remove redundant calls of sk_tx_queue_clear().

2021-01-28 Thread Kuniyuki Iwashima
ore, this patch adds a compile-time check to take care of the order of sock_copy() and sk_tx_queue_clear() and removes sk_tx_queue_clear() from sk_prot_alloc() so that it does the only allocation and its callers initialize fields. CC: Tariq Toukan CC: Boris Pismenny Signed-off-by: Kuniyuki Iwash

Re: [PATCH v4 net-next] net: Remove redundant calls of sk_tx_queue_clear().

2021-01-28 Thread Kuniyuki Iwashima
From: Tariq Toukan Date: Thu, 28 Jan 2021 15:09:51 +0200 > On 1/28/2021 2:42 PM, Kuniyuki Iwashima wrote: > > The commit 41b14fb8724d ("net: Do not clear the sock TX queue in > > sk_set_socket()") removes sk_tx_queue_clear() from sk_set_socket() and adds &

[PATCH v4 net-next] net: Remove redundant calls of sk_tx_queue_clear().

2021-01-28 Thread Kuniyuki Iwashima
ewed-by: tag v1: https://lore.kernel.org/netdev/20210127125018.7059-1-kun...@amazon.co.jp/ CC: Tariq Toukan CC: Boris Pismenny Signed-off-by: Kuniyuki Iwashima --- net/core/sock.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/net/core/sock.c b/net/core/so

Re: [PATCH v3 net-next] net: Remove redundant calls of sk_tx_queue_clear().

2021-01-28 Thread Kuniyuki Iwashima
From: Tariq Toukan Date: Thu, 28 Jan 2021 13:07:26 +0200 > On 1/28/2021 4:19 AM, Kuniyuki Iwashima wrote: > > The commit 41b14fb8724d ("net: Do not clear the sock TX queue in > > sk_set_socket()") removes sk_tx_queue_clear() from sk_set_socket() and adds &

[PATCH v3 net-next] net: Remove redundant calls of sk_tx_queue_clear().

2021-01-27 Thread Kuniyuki Iwashima
) from sk_prot_alloc() instead of sk_alloc() and sk_clone_lock() v2: https://lore.kernel.org/netdev/20210127132215.10842-1-kun...@amazon.co.jp/ * Remove Reviewed-by: tag v1: https://lore.kernel.org/netdev/20210127125018.7059-1-kun...@amazon.co.jp/ CC: Tariq Toukan CC: Boris Pismenny Signed-off-b

Re: [PATCH net] net: Remove redundant calls of sk_tx_queue_clear().

2021-01-27 Thread Kuniyuki Iwashima
From: Eric Dumazet Date: Wed, 27 Jan 2021 19:07:51 +0100 > On Wed, Jan 27, 2021 at 6:56 PM Kuniyuki Iwashima wrote: > > > > From: Eric Dumazet > > Date: Wed, 27 Jan 2021 18:34:35 +0100 > > > On Wed, Jan 27, 2021 at 6:32 PM Kuniyuki Iwashima > > &

Re: [PATCH net] net: Remove redundant calls of sk_tx_queue_clear().

2021-01-27 Thread Kuniyuki Iwashima
From: Eric Dumazet Date: Wed, 27 Jan 2021 18:34:35 +0100 > On Wed, Jan 27, 2021 at 6:32 PM Kuniyuki Iwashima wrote: > > > > From: Eric Dumazet > > Date: Wed, 27 Jan 2021 18:05:24 +0100 > > > On Wed, Jan 27, 2021 at 5:52 PM Kuniyuki Iwashima > > &

Re: [PATCH net] net: Remove redundant calls of sk_tx_queue_clear().

2021-01-27 Thread Kuniyuki Iwashima
From: Eric Dumazet Date: Wed, 27 Jan 2021 18:05:24 +0100 > On Wed, Jan 27, 2021 at 5:52 PM Kuniyuki Iwashima wrote: > > > > From: Eric Dumazet > > Date: Wed, 27 Jan 2021 15:54:32 +0100 > > > On Wed, Jan 27, 2021 at 1:50 PM Kuniyuki Iwashima > >

Re: [PATCH net] net: Remove redundant calls of sk_tx_queue_clear().

2021-01-27 Thread Kuniyuki Iwashima
From: Eric Dumazet Date: Wed, 27 Jan 2021 15:54:32 +0100 > On Wed, Jan 27, 2021 at 1:50 PM Kuniyuki Iwashima wrote: > > > > The commit 41b14fb8724d ("net: Do not clear the sock TX queue in > > sk_set_socket()") removes sk_tx_queue_clear() from sk_set_s

RE: [PATCH net] net: Remove redundant calls of sk_tx_queue_clear().

2021-01-27 Thread Kuniyuki Iwashima
From: Kuniyuki Iwashima Date: Wed, 27 Jan 2021 21:50:18 +0900 > The commit 41b14fb8724d ("net: Do not clear the sock TX queue in > sk_set_socket()") removes sk_tx_queue_clear() from sk_set_socket() and adds > it instead in sk_alloc() and sk_clone_lock() to fix

[PATCH v2 net] net: Remove redundant calls of sk_tx_queue_clear().

2021-01-27 Thread Kuniyuki Iwashima
Fixes: 41b14fb8724d ("net: Do not clear the sock TX queue in sk_set_socket()") CC: Tariq Toukan CC: Boris Pismenny Signed-off-by: Kuniyuki Iwashima --- net/core/sock.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/net/core/sock.c b/net/core/sock.c index bbcd4b97eddd..5c665ee1415

[PATCH net] net: Remove redundant calls of sk_tx_queue_clear().

2021-01-27 Thread Kuniyuki Iwashima
Fixes: 41b14fb8724d ("net: Do not clear the sock TX queue in sk_set_socket()") CC: Tariq Toukan CC: Boris Pismenny Signed-off-by: Kuniyuki Iwashima Reviewed-by: Amit Shah --- net/core/sock.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/net/core/sock.c b/net/core/sock.c index bbc

[PATCH net] tcp: Fix potential use-after-free due to double kfree().

2021-01-17 Thread Kuniyuki Iwashima
t in IPv4. Fixes: 01770a166165 ("tcp: fix race condition when creating child sockets from syncookies") CC: Ricardo Dias Signed-off-by: Kuniyuki Iwashima Reviewed-by: Benjamin Herrenschmidt --- net/ipv4/tcp_ipv4.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/

Re: [PATCH v1 bpf-next 05/11] tcp: Migrate TCP_NEW_SYN_RECV requests.

2020-12-16 Thread Kuniyuki Iwashima
From: Martin KaFai Lau Date: Mon, 14 Dec 2020 18:58:37 -0800 > On Tue, Dec 15, 2020 at 02:03:13AM +0900, Kuniyuki Iwashima wrote: > > From: Martin KaFai Lau > > Date: Thu, 10 Dec 2020 10:49:15 -0800 > > > On Thu, Dec 10, 2020 at 02:15:38PM +0900, Kuniyuki Iwas

Re: [PATCH v1 bpf-next 03/11] tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues.

2020-12-14 Thread Kuniyuki Iwashima
From: Martin KaFai Lau Date: Thu, 10 Dec 2020 11:33:40 -0800 > On Thu, Dec 10, 2020 at 02:58:10PM +0900, Kuniyuki Iwashima wrote: > > [ ... ] > > > > > I've implemented one-by-one migration only for the accept queue for now. > > > > In addition to th

Re: [PATCH v1 bpf-next 05/11] tcp: Migrate TCP_NEW_SYN_RECV requests.

2020-12-14 Thread Kuniyuki Iwashima
From: Martin KaFai Lau Date: Thu, 10 Dec 2020 10:49:15 -0800 > On Thu, Dec 10, 2020 at 02:15:38PM +0900, Kuniyuki Iwashima wrote: > > From: Martin KaFai Lau > > Date: Wed, 9 Dec 2020 16:07:07 -0800 > > > On Tue, Dec 01, 2020 at 11:44:12PM +0900,

Re: [PATCH v1 bpf-next 03/11] tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues.

2020-12-09 Thread Kuniyuki Iwashima
From: Martin KaFai Lau Date: Wed, 9 Dec 2020 17:53:19 -0800 > On Thu, Dec 10, 2020 at 01:57:19AM +0900, Kuniyuki Iwashima wrOAote: > [ ... ] > > > > > > I think it is a bit complex to pass the new listener from > > > > > reusepor

Re: [PATCH v1 bpf-next 05/11] tcp: Migrate TCP_NEW_SYN_RECV requests.

2020-12-09 Thread Kuniyuki Iwashima
From: Martin KaFai Lau Date: Wed, 9 Dec 2020 16:07:07 -0800 > On Tue, Dec 01, 2020 at 11:44:12PM +0900, Kuniyuki Iwashima wrote: > > This patch renames reuseport_select_sock() to __reuseport_select_sock() and > > adds two wrapper function of it to pass the migrati

Re: [PATCH v1 bpf-next 03/11] tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues.

2020-12-09 Thread Kuniyuki Iwashima
From: Kuniyuki Iwashima Date: Wed, 9 Dec 2020 17:05:09 +0900 > From: Martin KaFai Lau > Date: Tue, 8 Dec 2020 19:09:03 -0800 > > On Tue, Dec 08, 2020 at 05:17:48PM +0900, Kuniyuki Iwashima wrote: > > > From: Martin KaFai Lau > > > Date: Mon, 7 Dec 2020

Re: [PATCH v1 bpf-next 03/11] tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues.

2020-12-09 Thread Kuniyuki Iwashima
From: Martin KaFai Lau Date: Tue, 8 Dec 2020 19:09:03 -0800 > On Tue, Dec 08, 2020 at 05:17:48PM +0900, Kuniyuki Iwashima wrote: > > From: Martin KaFai Lau > > Date: Mon, 7 Dec 2020 23:34:41 -0800 > > > On Tue, Dec 08, 2020 at 03:31:34PM +0900, Kuniyuki Iwas

Re: [PATCH v1 bpf-next 03/11] tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues.

2020-12-08 Thread Kuniyuki Iwashima
From: Martin KaFai Lau Date: Tue, 8 Dec 2020 00:13:28 -0800 > On Tue, Dec 08, 2020 at 03:27:14PM +0900, Kuniyuki Iwashima wrote: > > From: Martin KaFai Lau > > Date: Mon, 7 Dec 2020 12:14:38 -0800 > > > On Sun, Dec 06, 2020 at 01:03:07AM +0900, Kuniyuki Iwas

Re: [PATCH v1 bpf-next 03/11] tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues.

2020-12-08 Thread Kuniyuki Iwashima
From: Martin KaFai Lau Date: Mon, 7 Dec 2020 23:34:41 -0800 > On Tue, Dec 08, 2020 at 03:31:34PM +0900, Kuniyuki Iwashima wrote: > > From: Martin KaFai Lau > > Date: Mon, 7 Dec 2020 12:33:15 -0800 > > > On Thu, Dec 03, 2020 at 11:14:24PM +0900, Kuniyuki Iwas

Re: [PATCH v1 bpf-next 03/11] tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues.

2020-12-07 Thread Kuniyuki Iwashima
From: Martin KaFai Lau Date: Mon, 7 Dec 2020 22:54:18 -0800 > On Tue, Dec 01, 2020 at 11:44:10PM +0900, Kuniyuki Iwashima wrote: > > > @@ -242,8 +244,12 @@ void reuseport_detach_sock(struct sock *sk) > > > > reuse->num_socks--; > >

Re: [PATCH v1 bpf-next 03/11] tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues.

2020-12-07 Thread Kuniyuki Iwashima
From: Martin KaFai Lau Date: Mon, 7 Dec 2020 12:33:15 -0800 > On Thu, Dec 03, 2020 at 11:14:24PM +0900, Kuniyuki Iwashima wrote: > > From: Eric Dumazet > > Date: Tue, 1 Dec 2020 16:25:51 +0100 > > > On 12/1/20 3:44 PM, Kuniyuki Iwashima wrote:

Re: [PATCH v1 bpf-next 03/11] tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues.

2020-12-07 Thread Kuniyuki Iwashima
From: Martin KaFai Lau Date: Mon, 7 Dec 2020 12:14:38 -0800 > On Sun, Dec 06, 2020 at 01:03:07AM +0900, Kuniyuki Iwashima wrote: > > From: Martin KaFai Lau > > Date: Fri, 4 Dec 2020 17:42:41 -0800 > > > On Tue, Dec 01, 2020 at 11:44:10PM +0900,

[PATCH v2 bpf-next 13/13] bpf: Test BPF_SK_REUSEPORT_SELECT_OR_MIGRATE.

2020-12-07 Thread Kuniyuki Iwashima
This patch adds a test for BPF_SK_REUSEPORT_SELECT_OR_MIGRATE. Reviewed-by: Benjamin Herrenschmidt Signed-off-by: Kuniyuki Iwashima --- .../bpf/prog_tests/select_reuseport_migrate.c | 173 ++ .../bpf/progs/test_select_reuseport_migrate.c | 53 ++ 2 files changed, 226

[PATCH v2 bpf-next 12/13] bpf: Call bpf_run_sk_reuseport() for socket migration.

2020-12-07 Thread Kuniyuki Iwashima
, and the sk_hash of the listener is always zero. So we pass zero as hash to bpf_run_sk_reuseport(). Reviewed-by: Benjamin Herrenschmidt Signed-off-by: Kuniyuki Iwashima --- net/core/filter.c | 19 +++ net/core/sock_reuseport.c | 21 +++-- net/ipv4

[PATCH v2 bpf-next 11/13] bpf: Support BPF_FUNC_get_socket_cookie() for BPF_PROG_TYPE_SK_REUSEPORT.

2020-12-07 Thread Kuniyuki Iwashima
-off-by: Kuniyuki Iwashima --- include/uapi/linux/bpf.h | 8 net/core/filter.c | 22 ++ tools/include/uapi/linux/bpf.h | 8 3 files changed, 38 insertions(+) diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index

[PATCH v2 bpf-next 10/13] bpf: Add migration to sk_reuseport_(kern|md).

2020-12-07 Thread Kuniyuki Iwashima
is BPF_SK_REUSEPORT_SELECT_OR_MIGRATE. Link: https://lore.kernel.org/netdev/20201123003828.xjpjdtk4ygl6t...@kafai-mbp.dhcp.thefacebook.com/ Suggested-by: Martin KaFai Lau Signed-off-by: Kuniyuki Iwashima --- include/linux/bpf.h| 1 + include/linux/filter.h | 4 ++-- include

[PATCH v2 bpf-next 09/13] libbpf: Set expected_attach_type for BPF_PROG_TYPE_SK_REUSEPORT.

2020-12-07 Thread Kuniyuki Iwashima
This commit introduces a new section (sk_reuseport/migrate) and sets expected_attach_type to two each section in BPF_PROG_TYPE_SK_REUSEPORT program. Signed-off-by: Kuniyuki Iwashima --- tools/lib/bpf/libbpf.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/lib/bpf

[PATCH v2 bpf-next 08/13] bpf: Introduce two attach types for BPF_PROG_TYPE_SK_REUSEPORT.

2020-12-07 Thread Kuniyuki Iwashima
-mbp.dhcp.thefacebook.com/ Suggested-by: Martin KaFai Lau Signed-off-by: Kuniyuki Iwashima --- include/uapi/linux/bpf.h | 2 ++ kernel/bpf/syscall.c | 13 + tools/include/uapi/linux/bpf.h | 2 ++ 3 files changed, 17 insertions(+) diff --git a/include/uapi/linux/bpf.h b

[PATCH v2 bpf-next 07/13] tcp: Migrate TCP_NEW_SYN_RECV requests.

2020-12-07 Thread Kuniyuki Iwashima
from the reuseport group, we rewrite request_sock.rsk_listener and resume processing the request. Link: https://lore.kernel.org/bpf/202012020136.bf0z4guu-...@intel.com/ Reported-by: kernel test robot Reviewed-by: Benjamin Herrenschmidt Signed-off-by: Kuniyuki Iwashima --- include/net

[PATCH v2 bpf-next 06/13] tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues.

2020-12-07 Thread Kuniyuki Iwashima
m/ Reviewed-by: Benjamin Herrenschmidt Signed-off-by: Kuniyuki Iwashima --- include/net/sock_reuseport.h | 2 +- net/core/sock_reuseport.c| 16 +--- net/ipv4/inet_hashtables.c | 9 +++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/include/net/sock_r

[PATCH v2 bpf-next 05/13] tcp: Set the new listener to migrated TFO requests.

2020-12-07 Thread Kuniyuki Iwashima
stener to it at accept() before reqsk_fastopen_remove(). Reviewed-by: Benjamin Herrenschmidt Signed-off-by: Kuniyuki Iwashima --- net/ipv4/inet_connection_sock.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c

[PATCH v2 bpf-next 04/13] tcp: Introduce inet_csk_reqsk_queue_migrate().

2020-12-07 Thread Kuniyuki Iwashima
->rsk_listener. However, in the third case of TCP_SYN_RECV sockets, we take special care in the next commit. Reviewed-by: Benjamin Herrenschmidt Signed-off-by: Kuniyuki Iwashima --- include/net/inet_connection_sock.h | 1 + net/ipv4/inet_connection_sock.c| 68 ++

[PATCH v2 bpf-next 03/13] Revert "locking/spinlocks: Remove the unused spin_lock_bh_nested() API"

2020-12-07 Thread Kuniyuki Iwashima
This reverts commit 607904c357c61adf20b8fd18af765e501d61a385 to use spin_lock_bh_nested() in the next commit. Link: https://lore.kernel.org/netdev/9d290a57-49e1-04cd-2487-262b0d7c5...@gmail.com/ Signed-off-by: Kuniyuki Iwashima CC: Waiman Long --- include/linux/spinlock.h | 8

[PATCH v2 bpf-next 02/13] bpf: Define migration types for SO_REUSEPORT.

2020-12-07 Thread Kuniyuki Iwashima
/SYN_RECV sockets in the accept queue or NEW_SYN_RECV socket during 3WHS. Signed-off-by: Kuniyuki Iwashima --- include/uapi/linux/bpf.h | 14 ++ tools/include/uapi/linux/bpf.h | 14 ++ 2 files changed, 28 insertions(+) diff --git a/include/uapi/linux/bpf.h b/include

[PATCH v2 bpf-next 01/13] tcp: Allow TCP_CLOSE sockets to hold the reuseport group.

2020-12-07 Thread Kuniyuki Iwashima
rules so that the socket can listen again if it has the same reuseport group with other listening sockets. Reviewed-by: Benjamin Herrenschmidt Signed-off-by: Kuniyuki Iwashima --- include/net/sock_reuseport.h| 5 +++-- net/core/sock_reuseport.c | 39

[PATCH v2 bpf-next 00/13] Socket migration for SO_REUSEPORT.

2020-12-07 Thread Kuniyuki Iwashima
req_to_sk(req)->sk_hash because listener's hash is zero * Update commit messages and coverletter RFC: https://lore.kernel.org/netdev/20201117094023.3685-1-kun...@amazon.co.jp/ Kuniyuki Iwashima (13): tcp: Allow TCP_CLOSE sockets to hold the reuseport group. bpf: Define migration ty

Re: [PATCH v1 bpf-next 11/11] bpf: Test BPF_SK_REUSEPORT_SELECT_OR_MIGRATE.

2020-12-05 Thread Kuniyuki Iwashima
I'm sending this mail just for logging because I failed to send mails only to LKML, netdev, and bpf yesterday. From: Martin KaFai Lau Date: Fri, 4 Dec 2020 17:50:00 -0800 > On Tue, Dec 01, 2020 at 11:44:18PM +0900, Kuniyuki Iwashima wrote: > > This patch ad

Re: [PATCH v1 bpf-next 03/11] tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues.

2020-12-05 Thread Kuniyuki Iwashima
I'm sending this mail just for logging because I failed to send mails only to LKML, netdev, and bpf yesterday. From: Martin KaFai Lau Date: Fri, 4 Dec 2020 17:42:41 -0800 > On Tue, Dec 01, 2020 at 11:44:10PM +0900, Kuniyuki Iwashima wrote: > [ ... ] > > diff --gi

Re: [PATCH v1 bpf-next 01/11] tcp: Keep TCP_CLOSE sockets in the reuseport group.

2020-12-05 Thread Kuniyuki Iwashima
I'm sending this mail just for logging because I failed to send mails only to LKML, netdev, and bpf yesterday. From: Martin KaFai Lau Date: Fri, 4 Dec 2020 17:31:03 -0800 > On Tue, Dec 01, 2020 at 11:44:08PM +0900, Kuniyuki Iwashima wrote: > > This patch is a preparation patch t

Re: [PATCH v1 bpf-next 09/11] bpf: Support bpf_get_socket_cookie_sock() for BPF_PROG_TYPE_SK_REUSEPORT.

2020-12-05 Thread Kuniyuki Iwashima
I'm sending this mail just for logging because I failed to send mails only to LKML, netdev, and bpf yesterday. From: Martin KaFai Lau Date: Fri, 4 Dec 2020 11:58:07 -0800 > On Tue, Dec 01, 2020 at 11:44:16PM +0900, Kuniyuki Iwashima wrote: > > We will call sock_reuseport.prog f

Re: [PATCH v1 bpf-next 06/11] bpf: Introduce two attach types for BPF_PROG_TYPE_SK_REUSEPORT.

2020-12-05 Thread Kuniyuki Iwashima
I'm sending this mail just for logging because I failed to send mails only to LKML, netdev, and bpf yesterday. From: Martin KaFai Lau Date: Thu, 3 Dec 2020 21:56:53 -0800 > On Thu, Dec 03, 2020 at 11:16:08PM +0900, Kuniyuki Iwashima wrote: > > From: Martin KaFai Lau > >

Re: [PATCH v1 bpf-next 03/11] tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues.

2020-12-03 Thread Kuniyuki Iwashima
From: Eric Dumazet Date: Thu, 3 Dec 2020 15:31:53 +0100 > On Thu, Dec 3, 2020 at 3:14 PM Kuniyuki Iwashima wrote: > > > > From: Eric Dumazet > > Date: Tue, 1 Dec 2020 16:25:51 +0100 > > > On 12/1/20 3:44 PM, Kuniyuki Iwashima wrote: > > > > This

Re: [PATCH v1 bpf-next 06/11] bpf: Introduce two attach types for BPF_PROG_TYPE_SK_REUSEPORT.

2020-12-03 Thread Kuniyuki Iwashima
From: Martin KaFai Lau Date: Wed, 2 Dec 2020 20:24:02 -0800 > On Wed, Dec 02, 2020 at 11:19:02AM -0800, Martin KaFai Lau wrote: > > On Tue, Dec 01, 2020 at 06:04:50PM -0800, Andrii Nakryiko wrote: > > > On Tue, Dec 1, 2020 at 6:49 AM Kuniyuki Iwas

Re: [PATCH v1 bpf-next 03/11] tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues.

2020-12-03 Thread Kuniyuki Iwashima
From: Eric Dumazet Date: Tue, 1 Dec 2020 16:25:51 +0100 > On 12/1/20 3:44 PM, Kuniyuki Iwashima wrote: > > This patch lets reuseport_detach_sock() return a pointer of struct sock, > > which is used only by inet_unhash(). If it is not NULL, > > inet_csk_reqsk_que

Re: [PATCH v1 bpf-next 05/11] tcp: Migrate TCP_NEW_SYN_RECV requests.

2020-12-03 Thread Kuniyuki Iwashima
From: Eric Dumazet Date: Tue, 1 Dec 2020 16:13:39 +0100 > On 12/1/20 3:44 PM, Kuniyuki Iwashima wrote: > > This patch renames reuseport_select_sock() to __reuseport_select_sock() and > > adds two wrapper function of it to pass the migration type defined in the >

[PATCH v1 bpf-next 10/11] bpf: Call bpf_run_sk_reuseport() for socket migration.

2020-12-01 Thread Kuniyuki Iwashima
, and the sk_hash of the listener is always zero. Thus, we pass zero as hash to bpf_run_sk_reuseport(). Reviewed-by: Benjamin Herrenschmidt Signed-off-by: Kuniyuki Iwashima --- net/core/filter.c | 19 +++ net/core/sock_reuseport.c | 19 ++- net/ipv4

[PATCH v1 bpf-next 09/11] bpf: Support bpf_get_socket_cookie_sock() for BPF_PROG_TYPE_SK_REUSEPORT.

2020-12-01 Thread Kuniyuki Iwashima
-off-by: Kuniyuki Iwashima --- include/uapi/linux/bpf.h | 8 net/core/filter.c | 12 +++- tools/include/uapi/linux/bpf.h | 8 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index

[PATCH v1 bpf-next 11/11] bpf: Test BPF_SK_REUSEPORT_SELECT_OR_MIGRATE.

2020-12-01 Thread Kuniyuki Iwashima
This patch adds a test for BPF_SK_REUSEPORT_SELECT_OR_MIGRATE. Reviewed-by: Benjamin Herrenschmidt Signed-off-by: Kuniyuki Iwashima --- .../bpf/prog_tests/migrate_reuseport.c| 164 ++ .../bpf/progs/test_migrate_reuseport_kern.c | 54 ++ 2 files changed, 218

[PATCH v1 bpf-next 08/11] bpf: Add migration to sk_reuseport_(kern|md).

2020-12-01 Thread Kuniyuki Iwashima
is BPF_SK_REUSEPORT_SELECT_OR_MIGRATE. Link: https://lore.kernel.org/netdev/20201123003828.xjpjdtk4ygl6t...@kafai-mbp.dhcp.thefacebook.com/ Suggested-by: Martin KaFai Lau Signed-off-by: Kuniyuki Iwashima --- include/linux/bpf.h| 1 + include/linux/filter.h | 4 ++-- include

[PATCH v1 bpf-next 07/11] libbpf: Set expected_attach_type for BPF_PROG_TYPE_SK_REUSEPORT.

2020-12-01 Thread Kuniyuki Iwashima
This commit introduces a new section (sk_reuseport/migrate) and sets expected_attach_type to two each section in BPF_PROG_TYPE_SK_REUSEPORT program. Signed-off-by: Kuniyuki Iwashima --- tools/lib/bpf/libbpf.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/lib/bpf

[PATCH v1 bpf-next 06/11] bpf: Introduce two attach types for BPF_PROG_TYPE_SK_REUSEPORT.

2020-12-01 Thread Kuniyuki Iwashima
-mbp.dhcp.thefacebook.com/ Suggested-by: Martin KaFai Lau Signed-off-by: Kuniyuki Iwashima --- include/uapi/linux/bpf.h | 2 ++ kernel/bpf/syscall.c | 8 tools/include/uapi/linux/bpf.h | 2 ++ 3 files changed, 12 insertions(+) diff --git a/include/uapi/linux/bpf.h b/include

[PATCH v1 bpf-next 05/11] tcp: Migrate TCP_NEW_SYN_RECV requests.

2020-12-01 Thread Kuniyuki Iwashima
from the reuseport group, we rewrite request_sock.rsk_listener and resume processing the request. Reviewed-by: Benjamin Herrenschmidt Signed-off-by: Kuniyuki Iwashima --- include/net/inet_connection_sock.h | 12 +++ include/net/request_sock.h | 13 include/net

[PATCH v1 bpf-next 01/11] tcp: Keep TCP_CLOSE sockets in the reuseport group.

2020-12-01 Thread Kuniyuki Iwashima
not have the reuseport group. Therefore, this patch also loosens such validation rules so that the socket can listen again if it has the same reuseport group with other listening sockets. Reviewed-by: Benjamin Herrenschmidt Signed-off-by: Kuniyuki Iwashima --- include/net/sock_reuseport.h| 5

[PATCH v1 bpf-next 04/11] tcp: Migrate TFO requests causing RST during TCP_SYN_RECV.

2020-12-01 Thread Kuniyuki Iwashima
stener to it at accept() before reqsk_fastopen_remove(). Moreover, if TFO request caused RST before 3WHS has completed, it is held in the listener's TFO queue to prevent DDoS attack. Thus, we also have to migrate the requests in TFO queue. Reviewed-by: Benjamin Herrenschmidt Signed-off-by: Kuniyuki Iw

[PATCH v1 bpf-next 03/11] tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues.

2020-12-01 Thread Kuniyuki Iwashima
use an error. Therefore, if there are different kinds of sockets, we must attach an eBPF program described in later commits. Link: https://lore.kernel.org/netdev/CAEfhGiyG8Y_amDZ2C8dQoQqjZJMHjTY76b=KBkTKcBtA=dh...@mail.gmail.com/ Reviewed-by: Benjamin Herrenschmidt Signed-off-by: Kuniyuki Iw

[PATCH v1 bpf-next 02/11] bpf: Define migration types for SO_REUSEPORT.

2020-12-01 Thread Kuniyuki Iwashima
/SYN_RECV sockets in the accept queue or NEW_SYN_RECV socket during 3WHS. Signed-off-by: Kuniyuki Iwashima --- include/uapi/linux/bpf.h | 14 ++ tools/include/uapi/linux/bpf.h | 14 ++ 2 files changed, 28 insertions(+) diff --git a/include/uapi/linux/bpf.h b/include

[PATCH v1 bpf-next 00/11] Socket migration for SO_REUSEPORT.

2020-12-01 Thread Kuniyuki Iwashima
* Pass req_to_sk(req)->sk_hash because listener's hash is zero * Update commit messages and coverletter RFC v0: https://lore.kernel.org/netdev/20201117094023.3685-1-kun...@amazon.co.jp/ Kuniyuki Iwashima (11): tcp: Keep TCP_CLOSE sockets in the reuseport group. bpf: Define migrat

Re: [RFC PATCH bpf-next 3/8] tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues.

2020-11-24 Thread Kuniyuki Iwashima
From: Martin KaFai Lau Date: Sun, 22 Nov 2020 16:40:20 -0800 > On Sat, Nov 21, 2020 at 07:13:22PM +0900, Kuniyuki Iwashima wrote: > > From: Martin KaFai Lau > > Date: Thu, 19 Nov 2020 17:53:46 -0800 > > > On Fri, Nov 20, 2020 at 07:09:22AM +0900, Kuniyuki Iwas

Re: [RFC PATCH bpf-next 0/8] Socket migration for SO_REUSEPORT.

2020-11-21 Thread Kuniyuki Iwashima
From: Martin KaFai Lau Date: Thu, 19 Nov 2020 18:31:57 -0800 > On Fri, Nov 20, 2020 at 07:17:49AM +0900, Kuniyuki Iwashima wrote: > > From: Martin KaFai Lau > > Date: Wed, 18 Nov 2020 17:49:13 -0800 > > > On Tue, Nov 17, 2020 at 06:40:15PM +0900,

Re: [RFC PATCH bpf-next 3/8] tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues.

2020-11-21 Thread Kuniyuki Iwashima
From: Martin KaFai Lau Date: Thu, 19 Nov 2020 17:53:46 -0800 > On Fri, Nov 20, 2020 at 07:09:22AM +0900, Kuniyuki Iwashima wrote: > > From: Martin KaFai Lau > > Date: Wed, 18 Nov 2020 15:50:17 -0800 > > > On Tue, Nov 17, 2020 at 06:40:18PM +0900, Kuniyuki Iwashima w

Re: [RFC PATCH bpf-next 0/8] Socket migration for SO_REUSEPORT.

2020-11-19 Thread Kuniyuki Iwashima
From: Martin KaFai Lau Date: Wed, 18 Nov 2020 17:49:13 -0800 > On Tue, Nov 17, 2020 at 06:40:15PM +0900, Kuniyuki Iwashima wrote: > > The SO_REUSEPORT option allows sockets to listen on the same port and to > > accept connections evenly. However, there is a defect

Re: [RFC PATCH bpf-next 7/8] bpf: Call bpf_run_sk_reuseport() for socket migration.

2020-11-19 Thread Kuniyuki Iwashima
From: Martin KaFai Lau Date: Wed, 18 Nov 2020 17:00:45 -0800 > On Tue, Nov 17, 2020 at 06:40:22PM +0900, Kuniyuki Iwashima wrote: > > This patch makes it possible to select a new listener for socket migration > > by eBPF. > > > > The noteworthy point is that w

Re: [RFC PATCH bpf-next 6/8] bpf: Add cookie in sk_reuseport_md.

2020-11-19 Thread Kuniyuki Iwashima
From: Martin KaFai Lau Date: Wed, 18 Nov 2020 16:11:54 -0800 > On Tue, Nov 17, 2020 at 06:40:21PM +0900, Kuniyuki Iwashima wrote: > > We will call sock_reuseport.prog for socket migration in the next commit, > > so the eBPF program has to know which listener is closing in orde

Re: [RFC PATCH bpf-next 3/8] tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues.

2020-11-19 Thread Kuniyuki Iwashima
From: Martin KaFai Lau Date: Wed, 18 Nov 2020 15:50:17 -0800 > On Tue, Nov 17, 2020 at 06:40:18PM +0900, Kuniyuki Iwashima wrote: > > This patch lets reuseport_detach_sock() return a pointer of struct sock, > > which is used only by inet_unhash(). If

Re: [RFC PATCH bpf-next 0/8] Socket migration for SO_REUSEPORT.

2020-11-19 Thread Kuniyuki Iwashima
From: Eric Dumazet Date: Wed, 18 Nov 2020 17:25:44 +0100 > On 11/17/20 10:40 AM, Kuniyuki Iwashima wrote: > > The SO_REUSEPORT option allows sockets to listen on the same port and to > > accept connections evenly. However, there is a defect in the current > > implementati

RE: [RFC PATCH bpf-next 0/8] Socket migration for SO_REUSEPORT.

2020-11-19 Thread Kuniyuki Iwashima
From: David Laight Date: Wed, 18 Nov 2020 09:18:24 + > From: Kuniyuki Iwashima > > Sent: 17 November 2020 09:40 > > > > The SO_REUSEPORT option allows sockets to listen on the same port and to > > accept connections evenly. However, there is a defect in the

[RFC PATCH bpf-next 1/8] net: Introduce net.ipv4.tcp_migrate_req.

2020-11-17 Thread Kuniyuki Iwashima
This commit adds a new sysctl option: net.ipv4.tcp_migrate_req. If this option is enabled, and then we call listen() for SO_REUSEPORT enabled sockets and close one, we will be able to migrate its child sockets to another listener. Reviewed-by: Benjamin Herrenschmidt Signed-off-by: Kuniyuki

[RFC PATCH bpf-next 2/8] tcp: Keep TCP_CLOSE sockets in the reuseport group.

2020-11-17 Thread Kuniyuki Iwashima
() or inet_csk_bind_conflict() which expect that such sockets should not have the reuseport group. Therefore, this patch loosens such validation rules so that the socket can listen again if it has the same reuseport group with other listening sockets. Reviewed-by: Benjamin Herrenschmidt Signed-off-by: Kuniyuki Iwashima

[RFC PATCH bpf-next 6/8] bpf: Add cookie in sk_reuseport_md.

2020-11-17 Thread Kuniyuki Iwashima
() for BPF_MAP_TYPE_REUSEPORT_SOCKARRAY map. This patch exposes the ID to the eBPF program. Reviewed-by: Benjamin Herrenschmidt Signed-off-by: Kuniyuki Iwashima --- include/linux/bpf.h| 1 + include/uapi/linux/bpf.h | 1 + net/core/filter.c | 8 tools/include/uapi/linux/bpf.h | 1 + 4

[RFC PATCH bpf-next 4/8] tcp: Migrate TFO requests causing RST during TCP_SYN_RECV.

2020-11-17 Thread Kuniyuki Iwashima
accept() before reqsk_fastopen_remove(). Moreover, if TFO request caused RST before 3WHS has completed, it is held in the listener's TFO queue to prevent DDoS attack. Thus, we also have to migrate the requests in TFO queue. Reviewed-by: Benjamin Herrenschmidt Signed-off-by: Kuniyuki Iwashima --- ne

[RFC PATCH bpf-next 7/8] bpf: Call bpf_run_sk_reuseport() for socket migration.

2020-11-17 Thread Kuniyuki Iwashima
API level or when we want to free resources as soon as possible. Reviewed-by: Benjamin Herrenschmidt Signed-off-by: Kuniyuki Iwashima --- net/core/filter.c | 26 +- net/core/sock_reuseport.c | 23 --- net/ipv4/inet_hashtables.c | 2 +- 3

[RFC PATCH bpf-next 8/8] bpf: Test BPF_PROG_TYPE_SK_REUSEPORT for socket migration.

2020-11-17 Thread Kuniyuki Iwashima
This patch adds a test for net.ipv4.tcp_migrate_req with eBPF. Reviewed-by: Benjamin Herrenschmidt Signed-off-by: Kuniyuki Iwashima --- .../bpf/prog_tests/migrate_reuseport.c| 175 ++ .../bpf/progs/test_migrate_reuseport_kern.c | 53 ++ 2 files changed, 228

[RFC PATCH bpf-next 3/8] tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues.

2020-11-17 Thread Kuniyuki Iwashima
later commits. Reviewed-by: Benjamin Herrenschmidt Signed-off-by: Kuniyuki Iwashima Link: https://lore.kernel.org/netdev/CAEfhGiyG8Y_amDZ2C8dQoQqjZJMHjTY76b=KBkTKcBtA=dh...@mail.gmail.com/ --- include/net/inet_connection_sock.h | 1 + include/net/sock_reuseport.h | 2 +- net/core/sock_r

[RFC PATCH bpf-next 0/8] Socket migration for SO_REUSEPORT.

2020-11-17 Thread Kuniyuki Iwashima
have to use eBPF program to select a specific listener or to cancel migration. Kuniyuki Iwashima (8): net: Introduce net.ipv4.tcp_migrate_req. tcp: Keep TCP_CLOSE sockets in the reuseport group. tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues. tcp: Migrate TFO requests

[RFC PATCH bpf-next 5/8] tcp: Migrate TCP_NEW_SYN_RECV requests.

2020-11-17 Thread Kuniyuki Iwashima
migrated sockets at close() or shutdown() syscalls, so we redistribute the requests evenly. As regards the second, we will cover in a later commit. Reviewed-by: Benjamin Herrenschmidt Signed-off-by: Kuniyuki Iwashima --- include/net/inet_connection_sock.h | 12 include/net/request_sock.h

Re: linux-next: manual merge of the bpf-next tree with the net tree

2020-07-22 Thread Kuniyuki Iwashima
From: Jakub Sitnicki Date: Wed, 22 Jul 2020 14:17:05 +0200 > On Wed, Jul 22, 2020 at 05:21 AM CEST, Stephen Rothwell wrote: > > Hi all, > > > > Today's linux-next merge of the bpf-next tree got conflicts in: > > > > net/ipv4/udp.c > > net/ipv6/udp.c > > > > between commit: > > > >