diff mbox series

[RFC,net] tcp: ensure PMTU updates are processed during fastopen

Message ID 20220316235908.1246615-1-kuba@kernel.org (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [RFC,net] tcp: ensure PMTU updates are processed during fastopen | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 2 this patch: 2
netdev/cc_maintainers fail 2 blamed authors not CCed: maze@google.com kafai@fb.com; 5 maintainers not CCed: yoshfuji@linux-ipv6.org pabeni@redhat.com maze@google.com kafai@fb.com dsahern@kernel.org
netdev/build_clang success Errors and warnings before: 20 this patch: 20
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 7 this patch: 7
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jakub Kicinski March 16, 2022, 11:59 p.m. UTC
tp->rx_opt.mss_clamp is not populated, yet, during TFO send so we
rise it to the local MSS. tp->mss_cache is not updated, however:

tcp_v6_connect():
  tp->rx_opt.mss_clamp = IPV6_MIN_MTU - headers;
  tcp_connect():
     tcp_connect_init():
       tp->mss_cache = min(mtu, tp->rx_opt.mss_clamp)
     tcp_send_syn_data():
       tp->rx_opt.mss_clamp = tp->advmss

After recent fixes to ICMPv6 PTB handling we started dropping
PMTU updates higher than tp->mss_cache. Because of the stale
tp->mss_cache value PMTU updates during TFO are always dropped.

Thanks to Wei for helping zero in on the problem and the fix!

Fixes: c7bb4b89033b ("ipv6: tcp: drop silly ICMPv6 packet too big messages")
Reported-by: Andre Nash <alnash@fb.com>
Reported-by: Neil Spring <ntspring@fb.com>
Reviewed-by: Wei Wang <weiwan@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 net/ipv4/tcp_output.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Yuchung Cheng March 17, 2022, 4:40 p.m. UTC | #1
On Wed, Mar 16, 2022 at 4:59 PM Jakub Kicinski <kuba@kernel.org> wrote:
>
> tp->rx_opt.mss_clamp is not populated, yet, during TFO send so we
> rise it to the local MSS. tp->mss_cache is not updated, however:
>
> tcp_v6_connect():
>   tp->rx_opt.mss_clamp = IPV6_MIN_MTU - headers;
>   tcp_connect():
>      tcp_connect_init():
>        tp->mss_cache = min(mtu, tp->rx_opt.mss_clamp)
>      tcp_send_syn_data():
>        tp->rx_opt.mss_clamp = tp->advmss
>
> After recent fixes to ICMPv6 PTB handling we started dropping
> PMTU updates higher than tp->mss_cache. Because of the stale
> tp->mss_cache value PMTU updates during TFO are always dropped.
>
> Thanks to Wei for helping zero in on the problem and the fix!
>
> Fixes: c7bb4b89033b ("ipv6: tcp: drop silly ICMPv6 packet too big messages")
> Reported-by: Andre Nash <alnash@fb.com>
> Reported-by: Neil Spring <ntspring@fb.com>
> Reviewed-by: Wei Wang <weiwan@google.com>
Acked-by: Yuchung Cheng <ycheng@google.com>

Thanks for the fix.

> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
>  net/ipv4/tcp_output.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> index 5079832af5c1..257780f93305 100644
> --- a/net/ipv4/tcp_output.c
> +++ b/net/ipv4/tcp_output.c
> @@ -3719,6 +3719,7 @@ static void tcp_connect_queue_skb(struct sock *sk, struct sk_buff *skb)
>   */
>  static int tcp_send_syn_data(struct sock *sk, struct sk_buff *syn)
>  {
> +       struct inet_connection_sock *icsk = inet_csk(sk);
>         struct tcp_sock *tp = tcp_sk(sk);
>         struct tcp_fastopen_request *fo = tp->fastopen_req;
>         int space, err = 0;
> @@ -3733,8 +3734,10 @@ static int tcp_send_syn_data(struct sock *sk, struct sk_buff *syn)
>          * private TCP options. The cost is reduced data space in SYN :(
>          */
>         tp->rx_opt.mss_clamp = tcp_mss_clamp(tp, tp->rx_opt.mss_clamp);
> +       /* Sync mss_cache after updating the mss_clamp */
> +       tcp_sync_mss(sk, icsk->icsk_pmtu_cookie);
>
> -       space = __tcp_mtu_to_mss(sk, inet_csk(sk)->icsk_pmtu_cookie) -
> +       space = __tcp_mtu_to_mss(sk, icsk->icsk_pmtu_cookie) -
>                 MAX_TCP_OPTION_SPACE;
>
>         space = min_t(size_t, space, fo->size);
> --
> 2.34.1
>
Martin KaFai Lau March 17, 2022, 11:11 p.m. UTC | #2
On Wed, Mar 16, 2022 at 04:59:08PM -0700, Jakub Kicinski wrote:
> tp->rx_opt.mss_clamp is not populated, yet, during TFO send so we
> rise it to the local MSS. tp->mss_cache is not updated, however:
> 
> tcp_v6_connect():
>   tp->rx_opt.mss_clamp = IPV6_MIN_MTU - headers;
>   tcp_connect():
>      tcp_connect_init():
>        tp->mss_cache = min(mtu, tp->rx_opt.mss_clamp)
>      tcp_send_syn_data():
>        tp->rx_opt.mss_clamp = tp->advmss
> 
> After recent fixes to ICMPv6 PTB handling we started dropping
> PMTU updates higher than tp->mss_cache. Because of the stale
> tp->mss_cache value PMTU updates during TFO are always dropped.
> 
> Thanks to Wei for helping zero in on the problem and the fix!
> 
> Fixes: c7bb4b89033b ("ipv6: tcp: drop silly ICMPv6 packet too big messages")
> Reported-by: Andre Nash <alnash@fb.com>
> Reported-by: Neil Spring <ntspring@fb.com>
> Reviewed-by: Wei Wang <weiwan@google.com>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: Martin KaFai Lau <kafai@fb.com>
diff mbox series

Patch

diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 5079832af5c1..257780f93305 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -3719,6 +3719,7 @@  static void tcp_connect_queue_skb(struct sock *sk, struct sk_buff *skb)
  */
 static int tcp_send_syn_data(struct sock *sk, struct sk_buff *syn)
 {
+	struct inet_connection_sock *icsk = inet_csk(sk);
 	struct tcp_sock *tp = tcp_sk(sk);
 	struct tcp_fastopen_request *fo = tp->fastopen_req;
 	int space, err = 0;
@@ -3733,8 +3734,10 @@  static int tcp_send_syn_data(struct sock *sk, struct sk_buff *syn)
 	 * private TCP options. The cost is reduced data space in SYN :(
 	 */
 	tp->rx_opt.mss_clamp = tcp_mss_clamp(tp, tp->rx_opt.mss_clamp);
+	/* Sync mss_cache after updating the mss_clamp */
+	tcp_sync_mss(sk, icsk->icsk_pmtu_cookie);
 
-	space = __tcp_mtu_to_mss(sk, inet_csk(sk)->icsk_pmtu_cookie) -
+	space = __tcp_mtu_to_mss(sk, icsk->icsk_pmtu_cookie) -
 		MAX_TCP_OPTION_SPACE;
 
 	space = min_t(size_t, space, fo->size);