Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2203187pxj; Sun, 16 May 2021 18:28:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgkzlEPR6C7ak/r5Domvk2om9dbE61I6tPTx/oQrodizwu9+Q9YS+eGxiM1n3n4bAUZujA X-Received: by 2002:a17:906:b191:: with SMTP id w17mr59753537ejy.200.1621214887027; Sun, 16 May 2021 18:28:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621214887; cv=none; d=google.com; s=arc-20160816; b=n8+/qPIBkNWnFS8AdKN4cYlxXyEc5XWVnwpUb/K2mCif/bZmVoEaduMzwgUHGV2jry TcLOmCfiHvZJRKRAesxcvw0h5NaVsJ14szXpHO+WZdRGlrpX4b9t3QnE6W0OGMIrypMM c8r95CexSff8BUJ3e41qpi1XgiD9lKsBwqhEzVfNuIeiff9ZHW/dLSs/j4MmPMTJYbMl ug2cCcLnXQn4336VGT9xppVQfwhzKoAc8TKdJBc5dywe8/N5qXe4gJ67hexw67941p57 U7JpImn1tmuZ42s3B0E06bhzc5AxOrb1bub8aC0Sgq7gq399WAojV+xMnya3dfqJ/pwt 3ddA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6ZO03lKQ/WPNVG3UvYnIANaz4hxB8S0MeSpixn0HSFY=; b=038c17CRsabyrqUovOiTR/yutJFGpwyYJ0KdKVtZ/AV66tAzmaDzeoqMjnr1sY4SCv oNC98ZfpYUWy3EUdyCbTEQBhYGOdlZfCrOVIYis7mwGWw1spZu0hAYDyDfuhOxqfGvEd sakD7Ch0L5NIY4/PdmKp6wtS3f4fNmwbLESHEVyge2XGZ1YN4HLTlh3JWYu8QO6uI7wt y0KmHFgrqpBKEWoeK9TIfCgC0vPv9awmNafAxlO9JfYxK40YM8kp6P7cOtY7qh4uUWTb 6TjF/jq79NRnoMdIDO1Z0jaMU4i4ndZDDj/wcqlT6AfUoEUIDiMO0cz4FhLDmynYAVN1 NOjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.co.jp header.s=amazon201209 header.b=EKohoHp0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.co.jp Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y13si452978edq.98.2021.05.16.18.27.42; Sun, 16 May 2021 18:28:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.co.jp header.s=amazon201209 header.b=EKohoHp0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.co.jp Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234765AbhEQAYz (ORCPT + 99 others); Sun, 16 May 2021 20:24:55 -0400 Received: from smtp-fw-6002.amazon.com ([52.95.49.90]:31649 "EHLO smtp-fw-6002.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234712AbhEQAYz (ORCPT ); Sun, 16 May 2021 20:24:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.co.jp; i=@amazon.co.jp; q=dns/txt; s=amazon201209; t=1621211020; x=1652747020; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6ZO03lKQ/WPNVG3UvYnIANaz4hxB8S0MeSpixn0HSFY=; b=EKohoHp0D3XmHZYcWPfjpjb0jp6WIwqFW352XtT4hleg0eMsSWM4eNBD rYTzWcyf9yj3j+XtnCs1LnKHqqH49H66HXWBbWDDyNbi8kVXzJweq28gk 7lWHmqXqKwW4JoWWMW4K+svYoqxUE/MQWVQc+h6ScGWF1WZny5GDyenIy I=; X-IronPort-AV: E=Sophos;i="5.82,306,1613433600"; d="scan'208";a="112501580" Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1d-38ae4ad2.us-east-1.amazon.com) ([10.43.8.2]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP; 17 May 2021 00:23:39 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-1d-38ae4ad2.us-east-1.amazon.com (Postfix) with ESMTPS id 3A849A1DF3; Mon, 17 May 2021 00:23:36 +0000 (UTC) Received: from EX13D04ANC001.ant.amazon.com (10.43.157.89) by EX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 17 May 2021 00:23:36 +0000 Received: from 88665a182662.ant.amazon.com (10.43.162.28) by EX13D04ANC001.ant.amazon.com (10.43.157.89) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 17 May 2021 00:23:31 +0000 From: Kuniyuki Iwashima To: "David S . Miller" , Jakub Kicinski , Eric Dumazet , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau CC: Benjamin Herrenschmidt , Kuniyuki Iwashima , Kuniyuki Iwashima , , , Subject: [PATCH v6 bpf-next 01/11] net: Introduce net.ipv4.tcp_migrate_req. Date: Mon, 17 May 2021 09:22:48 +0900 Message-ID: <20210517002258.75019-2-kuniyu@amazon.co.jp> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210517002258.75019-1-kuniyu@amazon.co.jp> References: <20210517002258.75019-1-kuniyu@amazon.co.jp> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.43.162.28] X-ClientProxiedBy: EX13D21UWA004.ant.amazon.com (10.43.160.252) To EX13D04ANC001.ant.amazon.com (10.43.157.89) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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-by: Benjamin Herrenschmidt Acked-by: Martin KaFai Lau --- Documentation/networking/ip-sysctl.rst | 25 +++++++++++++++++++++++++ include/net/netns/ipv4.h | 1 + net/ipv4/sysctl_net_ipv4.c | 9 +++++++++ 3 files changed, 35 insertions(+) diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst index c2ecc9894fd0..22c80b0d2208 100644 --- a/Documentation/networking/ip-sysctl.rst +++ b/Documentation/networking/ip-sysctl.rst @@ -732,6 +732,31 @@ tcp_syncookies - INTEGER network connections you can set this knob to 2 to enable unconditionally generation of syncookies. +tcp_migrate_req - BOOLEAN + The incoming connection is tied to a specific listening socket when + the initial SYN packet is received during the three-way handshake. + When a listener is closed, in-flight request sockets during the + handshake and established sockets in the accept queue are aborted. + + If the listener has SO_REUSEPORT enabled, other listeners on the + same port should have been able to accept such connections. This + option makes it possible to migrate such child sockets to another + listener after close() or shutdown(). + + The BPF_SK_REUSEPORT_SELECT_OR_MIGRATE type of eBPF program should + usually be used to define the policy to pick an alive listener. + Otherwise, the kernel will randomly pick an alive listener only if + this option is enabled. + + Note that migration between listeners with different settings may + crash applications. Let's say migration happens from listener A to + B, and only B has TCP_SAVE_SYN enabled. B cannot read SYN data from + the requests migrated from A. To avoid such a situation, cancel + migration by returning SK_DROP in the type of eBPF program, or + disable this option. + + Default: 0 + tcp_fastopen - INTEGER Enable TCP Fast Open (RFC7413) to send and accept data in the opening SYN packet. diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h index f6af8d96d3c6..fd63c91addcc 100644 --- a/include/net/netns/ipv4.h +++ b/include/net/netns/ipv4.h @@ -126,6 +126,7 @@ struct netns_ipv4 { u8 sysctl_tcp_syn_retries; u8 sysctl_tcp_synack_retries; u8 sysctl_tcp_syncookies; + u8 sysctl_tcp_migrate_req; int sysctl_tcp_reordering; u8 sysctl_tcp_retries1; u8 sysctl_tcp_retries2; diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index a62934b9f15a..7bb013fcbf5f 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -940,6 +940,15 @@ static struct ctl_table ipv4_net_table[] = { .proc_handler = proc_dou8vec_minmax, }, #endif + { + .procname = "tcp_migrate_req", + .data = &init_net.ipv4.sysctl_tcp_migrate_req, + .maxlen = sizeof(u8), + .mode = 0644, + .proc_handler = proc_dou8vec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE + }, { .procname = "tcp_reordering", .data = &init_net.ipv4.sysctl_tcp_reordering, -- 2.30.2