From patchwork Tue Nov 23 07:07:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Galaganov X-Patchwork-Id: 12633517 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from fallback21.mail.ru (fallback21.m.smailru.net [94.100.176.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E86A2C81 for ; Tue, 23 Nov 2021 07:29:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=internet.ru; s=mail3; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:From:Subject:Content-Type:Content-Transfer-Encoding:To:Cc; bh=JFpH451qVQIpmhaB2CuQoc06D60uYrD5sVAzZLlvCNw=; t=1637652580;x=1638257980; b=jl7QoFWfoHxTb/zywrAFCYzSxqfDB2SRHYayXPFAJRy7QLX2rUmOHuHImMpibpMaAZdX3ia5sH4gJkC4Rgf6/cEMWsJtTjxqDMfqOaWPf9QROQb/SgG9A03z/BFZtfXDQwyOzKq+IHP8uhx1pvFVa+31WhXFoXp3SjefA9sWqxI=; Received: from [10.161.64.43] (port=48050 helo=smtp35.i.mail.ru) by fallback21.m.smailru.net with esmtp (envelope-from ) id 1mpPtv-0007Pl-C3 for mptcp@lists.linux.dev; Tue, 23 Nov 2021 10:07:35 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=internet.ru; s=mail4; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:From:Subject:Content-Type:Content-Transfer-Encoding:To:Cc; bh=JFpH451qVQIpmhaB2CuQoc06D60uYrD5sVAzZLlvCNw=; t=1637651255;x=1638256655; b=mr7UQfjwBOcICm6EV3tOJnYQHshvHWBUosm62EQ16n6tm1s9ccWfAfiEc3G+ZYrmDHVYfSL6/xNNpl8dWHm/41Y904crWyZYNQpW5O2xXZGH7vRVAHdnJVhpD2oDhrg82iAffkYgEIIEakcR1VMWc+RliTXU2gSxNwVEaWD309b5y1e//Hfk08tnuKjBdxdTYuiqqAYwlmbPl0dhnMxQrxnEwG0IAsCTBStTLZVh2qIHkc9IJ0wvWhTW7v5Fz/rGuxa6DiFDGTiYKYWIyMCaoY9ZG46wzRkgHJHTiksWkowkF4qlIedsLYBCI27GhO0clC+I5Hkru/8W6wXG8ngDKg==; Received: by smtp35.i.mail.ru with esmtpa (envelope-from ) id 1mpPtm-0002NB-Pv; Tue, 23 Nov 2021 10:07:27 +0300 From: Maxim Galaganov To: mptcp@lists.linux.dev Cc: Maxim Galaganov Subject: [PATCH mptcp-next 1/3] tcp: expose __tcp_sock_set_cork and __tcp_sock_set_nodelay Date: Tue, 23 Nov 2021 10:07:06 +0300 Message-Id: <20211123070708.2897469-2-max@internet.ru> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211123070708.2897469-1-max@internet.ru> References: <20211123070708.2897469-1-max@internet.ru> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9BAEAA343CB33328DA8790EF48BADF8FC9BC3B7F78ECA59C01313CFAB8367EF908E2BE116634AD74DFA91160A32AED89F00E47A53542FF964503835FA8921BE82386F63046B3269FA X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7D9C4478D0B876341EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006374C960BD2D03BF0BDEA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BBCA57AF85F7723F2298879DF6EF9B279F5C190A68771658220879F7C8C5043D14489FFFB0AA5F4BF176DF2183F8FC7C0F6FAE79CA2B8C2908941B15DA834481FA18204E546F3947CC2B5EEE3591E0D35F6B57BC7E64490618DEB871D839B7333395957E7521B51C2DFABB839C843B9C08941B15DA834481F8AA50765F7900637D0FEED2715E18529389733CBF5DBD5E9B5C8C57E37DE458BD9DD9810294C998ED8FC6C240DEA76428AA50765F7900637FBE64AAB3768209ED81D268191BDAD3DBD4B6F7A4D31EC0BEA7A3FFF5B025636D81D268191BDAD3D78DA827A17800CE70CF55DB4244C8E6DEC76A7562686271EEC990983EF5C03292E808ACE2090B5E14AD6D5ED66289B5259CC434672EE63711DD303D21008E298D5E8D9A59859A8B6B372FE9A2E580EFC725E5C173C3A84C30DA41C7A345C8AA635872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CC559E5F89E84DC551CFF3744A19F65B4263FFC94CE09EBEF9C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF25DC386152A6764A699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3498910055B812BD9C1D028FBEA98AAB6EBBA6F9415EB0999AE3904D1EC225F91300937A57798A16C11D7E09C32AA3244CDABF505EB3B59690E3863AE0EE5EF9F160759606DA2E136A729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojutWt0++zX5RZhiJO0QOIbA== X-Mailru-Sender: 6B47EA55652F5E70849B49CCF28A6C3B0D9917215D464370DF4334CDCC15A839DE14DD44AED48F92AA92DCB28147B367B60569B44082A3A3CC338593878DF048773EBFF2F43C11D60D4ABDE8C577C2ED X-Mras: Ok X-7564579A: 646B95376F6C166E X-77F55803: 6242723A09DB00B4EE34287C01580B602FF54B759B37932376D1D705F9140037049FFFDB7839CE9E53879DFD0F690E42985CA9BFA032FB517DF7427598097752325AF9F0306C3DBA X-7FA49CB5: 0D63561A33F958A5B9566FE4271BBB8646D1CD13ED556AFF6476F9A76BA6B735CACD7DF95DA8FC8BD5E8D9A59859A8B64071617579528AACCC7F00164DA146DAFE8445B8C89999728AA50765F79006375D86F985788DC295389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8E3C0F74373B9C9F4F6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947C5DA91C8160F4BAA02D242C3BD2E3F4C64AD6D5ED66289B52698AB9A7B718F8C442539A7722CA490CD5E8D9A59859A8B634381CAC65D01DA6089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CC559E5F89E84DC5560D5CD9F6948F78C7C6C33A47156DB659C2B6934AE262D3EE7EAB7254005DCED8DA55E71E02F9FC08E8E86DC7131B365E7726E8460B7C23C X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojutWt0++zX5TVWWM7u2k2Cg== X-Mailru-MI: 800 X-Mailru-Sender: A5480F10D64C90059EC859477DBBED747FBA404D6491E8E314BCF26445B63B3AF7F5837242FA16B284390AFDD794B14678274A4A9E9E44FD5B858845640BC0C1AB428D199E4977E267EA787935ED9F1B X-Mras: Ok Expose __tcp_sock_set_cork() and __tcp_sock_set_nodelay() for use in MPTCP setsockopt code -- namely for syncing MPTCP socket options with subflows inside sync_socket_options() while already holding the subflow socket lock. Signed-off-by: Maxim Galaganov --- include/linux/tcp.h | 2 ++ net/ipv4/tcp.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/tcp.h b/include/linux/tcp.h index 48d8a363319e..78b91bb92f0d 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -512,11 +512,13 @@ static inline u16 tcp_mss_clamp(const struct tcp_sock *tp, u16 mss) int tcp_skb_shift(struct sk_buff *to, struct sk_buff *from, int pcount, int shiftlen); +void __tcp_sock_set_cork(struct sock *sk, bool on); void tcp_sock_set_cork(struct sock *sk, bool on); int tcp_sock_set_keepcnt(struct sock *sk, int val); int tcp_sock_set_keepidle_locked(struct sock *sk, int val); int tcp_sock_set_keepidle(struct sock *sk, int val); int tcp_sock_set_keepintvl(struct sock *sk, int val); +void __tcp_sock_set_nodelay(struct sock *sk, bool on); void tcp_sock_set_nodelay(struct sock *sk); void tcp_sock_set_quickack(struct sock *sk, int val); int tcp_sock_set_syncnt(struct sock *sk, int val); diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 6ab82e1a1d41..20054618c87e 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -3207,7 +3207,7 @@ static void tcp_enable_tx_delay(void) * TCP_CORK can be set together with TCP_NODELAY and it is stronger than * TCP_NODELAY. */ -static void __tcp_sock_set_cork(struct sock *sk, bool on) +void __tcp_sock_set_cork(struct sock *sk, bool on) { struct tcp_sock *tp = tcp_sk(sk); @@ -3235,7 +3235,7 @@ EXPORT_SYMBOL(tcp_sock_set_cork); * However, when TCP_NODELAY is set we make an explicit push, which overrides * even TCP_CORK for currently queued segments. */ -static void __tcp_sock_set_nodelay(struct sock *sk, bool on) +void __tcp_sock_set_nodelay(struct sock *sk, bool on) { if (on) { tcp_sk(sk)->nonagle |= TCP_NAGLE_OFF|TCP_NAGLE_PUSH; From patchwork Tue Nov 23 07:07:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Galaganov X-Patchwork-Id: 12633585 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from fallback24.mail.ru (fallback24.m.smailru.net [94.100.187.223]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 423F62C81 for ; Tue, 23 Nov 2021 07:49:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=internet.ru; s=mail3; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:From:Subject:Content-Type:Content-Transfer-Encoding:To:Cc; bh=itA0Lg1o+QF8e6XofYDQDd8GTKrQCEPOJRuPlc9CtAk=; t=1637653791;x=1638259191; b=FfLBcvyJ4lEmi6TO8p2klSnw4Oq1+edNjSlFDup2kOoYxi6PC6HC2AhhYGW6N4uxg2oBcT123p8e5mqGfzIHr/xO8OQi2Jf5N0Rexh2wQCG0bi8siQEBoR2iP1CcFJJX6Coy2M6GJF4q5HI4LqoqLI4pFFAAZVE1j9Z+FS4oWQE=; Received: from [10.161.64.43] (port=53214 helo=smtp35.i.mail.ru) by fallback24.m.smailru.net with esmtp (envelope-from ) id 1mpPtw-0007Mn-Po for mptcp@lists.linux.dev; Tue, 23 Nov 2021 10:07:37 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=internet.ru; s=mail4; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:From:Subject:Content-Type:Content-Transfer-Encoding:To:Cc; bh=itA0Lg1o+QF8e6XofYDQDd8GTKrQCEPOJRuPlc9CtAk=; t=1637651256;x=1638256656; b=pBFRsiq3/k5kROky6vpnc9a80sUIEljuupJQFCxMhSo0lYly7U9cW5GvkTf2HXHVLEKndlW2SjJgjJaMVg/ww9QWh+zMKXtvIZqzOU/ZXasFfoa7wfOtg5Y2b7P8Ojbtd8a4NsXQ+GTr8dbwSpzmeyaloho/plmtIqK+BDaLaeK21uXRjHzMboLZ4922paskuyGuLS/ww3pT88Wrg4Qo4ZyCbadbMjLMFNuwnDrd+aJY1w1cNXvMI9q9Vz+BpZqZlKImbKnaQIH6dCrGwfC19sziIBp3kHH2nyguXjOWuCC5mYGXr9O3slzCJtGWEUBIa057Qt7+jNc5BeytPDRctQ==; Received: by smtp35.i.mail.ru with esmtpa (envelope-from ) id 1mpPto-0002NB-8F; Tue, 23 Nov 2021 10:07:28 +0300 From: Maxim Galaganov To: mptcp@lists.linux.dev Cc: Maxim Galaganov Subject: [PATCH mptcp-next 2/3] mptcp: expose mptcp_check_and_set_pending Date: Tue, 23 Nov 2021 10:07:07 +0300 Message-Id: <20211123070708.2897469-3-max@internet.ru> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211123070708.2897469-1-max@internet.ru> References: <20211123070708.2897469-1-max@internet.ru> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9FE0487E502468146A248A7B8B31062F80ED88F6A42059E94182A05F538085040A17612D49855C4EAEFCB8B15D71D31E3B33987CE173C74A8BCBB9588D3293F00 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE73F64378C139886A6EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637DD81BB19E5DE3F6B8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D89A236BCCF3E7C2032BDAAFADB7AC29896F9789CCF6C18C3F8528715B7D10C86859CC434672EE6371117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8BAA867293B0326636D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EED76C6ED7039589DE4D0DA9BD313A0613D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE365B78C30F681404D6136E347CC761E07C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F790063765DCC2E2BEE1D191EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458834459D11680B505A64F04A8DA58D1F3BEA22B05E692540E X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CC559E5F89E84DC5533A3247875A6B42D682CCD3E23EF5DEA9C2B6934AE262D3EE7EAB7254005DCED114C52B35DBB74F4E7EAB7254005DCEDA5DF9383870C0FED1E0A4E2319210D9B64D260DF9561598F01A9E91200F654B0F19FF8B1531DFD348E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34AA8975497C7004E81D063032481F5C5AE2DD8E335876593BF3205D295A4C9A343ECD47821245636C1D7E09C32AA3244C12DC3B51243BAA82E3C56BB22C4ED78635DA7DC5AF9B58C0729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojutWt0++zX5RYzT7T1i/N8g== X-Mailru-Sender: 6B47EA55652F5E70849B49CCF28A6C3BB9446911DC695EA1DF4334CDCC15A8392E9D602AF0DE6B62AA92DCB28147B367B60569B44082A3A3CC338593878DF048773EBFF2F43C11D60D4ABDE8C577C2ED X-Mras: Ok X-7564579A: 646B95376F6C166E X-77F55803: 6242723A09DB00B4EE34287C01580B602FF54B759B3793237725B0DEDCB309BE049FFFDB7839CE9E53879DFD0F690E42C0E285ED9F614C4C001D30098B559495967915647A064788 X-7FA49CB5: 0D63561A33F958A5E763DFB9ED1B3C554C53E27C707B8CB5DF2D5792EF1B63A7CACD7DF95DA8FC8BD5E8D9A59859A8B64071617579528AACCC7F00164DA146DAFE8445B8C89999728AA50765F79006372D3B7B5A639A2778389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC898A01D7C647FC0B3F6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947C706E30CA5231861903F1AB874ED890284AD6D5ED66289B52698AB9A7B718F8C442539A7722CA490CD5E8D9A59859A8B634381CAC65D01DA6089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CC559E5F89E84DC554F4D5A5EB640F4AC36A5D970377CDCF39C2B6934AE262D3EE7EAB7254005DCED114C52B35DBB74F4E7EAB7254005DCEDA5DF9383870C0FED699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojutWt0++zX5QIFJQCOptVlA== X-Mailru-MI: 800 X-Mailru-Sender: A5480F10D64C90059EC859477DBBED74C1BDCA8CFB3078E443E0E52E5BA5E17638066306E4938E9F84390AFDD794B14678274A4A9E9E44FD5B858845640BC0C1AB428D199E4977E267EA787935ED9F1B X-Mras: Ok Expose the mptcp_check_and_set_pending() function for use inside MPTCP sockopt code. The next patch will call it when TCP_CORK is cleared or TCP_NODELAY is set on the MPTCP socket in order to push pending data from mptcp_release_cb(). Signed-off-by: Maxim Galaganov --- net/mptcp/protocol.c | 2 +- net/mptcp/protocol.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index ef2125798e64..8b49866bcc25 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1543,7 +1543,7 @@ static void mptcp_update_post_push(struct mptcp_sock *msk, msk->snd_nxt = snd_nxt_new; } -static void mptcp_check_and_set_pending(struct sock *sk) +void mptcp_check_and_set_pending(struct sock *sk) { if (mptcp_send_head(sk) && !test_bit(MPTCP_PUSH_PENDING, &mptcp_sk(sk)->flags)) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index a6a4bd7de5b4..7f199fb720ff 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -571,6 +571,7 @@ unsigned int mptcp_stale_loss_cnt(const struct net *net); void mptcp_subflow_fully_established(struct mptcp_subflow_context *subflow, struct mptcp_options_received *mp_opt); bool __mptcp_retransmit_pending_data(struct sock *sk); +void mptcp_check_and_set_pending(struct sock *sk); void __mptcp_push_pending(struct sock *sk, unsigned int flags); bool mptcp_subflow_data_available(struct sock *sk); void __init mptcp_subflow_init(void); From patchwork Tue Nov 23 07:07:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Galaganov X-Patchwork-Id: 12633583 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from fallback23.mail.ru (fallback23.m.smailru.net [94.100.187.222]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6E8D2C81 for ; Tue, 23 Nov 2021 07:49:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=internet.ru; s=mail3; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:From:Subject:Content-Type:Content-Transfer-Encoding:To:Cc; bh=/r5oKKCrfDIWXMjq39MOHcVUXGKGYEpRabtOSh/GoLo=; t=1637653762;x=1638259162; b=AAezzhxW/2L+dbbG6rDTYi3XxmyRq/af1XhgBM1J37I19IG/iUTYiRFS1nBm4dfw6TsoJQEXT6YnY3VqwmrmywA3qhz4ucSpb0B/bL2NLwqY1Mr70bdar3Hovrdi2xvcgsja8pMQjK1eXudYbjqAXUYIzP+feERzNFgPnIfzjys=; Received: from [10.161.64.43] (port=60030 helo=smtp35.i.mail.ru) by fallback23.m.smailru.net with esmtp (envelope-from ) id 1mpPtx-0001sy-Nc for mptcp@lists.linux.dev; Tue, 23 Nov 2021 10:07:37 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=internet.ru; s=mail4; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:From:Subject:Content-Type:Content-Transfer-Encoding:To:Cc; bh=/r5oKKCrfDIWXMjq39MOHcVUXGKGYEpRabtOSh/GoLo=; t=1637651257;x=1638256657; b=PuVV4S73YFAZCXE+NJprRS4dwJ/3YmoUy7uNpZsMNj2mLGGL2vPcspiTI4IzSDR6VdYj4wPV5BalyV0v/oD5faaKbifHYU45UYAZy2hQ5zr15ZP4Km2JokkHnS7cmSN6H+4y/bePTJMC8SUWmscj4YKeUPHaN4nXq2RjdVtvgQdaQqGWXUxn9znueFfeKzvnru0zQbhCHzI20z1mZpCP29xDH8pXsaOyuGTPwUEEwQ2SzY6h64WtHA9whqth3wyJoxnzbgLFd/bTWjB+IjSZtgmYEzPTcIUpVP2U7UxUgclmElr3rguX+mjq2j9S/hIM3kaY0PuF+eW3TUyL/qbf/Q==; Received: by smtp35.i.mail.ru with esmtpa (envelope-from ) id 1mpPtp-0002NB-IM; Tue, 23 Nov 2021 10:07:30 +0300 From: Maxim Galaganov To: mptcp@lists.linux.dev Cc: Maxim Galaganov Subject: [PATCH mptcp-next 3/3] mptcp: support TCP_CORK and TCP_NODELAY Date: Tue, 23 Nov 2021 10:07:08 +0300 Message-Id: <20211123070708.2897469-4-max@internet.ru> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211123070708.2897469-1-max@internet.ru> References: <20211123070708.2897469-1-max@internet.ru> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9BAEAA343CB33328DF92459FC902347094773BA340476FEDD1313CFAB8367EF908E2BE116634AD74D5AD3A22E445012E9603561DA1CB10086503835FA8921BE82C72A02DE8EF075F6 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7B7733D0215A2F71AEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006374B2D40F594293EAD8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D85152B88630E2408431D5A986FED178706F9789CCF6C18C3F8528715B7D10C86859CC434672EE6371117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD182CC0D3CB04F14752D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EED76C6ED7039589DE4D0DA9BD313A0613D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE31F9513A7CA91E5556136E347CC761E07C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F790063765DCC2E2BEE1D191EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458834459D11680B505A64F04A8DA58D1F3A7627F2A65545C38 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CC559E5F89E84DC55D4CF228061722C235D919DFBAB43A9589C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF25DC386152A6764A699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D347324AA9FA07FF01E0C8C8F21883E77FFA9B1E1E77343519254A9D9FE08DC63BA9D8622B518EBE2C81D7E09C32AA3244C9F959D46CD5559FA659345AADF294F2A853296C06374E602729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojutWt0++zX5T1l8lDkT4iYw== X-Mailru-Sender: 6B47EA55652F5E70849B49CCF28A6C3B79F2D85E841A4C7ADF4334CDCC15A839C93384347223FF60AA92DCB28147B367B60569B44082A3A3CC338593878DF048773EBFF2F43C11D60D4ABDE8C577C2ED X-Mras: Ok X-7564579A: 646B95376F6C166E X-77F55803: 6242723A09DB00B4EE34287C01580B602FF54B759B37932369B5239765CEB9CF049FFFDB7839CE9E53879DFD0F690E42A1ABF948FCF29E5D2968813A697059DE967915647A064788 X-7FA49CB5: 0D63561A33F958A5927FB84AB53B504343D04C1312C21C09F21F2D2C081F2F4ECACD7DF95DA8FC8BD5E8D9A59859A8B699B836357A5F2ED6CC7F00164DA146DAFE8445B8C89999728AA50765F7900637FBC651BE86AB0F05389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC87C7DAE56957A78C8F6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947C706E30CA5231861903F1AB874ED890284AD6D5ED66289B52698AB9A7B718F8C442539A7722CA490CD5E8D9A59859A8B634381CAC65D01DA6089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CC559E5F89E84DC55F5DC25F94A884639CA4B0D72CF4506D49C2B6934AE262D3EE7EAB7254005DCED8DA55E71E02F9FC08E8E86DC7131B365E7726E8460B7C23C X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojutWt0++zX5QIFJQCOptVlA== X-Mailru-MI: 800 X-Mailru-Sender: A5480F10D64C90059EC859477DBBED74C056BE3D4CE15F9313AFDEFA4BDAE50C21401CF93FD6FA5584390AFDD794B14678274A4A9E9E44FD5B858845640BC0C1AB428D199E4977E267EA787935ED9F1B X-Mras: Ok First, add cork and nodelay fields to the mptcp_sock structure so they can be used in sync_socket_options(), and fill them on setsockopt while holding the msk socket lock. Then, on setsockopt set proper tcp_sk(ssk)->nonagle values for subflows by calling __tcp_sock_set_cork() or __tcp_sock_set_nodelay() on the ssk while holding the ssk socket lock. tcp_push_pending_frames() will be invoked on the ssk if a cork was cleared or nodelay was set. Also set MPTCP_PUSH_PENDING bit by calling mptcp_check_and_set_pending(). This will lead to __mptcp_push_pending() being called inside mptcp_release_cb() with new tcp_sk(ssk)->nonagle. Also add getsockopt support for TCP_CORK and TCP_NODELAY. Signed-off-by: Maxim Galaganov Acked-by: Paolo Abeni --- I've tested this by doing single-byte writes and looking at the length of packets in tcpdump, also this is now running on my tproxy setup. Enabling nodelay on a tproxy gave a decrease in latency to first byte and lead to improved user experience in web browsing and voip applications. Existing selftests run passed on a debug config, I'll add coverage for new sockopts once I grasp how to do it. Should these bit fields have an explicit zero initializer? I've looked at recvmsg_inq and it doesn't seem to have one. net/mptcp/protocol.h | 4 ++- net/mptcp/sockopt.c | 70 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 7f199fb720ff..47d24478763c 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -249,7 +249,9 @@ struct mptcp_sock { bool use_64bit_ack; /* Set when we received a 64-bit DSN */ bool csum_enabled; bool allow_infinite_fallback; - u8 recvmsg_inq:1; + u8 recvmsg_inq:1, + cork:1, + nodelay:1; spinlock_t join_list_lock; struct work_struct work; struct sk_buff *ooo_last_skb; diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index 11cda8629993..e0501f6bfff8 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -616,6 +616,66 @@ static int mptcp_setsockopt_sol_tcp_congestion(struct mptcp_sock *msk, sockptr_t return ret; } +static int mptcp_setsockopt_sol_tcp_cork(struct mptcp_sock *msk, sockptr_t optval, + unsigned int optlen) +{ + struct mptcp_subflow_context *subflow; + struct sock *sk = (struct sock *)msk; + int val; + + if (optlen < sizeof(int)) + return -EINVAL; + + if (copy_from_sockptr(&val, optval, sizeof(val))) + return -EFAULT; + + lock_sock(sk); + sockopt_seq_inc(msk); + msk->cork = !!val; + mptcp_for_each_subflow(msk, subflow) { + struct sock *ssk = mptcp_subflow_tcp_sock(subflow); + + lock_sock(ssk); + __tcp_sock_set_cork(ssk, !!val); + release_sock(ssk); + } + if (!val) + mptcp_check_and_set_pending(sk); + release_sock(sk); + + return 0; +} + +static int mptcp_setsockopt_sol_tcp_nodelay(struct mptcp_sock *msk, sockptr_t optval, + unsigned int optlen) +{ + struct mptcp_subflow_context *subflow; + struct sock *sk = (struct sock *)msk; + int val; + + if (optlen < sizeof(int)) + return -EINVAL; + + if (copy_from_sockptr(&val, optval, sizeof(val))) + return -EFAULT; + + lock_sock(sk); + sockopt_seq_inc(msk); + msk->nodelay = !!val; + mptcp_for_each_subflow(msk, subflow) { + struct sock *ssk = mptcp_subflow_tcp_sock(subflow); + + lock_sock(ssk); + __tcp_sock_set_nodelay(ssk, !!val); + release_sock(ssk); + } + if (val) + mptcp_check_and_set_pending(sk); + release_sock(sk); + + return 0; +} + static int mptcp_setsockopt_sol_ip_set_transparent(struct mptcp_sock *msk, int optname, sockptr_t optval, unsigned int optlen) { @@ -717,6 +777,10 @@ static int mptcp_setsockopt_sol_tcp(struct mptcp_sock *msk, int optname, return -EOPNOTSUPP; case TCP_CONGESTION: return mptcp_setsockopt_sol_tcp_congestion(msk, optval, optlen); + case TCP_CORK: + return mptcp_setsockopt_sol_tcp_cork(msk, optval, optlen); + case TCP_NODELAY: + return mptcp_setsockopt_sol_tcp_nodelay(msk, optval, optlen); } return -EOPNOTSUPP; @@ -1078,6 +1142,10 @@ static int mptcp_getsockopt_sol_tcp(struct mptcp_sock *msk, int optname, optval, optlen); case TCP_INQ: return mptcp_put_int_option(msk, optval, optlen, msk->recvmsg_inq); + case TCP_CORK: + return mptcp_put_int_option(msk, optval, optlen, msk->cork); + case TCP_NODELAY: + return mptcp_put_int_option(msk, optval, optlen, msk->nodelay); } return -EOPNOTSUPP; } @@ -1165,6 +1233,8 @@ static void sync_socket_options(struct mptcp_sock *msk, struct sock *ssk) if (inet_csk(sk)->icsk_ca_ops != inet_csk(ssk)->icsk_ca_ops) tcp_set_congestion_control(ssk, msk->ca_name, false, true); + __tcp_sock_set_cork(ssk, !!msk->cork); + __tcp_sock_set_nodelay(ssk, !!msk->nodelay); inet_sk(ssk)->transparent = inet_sk(sk)->transparent; inet_sk(ssk)->freebind = inet_sk(sk)->freebind;