From patchwork Wed May 24 16:26:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Watson X-Patchwork-Id: 9746381 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 B7CF060209 for ; Wed, 24 May 2017 16:27:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A685F287F5 for ; Wed, 24 May 2017 16:27:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9AE9B2899F; Wed, 24 May 2017 16:27:14 +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 4CCC3287F5 for ; Wed, 24 May 2017 16:27:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967288AbdEXQ1L (ORCPT ); Wed, 24 May 2017 12:27:11 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:39765 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967637AbdEXQ1I (ORCPT ); Wed, 24 May 2017 12:27:08 -0400 Received: from pps.filterd (m0109331.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v4OGHR1G006842; Wed, 24 May 2017 09:26:55 -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=zJnLQkEnE59HrhVS7MaI3q2j4+al1SMpwXMfcfkSvyc=; b=XMfPw2Ell3gOId3+fYVmQrmBAadjAwTTJqlpZ/JcEsOXuibrWhVMHKPiQz7ATkMZMD4Q IIT0dC70i0QJNfzbnyRcUp7zo5XU7bHbP/LdKTngK0hMkPEXa239h4ZMUvhfl87mYTvT 99U6xYZGgHuhml/0GiKgc6YQn4qqdcMXFmw= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0a-00082601.pphosted.com with ESMTP id 2an862h4jc-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 24 May 2017 09:26:55 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.33) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 24 May 2017 12:26:53 -0400 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=zJnLQkEnE59HrhVS7MaI3q2j4+al1SMpwXMfcfkSvyc=; b=VqB4GEmBq/01wdjXpOVW47ipgzamI+uAtZSS51d4rPScnJQXPyc/h1P/V6bq/4GQrAxfX+dzsuK+AH7pZJ5zw9nDiWxoykWsNkwNjcdP2Lx/TdycC3XsPVANK9oLWH1Dv1RqOBmpdRw23vorte7O5r39PJsfdFbewS+2A8Od4t8= 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::df6b) by DM5PR15MB1756.namprd15.prod.outlook.com (10.174.246.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1101.14; Wed, 24 May 2017 16:26:50 +0000 Date: Wed, 24 May 2017 09:26:46 -0700 From: Dave Watson To: Ilya Lesokhin , Aviad Yehezkel , Boris Pismenny , Liran Liss , Matan Barak , David Miller , , Tom Herbert , , , Hannes Frederic Sowa CC: Alexei Starovoitov , , Subject: [PATCH net-next 1/4] tcp: ULP infrastructure Message-ID: <20170524162646.GA24128@davejwatson-mba.local> 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::df6b] X-ClientProxiedBy: BN6PR04CA0004.namprd04.prod.outlook.com (10.172.194.14) To DM5PR15MB1756.namprd15.prod.outlook.com (10.174.246.138) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR15MB1756: X-MS-Office365-Filtering-Correlation-Id: 0e9783e3-e29e-41e8-ac85-08d4a2c1af22 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:DM5PR15MB1756; X-Microsoft-Exchange-Diagnostics: 1; DM5PR15MB1756; 3:+ctMl3TxGdjwPf+zG4eO0itqlvUnBfeNOXQWhESkheEmMuIDi/VMcPuoZ+gxysQE+zzmTPvjJrwST7aeYOcqyx0ZJ4ZHL2w0SyrCUTWdyeW2JwDZUjBPErcKI04WIhZORK3BIzXdsQdaC3GGkQFIMO69rkP+CGcZifzzr+h9c4Qk/4QRpKdEuyvKzZf3nN2UcNOzGODyA20N5BjsY0iYHgvW+2Ttw21MaT16iZPg1nHhQgNqNv+KpOTif3/kIxhBr15jv7Zdd2VBIAgfVqAMmZZE2RjTGKAISNGoDiwrhoJPoXuyThBopC00l1oUQvP/77f85o1JDJYEEZ8z00VCww==; 25:4irhvg2C5k9ic4fyOkolVZGTNRzs10CTDz1S6TvwT6NqS7fxrjPVOwdJTf2qCke5n/pvBmF1oME7VvXQT68g+fTm4Zf7Ok4gu3oEHfaeqlcbq6PTNSJO3FHO749er0WoT+67fXAR3e3mMkQK+CKKOsE6R4Uh2y0WR6TkdV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RDpo5mUgCw/pR3hRueZ2H5UKJIpyNVA6cTSseyIB3Z9fvOFegvhxWHmPQaTG41bCSfFzFIEa2CumegGm X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(67672495146484)(21532816269658)(266576461109395); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700054)(100105000095)(100000701054)(100105300095)(100000702054)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(100000703054)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123564025)(20161123562025)(20161123558100)(6072148)(100000704054)(100105200095)(100000705054)(100105500095); SRVR:DM5PR15MB1756; BCL:0; PCL:0; RULEID:(100000800054)(100110000095)(100000801054)(100110300095)(100000802054)(100110100095)(100000803054)(100110400095)(100000804054)(100110200095)(100000805047)(100110500095); SRVR:DM5PR15MB1756; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR15MB1756; 4:F+tXrqYYAffPYI9fe7/YqQpeL/nqNXDQS+ZLSC+NcV?= =?us-ascii?Q?AyAHyRfq7XHWoj28D1n6zkkq8tQO7xl6FoaGR/rhQAIkKEqyCTfX9n925aGb?= =?us-ascii?Q?+wmOL8g3y/l7FmPvZB+4eo0EF9N7uzHpEGIOvzhdQaLQ3fhOvWhvU/j2es+f?= =?us-ascii?Q?qv81VTXL9hhOVhhFn08SPC3FAc6loBvglTd4TeH9njs/jbgZTC7L5CHhKqjw?= =?us-ascii?Q?FX+E2cRTAENbWbTNcYl2vTnSEORbIuW2gCiZcLQ3iQRA0v8LsSnHniGDpyva?= =?us-ascii?Q?cEKJwM9zvYRugVVYHxGOgxT9HzCdY9+Gg8vvcmyma1tFFiDZ2DPua+vZjlYL?= =?us-ascii?Q?A+IcXxZ1mmxhDMwax2PzEAZ4aQhUR8CpR3UZ6iqtqYYzXFxwM8KBfnotQQHc?= =?us-ascii?Q?mGejBnz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69949h32VW?= X-Forefront-PRVS: 031763BCAF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(39840400002)(39400400002)(39850400002)(39450400003)(39410400002)(5660300001)(25786009)(9686003)(23726003)(6116002)(53936002)(83506001)(50986999)(50466002)(54356999)(86362001)(4001350100001)(478600001)(2950100002)(6666003)(76176999)(76506005)(305945005)(47776003)(7416002)(7736002)(42186005)(2906002)(5890100001)(1076002)(6496005)(38730400002)(6486002)(189998001)(98436002)(81166006)(8676002)(33656002)(4326008)(18370500001)(921003)(1121003); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR15MB1756; H:localhost; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR15MB1756; 23:tF53fOH6hBm6kMnz1dTFHxC+JpvWifiFGpSIWQpMI?= =?us-ascii?Q?dth0KeZ3jEo4m8j3d/6KEBN8ywL1P7ZDhhPR0oB88S4AKl5IXwXQ4wrxzSSB?= =?us-ascii?Q?MI0RgGQOjNTBfmDnsdobXZ8wQ+Y5vvKX1yP0QpjNTALxxS2hN79y10Gzblg/?= =?us-ascii?Q?GA9BqtKLEovzCUwYPstW5fA6aq4piNaPIBTvHY3U0MVwN53x+D5OrKwPoxYf?= =?us-ascii?Q?bNYOtQdj5f4aczpyYuxViQwVkuMcV2WrtVXhzPiie2FjcCWnzab8RIaLxIJ/?= =?us-ascii?Q?uUWehw8nPPn5qSxDWT9JyLPK/wO6m657y3iObp/fDuvAezoJTNlvAy7hCfer?= =?us-ascii?Q?EC0KUPiclHTTE2B3i7h84U3o1nks/g+9eZSESkXsg4xVowMUQ7D2kJNLqD08?= =?us-ascii?Q?51Uex47tAm4R72lVTSHasEgeD0PKf6z1HiaI95+8vhAMwq3o/4YH+VJxGd4O?= =?us-ascii?Q?CQ8VVoFntH3uw3/ahenwxJfnL/e5YypJljEtDw725oVx1PqR9BNvJJCIwait?= =?us-ascii?Q?lUOKODPigg90r5k4FfjOVCenicVRUuhW+kI/WPrfeshnLGp89ATCo9iu/1R1?= =?us-ascii?Q?o1gEY8nYFCG6CsLhavjUNmeqYxhJa7fDImd2PFH+59mZUNfalAFlGidF7V1i?= =?us-ascii?Q?FmjseYNfsIN8aU5za95Ku+gIQjfm725Kgk9RtKL+iAPvmyXBZKrryy150hqE?= =?us-ascii?Q?Cdg/jANs9lpNPhD0WxayOT6fCNRRw+p8uVPqDxDl1PFm3RgvQSmIBBQF9T3t?= =?us-ascii?Q?5xW373SVC0piNuRRq/UUczbXZn24y5Ly05LLq3AGGeGbOTWLJSASbtVoI73G?= =?us-ascii?Q?D6K1kNLgV0BulrDz5QECj1InPwFCuwrfWsu8vxVI7iFWq+yystFAQWcQnOMU?= =?us-ascii?Q?hB+iUMfvSc0t4tGqoJT765x4qTAvmzH5DHPCN7XRwd8Al8oYhaaO8Xn+X+6b?= =?us-ascii?Q?j0TysUtxAAD6ZUkCIwyymJ4ffZtRC1/VtbB+UmKUjuTVpSvPqFm0qz9EcNTg?= =?us-ascii?Q?NmNHoTWCZR5gIz6S1WBDPZ4KV9ysceCxSGivVkXQEABcwRB4+u2IpHJ626Ap?= =?us-ascii?Q?fCiaNlHhCHI9/qJOersfg0AAY5/UPJLUHzwPHNgD4xroWazoxWRS5Km5Bwk6?= =?us-ascii?Q?ynZ8Phe8neiOGAZeG1BnGUttwi2pvBg?= X-Microsoft-Exchange-Diagnostics: 1; DM5PR15MB1756; 6:LV/qq/UWPqBvYSJPXT27HJmPk0jegaQxNci9QXR1W09ZkhdvAa4gqzEO5VjSzNy7nkTVFNczIA7zhdqF57lvb8H0lOxifRSkMP/LURyM5lf3YcD3UVfE6HTzH/6kGySQePXifG0aI+XVXbizajjmhL5McP7aFQx31DVkXBFXHk8n0zrMsYh83e591/cX4EI0tRfvbhEfg23T+IbPqzhziJNCqLD5r2dIRPeLNe4bsCcK7WEkIFCzSM0yzKbEWBO0QtgL/XwmUvgNhWiAU2FivSD2R2kkSj6LifG6QDlO8rNTBsbs4mhp7BFl/T4wqtneDzOT1geP+hc3XivJNxbjr2AnHBnzuhZDITRzdHHfvJl9EN6z7xq6LeRuvHBgGJJraIup7BlpJSPfozZNBFaykhqKb8bZWQXVl+eOHlWD5h9cGoGcej9V7rgoCARrAKaUMpsiR3hVozqBWvJ6c6EaI5PlDX6rmCm+v92pfFXQ3JQl23cfIoKTQZvHaEityygmn3u5iWn/9oO31C91l62rww== X-Microsoft-Exchange-Diagnostics: 1; DM5PR15MB1756; 5:eVvlasKNxNRBFr8li0lnY6DBjKw1IYnsSWW1cI7wNdCMGtVt2B9W7z8leecOSepYZ+yNxZtnZgc++epeMa6qELBRBdtPMAtOM7cdE/KGtk/7IyEwDVbRYhjTk8ZFMtX7Kh9YyuT/AYrlN+95CD6n6Cs/E77TuUDYmFkGNJbul9dVEucMaxKl2AfFWSE6JWaI/dp+JU/IMpgNzfFgwgiMJIe5qAEG67Qg7KaL+46cw7hj54gDwx+h8NdUEyLLuWVyGstWB4OGaHG+VbiuHI+h8z/H5vbr+YgaKgugnBlspdOhHWp0LVmVW7TBEcOU9O73ElwFSYAEO96Snj1LE8mPmdYoEljLGStilS1DWBfgzOyznYnb1j6FiODE4WyyN5BVbkcQ531lntVkd6xgb0esg8vtcFbtBrsOGPYRk0f/zf368B2DIoCW1jxclW0fJ17pUrDpV9fPNBtF0dEU38vJDplODUWWFj/LKZFGcJHZdKWQFMWW7ojzxd7qxXr/5W5g; 24:kvgeKtfEXneIfPUEDXPiv0xJFKWna8PYp/u2fa0T7P2qeUboOG8ZReJ9OCKmGzUPlzsGBwmGxRLUrDMt0VUTogYTFYSY2BqXjNDdVE1PGCs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR15MB1756; 7:zgx2iCPgCHe73td0uIx9nVmCI8hrL/kcmtPUJyipmHBF5kJ9yfyuUaou/u7ZLY5cwLgsZHQWcsonIhVPbSiIy3KWuVkNwpediTMD+6r0jHM22sQYOm3u1M2BW8FdgqrvN0Hvka+6KR0OJCSxvEud/NbSFQWAWGrea198gScoEDqQ4ZW3Ufqld0K6aexRN3tAdr2ir/u78fX7MYMZMH5RNzdQjivFOJRb/RccZUdbSlrubOc4RK18IhZS+uDyG0h77hFfbKqNvjcy16OgAmeL/uOApACWfFhXzaWEJDtmD+EVQp3vhycFV227+VbIvMPDNulVb9c7P9Z66go9sleN0Q==; 20:cr9ZrBmfazLuNLtv6FlhRDRqLnhTKTZNjuZYyJBYnxunSb2KJi3vTXvITdEk5SxLqeqeo4iLLd734f5ABY5bsksl5UTf1W5OkV/3G17PnA+l+g4srr2+0yvuah6zHbGi2eDJ9HYtkeYyraXX/IyndOrGkwE5Gv51UExqDd9tGj0= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2017 16:26:50.4865 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR15MB1756 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-05-24_12:, , 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 82462db..fcc39f8 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1992,4 +1992,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 86957e9..6a40837c 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; } @@ -707,6 +726,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 aaf663a..9f06faa 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -2458,6 +2458,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; @@ -3014,6 +3032,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 191b2f7..c2f5538 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..e2beb80 --- /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(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(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; +}