From patchwork Wed Jun 14 18:37:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Watson X-Patchwork-Id: 9787235 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D6E37602C9 for ; Wed, 14 Jun 2017 18:37:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA27526785 for ; Wed, 14 Jun 2017 18:37:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE6532851F; Wed, 14 Jun 2017 18:37:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFF2D28510 for ; Wed, 14 Jun 2017 18:37:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751972AbdFNShn (ORCPT ); Wed, 14 Jun 2017 14:37:43 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:48630 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751735AbdFNShk (ORCPT ); Wed, 14 Jun 2017 14:37:40 -0400 Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v5EIYqmO000377; Wed, 14 Jun 2017 11:37:26 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=facebook; bh=YqWlU4sZmCzRCCvmJwc6xZygSbksmpSkYnxY9TtW3QQ=; b=bDyaIYp7erD6O5cMXOfDnwxRmP1CcUxf7eT3vFnGse35mf6XQP7rc09j1dj22VNiOhTT 5EUyYDKuDQ+s+M7TAGLDIriEi2Pw6scaFGtgeYviejveMCy46YEvDK1NmhWAtLYgv/w3 HrB0vaQxdup0oWl68jaq5lgDUypqWpYhTQQ= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2b37rcrrkw-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 14 Jun 2017 11:37:26 -0700 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.17) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 14 Jun 2017 11:37:24 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=YqWlU4sZmCzRCCvmJwc6xZygSbksmpSkYnxY9TtW3QQ=; b=RVIOuVnT5XknASUPZ2dCxe56glbQHw6F5/xlviZZylFpSexThv8sJ0rEGl296eoivOLfDy62QSp1DGZVsxpC0rF/9twst3FF60lbbLGsM0iRXpg5ERbQnr7boS50u3NAU4+1mm+wh66QiFIhVKZTJHBkngTLEDxufWSZoJ61vB0= Authentication-Results: mellanox.com; dkim=none (message not signed) header.d=none; mellanox.com; dmarc=none action=none header.from=fb.com; Received: from localhost (2620:10d:c090:180::1:fa02) by CY4PR15MB1752.namprd15.prod.outlook.com (10.174.53.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1157.12; Wed, 14 Jun 2017 18:37:20 +0000 Date: Wed, 14 Jun 2017 11:37:14 -0700 From: Dave Watson To: Ilya Lesokhin , Aviad Yehezkel , Boris Pismenny , Liran Liss , Matan Barak , David Miller , , Tom Herbert , , , Hannes Frederic Sowa , Eric Dumazet CC: Alexei Starovoitov , , Subject: [PATCH v3 net-next 1/4] tcp: ULP infrastructure Message-ID: <20170614183714.GA80310@davejwatson-mba.dhcp.thefacebook.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.0 (2016-04-01) X-Originating-IP: [2620:10d:c090:180::1:fa02] X-ClientProxiedBy: BN6PR13CA0007.namprd13.prod.outlook.com (10.175.123.17) To CY4PR15MB1752.namprd15.prod.outlook.com (10.174.53.142) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PR15MB1752: X-MS-Office365-Filtering-Correlation-Id: 2dced6a7-cb43-41ad-aa48-08d4b354640f X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:CY4PR15MB1752; X-Microsoft-Exchange-Diagnostics: 1; CY4PR15MB1752; 3:RKhf13kSxOO6cBYnbazg07gHNNUy5Xdbrqu5olVQw4FqyLqga4HdJ2fMBLa4EFNlqQSV0Yjr8ClvfSyDmsAEus6GibT8zSk3pKwDdGRyigDKkz4gdtaSlhA6WDAitn8FpR+/dGcCcP4UFMukiSk8T1HSdA0SyWGm8FIvnjRWZ4XcHlJ1atrkigVnVUUHBpVFC+MKgzr4Q8Nn1/DN7apZXUYSw8Kx0kio4tfP6zOljmNO3G5GQ88wWEnLD/bibh6tVft3lCrnSkcmbgS0ww+CZ9PAJcfWpFuxpqld2tCt6qezYmQEfFyzbdqmzglOpkxIGmV1TLMIPHwtZ/oBwCnWjw==; 25:MMwEv9OepJN5tjuCta1st4hR6rzp4O0thj2aGkmJtxSRWM/SaP0z3/iA/ksuG2doxogIMSAK9xXiRzknq1bwy7FjBm4xMGPfL3eQv9db1XqsOihCT5yFd/dd/CtALdAwFA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dbvWkTuo02csyW1258Q8+tpWoWwuLG3jmhrJ682ytO3JcZDzRXadjX4UvDIxPTok1RdEqjQzSP2GSeOxej7X2BcBs6zJHaBI X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(67672495146484)(21532816269658)(266576461109395); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(100000703101)(100105400095)(10201501046)(6041248)(20161123558100)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123562025)(20161123560025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CY4PR15MB1752; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CY4PR15MB1752; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR15MB1752; 4:iF1ABKfmiWsjLL6j4IglPwXj116UgXHnpbUHqMeR+d?= =?us-ascii?Q?AKEySONTqRYUD0Upl2CCcdo1iRThVIxhc/CRoCRF6B8oi/ApjCqu0kTvtOQS?= =?us-ascii?Q?dSQcQynHoJ7PdJhvH0H7u7xrMXUyxlF+70Xd9aDlvX+BHmBfbzFty33954iD?= =?us-ascii?Q?Pec+XjC0AMYv3XwmZPyJ13fcNN/nHhG6dq5djJbiccR+ZCYi7Ngn0rf3ICYG?= =?us-ascii?Q?GrIdePCaJAou07M1DPMj8PBWQ4meVvbT4FaNLlcAZujWAuK7Icp4O8l52r7X?= =?us-ascii?Q?H3gJhQuqdjkvEGyB33egYf3GRoYnfoWR67xKxGCBybL26VY402oHIfeZ3VJn?= =?us-ascii?Q?dmbpBE3Datpi67WuAijWdX9JLNhYHqLO6TSzinaDZe6BzS4zzZGawo3F7nNA?= =?us-ascii?Q?1BQVZV4f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-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(39450400003)(39860400002)(39400400002)(39410400002)(39840400002)(39850400002)(76176999)(53936002)(54356999)(50466002)(5890100001)(6496005)(1076002)(6666003)(8676002)(4001350100001)(7736002)(76506005)(42186005)(5660300001)(81166006)(25786009)(305945005)(50986999)(33656002)(38730400002)(2950100002)(6116002)(6486002)(83506001)(478600001)(189998001)(23726003)(9686003)(47776003)(2906002)(86362001)(4326008)(7416002)(18370500001)(921003)(1121003); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR15MB1752; H:localhost; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR15MB1752; 23:jDCXswgLuDOJEKR2pa2fyn09vjKvOTUNhd5iPnx6V?= =?us-ascii?Q?mOek/3HWRc7OSobr0lTmcDSnF72+vL73CVZg71di1u/Kvg0PV0Pg3x8H+oJM?= =?us-ascii?Q?/oUpc7208tPMa9dqGyaUclxQ5NV3q6GWMYPru+MlbM1qrSdgC7aoS4SWXieC?= =?us-ascii?Q?9fJFWmocxKLR0pC5B5c6APF+O8nAHMqTBvDzajVr8XaCK6kMYv929QUadgYq?= =?us-ascii?Q?r/p+lfrkEUt8sfrFClogUkFBIQErpJf7f4QFXFPUpa/kYZImPHtUDG3tjRBw?= =?us-ascii?Q?Dh62p/PCAPAjuCVVOS+sc0mmM6qKjHZ9QwnP0pF7hjGFMlFAJNgVQ682Qs2x?= =?us-ascii?Q?QLluDgolTrhqycw0HmnCNDmjFqB/MMOB8EoZ5aOUxl/ESoNqvbxTJFBe4LYp?= =?us-ascii?Q?4lrSKeQIOdfyzRhLA0Pp6cO4Qt+LWQKG2LE9SG6LgqshFHJ6J9VG7Vpifnrq?= =?us-ascii?Q?BaKD3+QwSPgyeBdv3IDMDv9d5XB/NaDSVywIqXVXw/p0Z/oS46g4vr3/Dq5F?= =?us-ascii?Q?lAwQNCOjcx8pGq3/5zRl44P6mX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ARo4t6tPLA5+ZUoe0J8RK0/kCNz5+UQqqqB89ycwld8azUxl4Af3DIFpAZsKMhcW9AhXrsPXH2893d8Onkris6AQRJ3XswshX0aAbwZWrOI72IFm/uuAHulGPu2NQBwOSuCnvbfkaxRVzOlswUUijFkhzykIwaQcyDiMv4QA0AdvZKaV1OC7CEwvHz09DrS79tvRV+UJJl9v2iuHPNOC1i292jpKmthixRui3faI1isMrpgEvA== X-Microsoft-Exchange-Diagnostics: 1; CY4PR15MB1752; 5:mnWMIZNSVOKOjv+e+BKXhldYlBjq1y3teQjk9uugQ7ut+8iNxGNVfSInW0BxCAEgJGCfXzdTEOq5dlhYP30rFA1xzRjTngRIFMGuvHIZ4qfQ+8T6gqe1TAvexsQmQf2mVgouxGRmCTvvsOLZA6VofkY+qLGe2ek9d0uNZFERiDRRZjO4FC4Ai63N85Hox+8+GKpOnlIpx0aYDACeSlTiTw8yHAxZj5c6ex5Zm8/pcHaWhYVfuv1B+VMoG/+xCFjDF4a0dExeWmwUPcz0UmRN1CG+zsF0AYepP25g6a4ECdxYEl1Zk90QnzF9A1QL2K9ASbbtfUnlq7WxRj8sDjkkMfLxk47UfSNUlLgp12U2tYMTRq5Yl/VnlHnMrdCZX7Cqrh4J4VX2TN+KTpPyH9tNJjw7s9yQcQYT0+5IEEEtve84NjUoagSeOiToXRLcX7I0xlGR8YFR8YYQdE3znA7fCgKfG+QNEFzoRi0tuJCSwHE9KLEG6e19S4+2QDZv5ej2; 24:yFPf/cuQ4mPPdrZ+2Ff8NgSRUsH8t+Y+YvqE3lHz2vhmkaE/i3yLnLH3+d4cfuYduoxEfesVYn0sFJp0oY1i4He2YzQFC/6j9lAjZKMornE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR15MB1752; 7:y7WxO+I/TtAKhAWCBWLn6tAVqF7MXt65hm9XIZZJMP8K/malREhS3/SEKg0eYJsCe4FBOubZBtRjOewVUdWIzx2AqmmJlVNtL8kPc1A4l6r1ztkF/FaG0qxvCO617DsrI5iLdIo5S7Y3iOxojWBS9n8yFxLAe0KwGiEDHJ4adAsmWjle1k1UFaiVdEjxyYE2Jl/Gnba7fiOlsF/WnAxBzOqaCRgE3cdhZF1cdTQpFHZ2Blev26AGjc/Sy/8J5onG4f2J/fPiXvNFBJG343cysZL12HrUvSGxBI+3H7xxf+NaDgUkfGX8K4/M4ZAKC0D6ylr0zRrT6MyN4vihMO29lQ==; 20:jMkNNDB0JdNdTWlMQQJHTUzlAB4jFbEF4cgIukiKg/VeavZ77o0f80AKPAsbbeNN0IXmJCDoZnJ2mn9sV8GmiuHsrDB6VmDjdgNfrW+gwKCEidMwGSh5XNPHNu1nwXNmkeZP0FPaiYXtjNbn2rHh/OSDbKwXOxznVXI3Fx4nThk= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2017 18:37:20.0486 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR15MB1752 X-OriginatorOrg: fb.com X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-06-14_05:, , signatures=0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add the infrustructure for attaching Upper Layer Protocols (ULPs) over TCP sockets. Based on a similar infrastructure in tcp_cong. The idea is that any ULP can add its own logic by changing the TCP proto_ops structure to its own methods. Example usage: setsockopt(sock, SOL_TCP, TCP_ULP, "tls", sizeof("tls")); modules will call: tcp_register_ulp(&tcp_tls_ulp_ops); to register/unregister their ulp, with an init function and name. A list of registered ulps will be returned by tcp_get_available_ulp, which is hooked up to /proc. Example: $ cat /proc/sys/net/ipv4/tcp_available_ulp tls There is currently no functionality to remove or chain ULPs, but it should be possible to add these in the future if needed. Signed-off-by: Boris Pismenny Signed-off-by: Dave Watson --- include/net/inet_connection_sock.h | 4 ++ include/net/tcp.h | 25 +++++++ include/uapi/linux/tcp.h | 1 + net/ipv4/Makefile | 2 +- net/ipv4/sysctl_net_ipv4.c | 25 +++++++ net/ipv4/tcp.c | 28 ++++++++ net/ipv4/tcp_ipv4.c | 2 + net/ipv4/tcp_ulp.c | 134 +++++++++++++++++++++++++++++++++++++ 8 files changed, 220 insertions(+), 1 deletion(-) create mode 100644 net/ipv4/tcp_ulp.c diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index c7a5779..13e4c89 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h @@ -75,6 +75,8 @@ struct inet_connection_sock_af_ops { * @icsk_pmtu_cookie Last pmtu seen by socket * @icsk_ca_ops Pluggable congestion control hook * @icsk_af_ops Operations which are AF_INET{4,6} specific + * @icsk_ulp_ops Pluggable ULP control hook + * @icsk_ulp_data ULP private data * @icsk_ca_state: Congestion control state * @icsk_retransmits: Number of unrecovered [RTO] timeouts * @icsk_pending: Scheduled timer event @@ -97,6 +99,8 @@ struct inet_connection_sock { __u32 icsk_pmtu_cookie; const struct tcp_congestion_ops *icsk_ca_ops; const struct inet_connection_sock_af_ops *icsk_af_ops; + const struct tcp_ulp_ops *icsk_ulp_ops; + void *icsk_ulp_data; unsigned int (*icsk_sync_mss)(struct sock *sk, u32 pmtu); __u8 icsk_ca_state:6, icsk_ca_setsockopt:1, diff --git a/include/net/tcp.h b/include/net/tcp.h index 3ab677d..b439f46 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1991,4 +1991,29 @@ static inline void tcp_listendrop(const struct sock *sk) enum hrtimer_restart tcp_pace_kick(struct hrtimer *timer); +/* + * Interface for adding Upper Level Protocols over TCP + */ + +#define TCP_ULP_NAME_MAX 16 +#define TCP_ULP_MAX 128 +#define TCP_ULP_BUF_MAX (TCP_ULP_NAME_MAX*TCP_ULP_MAX) + +struct tcp_ulp_ops { + struct list_head list; + + /* initialize ulp */ + int (*init)(struct sock *sk); + /* cleanup ulp */ + void (*release)(struct sock *sk); + + char name[TCP_ULP_NAME_MAX]; + struct module *owner; +}; +int tcp_register_ulp(struct tcp_ulp_ops *type); +void tcp_unregister_ulp(struct tcp_ulp_ops *type); +int tcp_set_ulp(struct sock *sk, const char *name); +void tcp_get_available_ulp(char *buf, size_t len); +void tcp_cleanup_ulp(struct sock *sk); + #endif /* _TCP_H */ diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h index 38a2b07..8204dce 100644 --- a/include/uapi/linux/tcp.h +++ b/include/uapi/linux/tcp.h @@ -117,6 +117,7 @@ enum { #define TCP_SAVED_SYN 28 /* Get SYN headers recorded for connection */ #define TCP_REPAIR_WINDOW 29 /* Get/set window parameters */ #define TCP_FASTOPEN_CONNECT 30 /* Attempt FastOpen with connect */ +#define TCP_ULP 31 /* Attach a ULP to a TCP connection */ struct tcp_repair_opt { __u32 opt_code; diff --git a/net/ipv4/Makefile b/net/ipv4/Makefile index f83de23..afcb435 100644 --- a/net/ipv4/Makefile +++ b/net/ipv4/Makefile @@ -8,7 +8,7 @@ obj-y := route.o inetpeer.o protocol.o \ inet_timewait_sock.o inet_connection_sock.o \ tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o \ tcp_minisocks.o tcp_cong.o tcp_metrics.o tcp_fastopen.o \ - tcp_rate.o tcp_recovery.o \ + tcp_rate.o tcp_recovery.o tcp_ulp.o \ tcp_offload.o datagram.o raw.o udp.o udplite.o \ udp_offload.o arp.o icmp.o devinet.o af_inet.o igmp.o \ fib_frontend.o fib_semantics.o fib_trie.o fib_notifier.o \ diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index 7065234a..9bf8097 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -360,6 +360,25 @@ static int proc_tfo_blackhole_detect_timeout(struct ctl_table *table, ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); if (write && ret == 0) tcp_fastopen_active_timeout_reset(); + + return ret; +} + +static int proc_tcp_available_ulp(struct ctl_table *ctl, + int write, + void __user *buffer, size_t *lenp, + loff_t *ppos) +{ + struct ctl_table tbl = { .maxlen = TCP_ULP_BUF_MAX, }; + int ret; + + tbl.data = kmalloc(tbl.maxlen, GFP_USER); + if (!tbl.data) + return -ENOMEM; + tcp_get_available_ulp(tbl.data, TCP_ULP_BUF_MAX); + ret = proc_dostring(&tbl, write, buffer, lenp, ppos); + kfree(tbl.data); + return ret; } @@ -686,6 +705,12 @@ static struct ctl_table ipv4_table[] = { .proc_handler = proc_dointvec_ms_jiffies, }, { + .procname = "tcp_available_ulp", + .maxlen = TCP_ULP_BUF_MAX, + .mode = 0444, + .proc_handler = proc_tcp_available_ulp, + }, + { .procname = "icmp_msgs_per_sec", .data = &sysctl_icmp_msgs_per_sec, .maxlen = sizeof(int), diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index cc8fd8b..b06ee30 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -2482,6 +2482,24 @@ static int do_tcp_setsockopt(struct sock *sk, int level, release_sock(sk); return err; } + case TCP_ULP: { + char name[TCP_ULP_NAME_MAX]; + + if (optlen < 1) + return -EINVAL; + + val = strncpy_from_user(name, optval, + min_t(long, TCP_ULP_NAME_MAX - 1, + optlen)); + if (val < 0) + return -EFAULT; + name[val] = 0; + + lock_sock(sk); + err = tcp_set_ulp(sk, name); + release_sock(sk); + return err; + } default: /* fallthru */ break; @@ -3038,6 +3056,16 @@ static int do_tcp_getsockopt(struct sock *sk, int level, return -EFAULT; return 0; + case TCP_ULP: + if (get_user(len, optlen)) + return -EFAULT; + len = min_t(unsigned int, len, TCP_ULP_NAME_MAX); + if (put_user(len, optlen)) + return -EFAULT; + if (copy_to_user(optval, icsk->icsk_ulp_ops->name, len)) + return -EFAULT; + return 0; + case TCP_THIN_LINEAR_TIMEOUTS: val = tp->thin_lto; break; diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 1dc8c44..eec2ff9 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1860,6 +1860,8 @@ void tcp_v4_destroy_sock(struct sock *sk) tcp_cleanup_congestion_control(sk); + tcp_cleanup_ulp(sk); + /* Cleanup up the write buffer. */ tcp_write_queue_purge(sk); diff --git a/net/ipv4/tcp_ulp.c b/net/ipv4/tcp_ulp.c new file mode 100644 index 0000000..e855ea7 --- /dev/null +++ b/net/ipv4/tcp_ulp.c @@ -0,0 +1,134 @@ +/* + * Pluggable TCP upper layer protocol support. + * + * Copyright (c) 2016-2017, Mellanox Technologies. All rights reserved. + * Copyright (c) 2016-2017, Dave Watson . All rights reserved. + * + */ + +#include +#include +#include +#include +#include +#include + +static DEFINE_SPINLOCK(tcp_ulp_list_lock); +static LIST_HEAD(tcp_ulp_list); + +/* Simple linear search, don't expect many entries! */ +static struct tcp_ulp_ops *tcp_ulp_find(const char *name) +{ + struct tcp_ulp_ops *e; + + list_for_each_entry_rcu(e, &tcp_ulp_list, list) { + if (strcmp(e->name, name) == 0) + return e; + } + + return NULL; +} + +static const struct tcp_ulp_ops *__tcp_ulp_find_autoload(const char *name) +{ + const struct tcp_ulp_ops *ulp = NULL; + + rcu_read_lock(); + ulp = tcp_ulp_find(name); + +#ifdef CONFIG_MODULES + if (!ulp && capable(CAP_NET_ADMIN)) { + rcu_read_unlock(); + request_module("%s", name); + rcu_read_lock(); + ulp = tcp_ulp_find(name); + } +#endif + if (!ulp || !try_module_get(ulp->owner)) + ulp = NULL; + + rcu_read_unlock(); + return ulp; +} + +/* Attach new upper layer protocol to the list + * of available protocols. + */ +int tcp_register_ulp(struct tcp_ulp_ops *ulp) +{ + int ret = 0; + + spin_lock(&tcp_ulp_list_lock); + if (tcp_ulp_find(ulp->name)) { + pr_notice("%s already registered or non-unique name\n", + ulp->name); + ret = -EEXIST; + } else { + list_add_tail_rcu(&ulp->list, &tcp_ulp_list); + } + spin_unlock(&tcp_ulp_list_lock); + + return ret; +} +EXPORT_SYMBOL_GPL(tcp_register_ulp); + +void tcp_unregister_ulp(struct tcp_ulp_ops *ulp) +{ + spin_lock(&tcp_ulp_list_lock); + list_del_rcu(&ulp->list); + spin_unlock(&tcp_ulp_list_lock); + + synchronize_rcu(); +} +EXPORT_SYMBOL_GPL(tcp_unregister_ulp); + +/* Build string with list of available upper layer protocl values */ +void tcp_get_available_ulp(char *buf, size_t maxlen) +{ + struct tcp_ulp_ops *ulp_ops; + size_t offs = 0; + + rcu_read_lock(); + list_for_each_entry_rcu(ulp_ops, &tcp_ulp_list, list) { + offs += snprintf(buf + offs, maxlen - offs, + "%s%s", + offs == 0 ? "" : " ", ulp_ops->name); + } + rcu_read_unlock(); +} + +void tcp_cleanup_ulp(struct sock *sk) +{ + struct inet_connection_sock *icsk = inet_csk(sk); + + if (!icsk->icsk_ulp_ops) + return; + + if (icsk->icsk_ulp_ops->release) + icsk->icsk_ulp_ops->release(sk); + module_put(icsk->icsk_ulp_ops->owner); +} + +/* Change upper layer protocol for socket */ +int tcp_set_ulp(struct sock *sk, const char *name) +{ + struct inet_connection_sock *icsk = inet_csk(sk); + const struct tcp_ulp_ops *ulp_ops; + int err = 0; + + if (icsk->icsk_ulp_ops) + return -EEXIST; + + ulp_ops = __tcp_ulp_find_autoload(name); + if (!ulp_ops) + err = -ENOENT; + else + err = ulp_ops->init(sk); + + if (err) + goto out; + + icsk->icsk_ulp_ops = ulp_ops; + out: + return err; +}